Diversity measures on communities and samples
Alpha Diversity
Microbiome.shannon — Functionshannon(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!.
Microbiome.shannon! — Functionshannon!(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!.
Microbiome.ginisimpson — Functionginisimpson(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!.
Microbiome.ginisimpson! — Functionginisimpson!(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!.
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.braycurtis — Functionbraycurtis(abt::AbstractAbundanceTable)Returns a pairwise Bray-Curtis dissimilarity matrix.
Microbiome.jaccard — Functionjaccard(abt::AbstractAbundanceTable)Returns a pairwise Jaccard distance matrix.
Microbiome.hellinger — Functionhellinger(abt::AbstractAbundanceTable)Returns a pairwise Hellinger distance matrix.
Microbiome.pcoa — Functionpcoa(abt::AbstractAbundanceTable, f=braycurtis)Returns eigenvectors from fitting MDS to a distance metric generated by f, by default braycurtis.