Skip to contents

Alpha diversity wrapper

Usage

alpha_div(counts, metric, ...)

Arguments

counts

An OTU abundance matrix where each column is a sample, and each row is an OTU. Any object coercible with as.matrix() can be given here, as well as phyloseq, rbiom, SummarizedExperiment, and TreeSummarizedExperiment objects.

metric

The name of an alpha diversity metric. Current options are c('observed', 'chao1', 'shannon', 'simpson', 'inv_simpson', 'faith'). Case-insensitive and partial name matching is supported. Options are also available via names(metrics$alpha).

...

Additional options to pass through to the called function. I.e. cpus or tree.

Value

A numeric vector.

See also

Other alpha_diversity: beta_div(), chao1(), faith(), inv_simpson(), observed(), shannon(), simpson()

Examples

    # Example counts matrix
    ex_counts
#>                   Saliva Gums Nose Stool
#> Streptococcus        162  793   22     1
#> Bacteroides            2    4    2   611
#> Corynebacterium        0    0  498     1
#> Haemophilus          180   87    2     1
#> Propionibacterium      1    1  251     0
#> Staphylococcus         0    1  236     1
    
    # Shannon diversity values
    alpha_div(ex_counts, 'Shannon')
#>     Saliva       Gums       Nose      Stool 
#> 0.74119910 0.36684449 1.14222899 0.04824952 
    
    # Chao1 diversity values
    alpha_div(ex_counts, 'c')
#> Saliva   Gums   Nose  Stool 
#>    4.5    Inf    6.0    Inf 
    
    # Faith PD values
    alpha_div(ex_counts, 'faith', tree = ex_tree)
#> Saliva   Gums   Nose  Stool 
#>    180    191    215    202