Diversity measures on communities and samples

Alpha Diversity

Microbiome.shannonFunction
shannon(v::Union{AbstractVector, AbstractSparseMatrix}) 
shannon(abt::AbstractAbundanceTable)

Computes the Shannon alpha diversity metric for a vector. When called on an AbstractAbundanceTable, returns a 1 x nsamples matrix with 1 entry per sample. See also shannon!.

source
Microbiome.shannon!Function
shannon!(abt::AbstractAbundanceTable; overwrite=false)

Adds a :shannon entry to the metadata for each sample in abt with the Shannon alpha diversity of that sample (see shannon). If overwrite=false (the default), uses insert! to perform this operation, so an error will be thrown if any sample already contains a :shannon entry. Otherwise, uses set!.

source
Microbiome.ginisimpsonFunction
ginisimpson(v::Union{AbstractVector, AbstractSparseMatrix}) 
ginisimpson(abt::AbstractAbundanceTable, overwrite=false)

Computes the Gini-Simpson alpha diversity metric for a vector. When called on an AbstractAbundanceTable, returns a 1 x nsamples matrix with 1 entry per sample. See also ginisimpson!.

source
Microbiome.ginisimpson!Function
ginisimpson!(abt::AbstractAbundanceTable; overwrite=false)

Adds a :ginisimpson entry to the metadata for each sample in abt with the Gini-Simpson alpha diversity of that sample (see ginisimpson). If overwrite=false (the default), uses insert! to perform this operation, so an error will be thrown if any sample already contains a :ginisimpson entry. Otherwise, uses set!.

source

Beta Diversity

Quite often, it's useful to boil stuff down to distances between samples. AbstractAbundanceTables take advantage of the pairwise function from Distances.jl to get a symetric distance matrix.

Right now, only Bray-Curtis, Jaccard, and Hellinger are implemented, but it would be straightforward to add any others. Open an issue if you want them!

You can also get fit a principal coordinates analysis (PCoA) to your AbstractAbundanceTable using the fit(MDS, ...) from MultivariateStats.jl under the hood.

Microbiome.pcoaFunction
pcoa(abt::AbstractAbundanceTable, f=braycurtis)

Returns eigenvectors from fitting MDS to a distance metric generated by f, by default braycurtis.

source