Calculate the alpha diversity of each sample.
Arguments
- biom
An rbiom object, such as from
as_rbiom(). Any value accepted byas_rbiom()can also be given here.- adiv
Alpha diversity metric(s) to use. Options are:
"OTUs","Shannon","Chao1","Simpson", and/or"InvSimpson". Setadiv=".all"to use all metrics. Multiple/abbreviated values allowed. Default:"Shannon"- md
Dataset field(s) to include in the output data frame, or
'.all'to include all metadata fields. 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
NULLto use all available, or to1to disable parallel processing. Default:NULL
Value
A data frame of alpha diversity values.
Each combination of sample/depth/adiv has its own row.
Column names are .sample, .depth, .adiv,
and .diversity, followed by any metadata fields requested by
md.
See also
Other alpha_diversity:
adiv_boxplot(),
adiv_corrplot(),
adiv_stats()
Examples
library(rbiom)
# Subset to 10 samples.
biom <- slice(hmp50, 1:10)
adiv_table(biom)
#> # A tibble: 10 × 8
#> .sample .depth .adiv .diversity Age BMI `Body Site` Sex
#> <chr> <dbl> <fct> <dbl> <dbl> <dbl> <fct> <fct>
#> 1 HMP01 1660 Shannon 1.74 22 20 Buccal mucosa Female
#> 2 HMP02 1371 Shannon 2.59 24 23 Buccal mucosa Male
#> 3 HMP03 1353 Shannon 2.95 28 26 Saliva Male
#> 4 HMP04 1895 Shannon 3.26 25 23 Saliva Male
#> 5 HMP05 3939 Shannon 1.46 27 24 Buccal mucosa Female
#> 6 HMP06 4150 Shannon 3.09 32 25 Saliva Male
#> 7 HMP07 3283 Shannon 1.23 26 22 Buccal mucosa Male
#> 8 HMP08 1695 Shannon 2.51 27 26 Saliva Female
#> 9 HMP09 2069 Shannon 3.60 33 32 Saliva Male
#> 10 HMP10 2509 Shannon 1.75 22 20 Anterior nares Female
biom <- rarefy(biom)
adiv_table(biom, md = NULL)
#> # A tibble: 10 × 4
#> .sample .depth .adiv .diversity
#> <fct> <dbl> <fct> <dbl>
#> 1 HMP01 1353 Shannon 1.75
#> 2 HMP02 1353 Shannon 2.58
#> 3 HMP03 1353 Shannon 2.95
#> 4 HMP04 1353 Shannon 3.23
#> 5 HMP05 1353 Shannon 1.42
#> 6 HMP06 1353 Shannon 3.09
#> 7 HMP07 1353 Shannon 1.27
#> 8 HMP08 1353 Shannon 2.50
#> 9 HMP09 1353 Shannon 3.61
#> 10 HMP10 1353 Shannon 1.75
