Measures and compares the diversity of biological communities
(e.g. tables of operational taxonomic units (OTUs), amplicon sequence
variants (ASVs) or metagenome-assembled genomes (MAGs)) based on Hill
numbers, in a unified framework for neutral, phylogenetic and functional
diversity measurement, diversity partitioning, (dis)similarity
measurement, diversity profiles, evenness and redundancy. The
statistical framework encompasses richness, Shannon and Simpson
diversity, Faith's phylogenetic diversity (PD), Rao's quadratic entropy
and Sorensen- and UniFrac-type dissimilarities, all grounded in a single
Hill-number framework. Methods are described in Jost (2007)
hilldiv3 measures and compares the diversity of biological communities —
OTU, ASV or MAG count tables — using Hill numbers. Hill numbers are a
single, intuitive family of diversity metrics: each one is an effective number
of taxa ("how many equally-abundant taxa would give this much diversity"), and
one parameter, the diversity order q, slides smoothly between counting all
taxa equally (richness), weighting them by abundance (Shannon) and focusing on
the common ones (Simpson). Because everything is expressed in the same currency,
results are directly comparable across samples, studies and methods.
From that one foundation, hilldiv3 provides a unified toolkit for neutral
diversity (abundances only), phylogenetic diversity (accounting for how
related taxa are) and functional diversity (accounting for how different
their traits are), covering measurement, partitioning, (dis)similarity,
profiles, evenness and redundancy. You call the same functions for all three —
the diversity type is chosen by whether you supply a tree or a distance matrix.
# install.packages("devtools")
devtools::install_github("alberdilab/hilldiv3")
library(hilldiv3)
# Bundled simulated gut-microbiome MAG data.
hilldiv(gut_counts) # neutral Hill numbers q = 0, 1, 2
hilldiv(gut_counts, tree = gut_tree) # neutral + phylogenetic
dist <- traits2dist(gut_traits)
hilldiv(gut_counts, dist = dist) # neutral + functional
hilldiv(gut_counts, tree = gut_tree, dist = dist) # all three types at once
# Results are tidy by default and plot directly.
plot(hillprof(gut_counts)) # diversity profile
hilldiv(gut_counts, out = "matrix") # matrix: samples x q orders
Full documentation lives on the package website: https://alberdilab.github.io/hilldiv3/
vignette("hilldiv3"), a gentle introduction for anyone
using Hill numbers for the first time.If you have used hilldiv2, v3 is a
full redesign that keeps the familiar function names (hilldiv(),
hillpart(), hilldiss(), hillsim(), hillpair(), hillred(), tss(),
traits2dist()) while changing how they work underneath:
match_data() helper.phyloseq and
TreeSummarizedExperiment objects.ape post-order traversal in place
of geiger::tips(); hillpair() computes the shared structure once and
reuses it across all sample pairs.hill* function returns a long-format
data.frame with print()/plot()/autoplot() methods; pass
out = "matrix" for a plain matrix.type = c("auto", "neutral", "phylogenetic", "functional")
argument that asserts and validates the diversity type (auto-detected by
default).hillprof() (diversity profiles) and hilleven() (evenness),
hierarchical multi-scale partitioning in hillpart(), plus bundled example
data (gut_counts, gut_tree, gut_traits).See NEWS.md for the full changelog.