calculateDiversity: Sample diversity estimation

calculateDiversityR Documentation

Sample diversity estimation

Description

This function uses various methods to estimate the clonotypic diversity of samples based on a matrix of clonotype abundances (samples are columns).

Usage

calculateDiversity(x, ...)

## S4 method for signature 'clonoStats'
calculateDiversity(
  x,
  methods = c("all", "nCells", "nClonotypes", "shannon", "normentropy", "invsimpson",
    "ginisimpson", "chao1", "chaobunge"),
  ...
)

## S4 method for signature 'SingleCellExperiment'
calculateDiversity(x, ...)

Arguments

x

A matrix of abundance values where rows are features (clonotypes) and columns are samples. This is created with summarizeClonotypes using a sparse matrix computed with either EMquant or CRquant.

...

Additional arguments passed to external calculation methods.

methods

A character vector specifying which diversity measures to use (default = 'all', see Details).

Details

Available methods are total cells with appropriate TCR data ('nCells', not a diversity measure, but a useful point of comparison), total clonotypes ('nClonotypes'), Shannon entropy ('shannon'), Simpson index ('simpson'), inverse Simpson index ('invsimpson'), Chao1 richness ('chao1'), and Chao-Bunge richness ('chaobunge'). A special value of 'all' is also allowed, which will run all methods listed above.

The 'chao1' and 'chaobunge' estimates assume all abundances are integers. When this is not the case for the input matrix, k, all values are multiplied by the scaling_factor and rounded to the nearest integer. The resulting estimate is then divided by scaling_factor to return to the original scale. The 'shannon', 'simpson', and 'invsimpson' methods work with any input type.

Value

A matrix of diversity estimates for each sample. Note that the 'chaobunge' method also includes an estimate of the standard error.

Examples

data('contigs')
x <- clonoStats(contigs)
calculateDiversity(x)


kstreet13/VDJdive documentation built on May 31, 2024, 1:26 p.m.