Skip to contents

Create a matrix of samples x alpha diversity metrics.

Usage

adiv_matrix(biom, adiv = ".all", transform = "none", cpus = NULL)

Arguments

biom

An rbiom object, such as from as_rbiom(). Any value accepted by as_rbiom() can also be given here.

adiv

Alpha diversity metric(s) to use. Options are: "OTUs", "Shannon", "Chao1", "Simpson", and/or "InvSimpson". Set adiv=".all" to use all metrics. Multiple/abbreviated values allowed. Default: ".all"

transform

Transformation to apply. Options are: c("none", "rank", "log", "log1p", "sqrt", "percent"). "rank" is useful for correcting for non-normally distributions before applying regression statistics. Default: "none"

cpus

The number of CPUs to use. Set to NULL to use all available, or to 1 to disable parallel processing. Default: NULL

Value

A numeric matrix with samples as rows. The first column is Depth. Remaining columns are the alpha diversity metric names given by adiv: one or more of OTUs, Shannon, Chao1, Simpson, and InvSimpson.

Examples

    library(rbiom)
    
    biom <- slice_head(hmp50, n = 5)
    
    adiv_matrix(biom)
#>       Depth OTUs  Shannon     Chao1   Simpson InvSimpson
#> HMP01  1660   49 1.741152  59.08333 0.5668413   2.308623
#> HMP02  1371   75 2.587403 104.38889 0.8133915   5.358813
#> HMP03  1353   75 2.950982  90.04167 0.8936622   9.403990
#> HMP04  1895   83 3.255785  93.32143 0.9323644  14.785121
#> HMP05  3939   67 1.462650 127.75000 0.5252254   2.106262
#> attr(,"cmd")
#> [1] "adiv_matrix(biom)"