| hilldiv | R Documentation |
Compute neutral, phylogenetic and/or functional Hill numbers (alpha
diversity) from a single sample or a count table. By default the computation
is cumulative: every diversity type whose inputs are present is returned.
Counts are always available, so neutral is always computed; a tree adds
phylogenetic and a dist adds functional. Supplying both a tree and a
dist therefore returns neutral, phylogenetic and functional side by side in
a single tibble (with a type column). Use type to restrict the output to
a subset.
hilldiv(
data,
q = c(0, 1, 2),
tree = NULL,
dist = NULL,
tau = NULL,
type = c("auto", "neutral", "phylogenetic", "functional"),
reference = c("pool", "sample"),
out = c("tibble", "matrix")
)
data |
Counts: a numeric vector (one sample), a matrix/data.frame
(taxa x samples), a |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type(s) to compute. |
reference |
Reference tree depth for phylogenetic Hill numbers
(ignored for neutral and functional types). |
out |
Output shape: |
A long-format data.frame of class hill_diversity (default). With
out = "matrix", a matrix of Hill numbers (samples in rows, diversity
orders q0, q1, ... in columns) for a single type, or a named list of
such matrices when several types are computed.
Chao, A., Chiu, C.-H. & Jost, L. (2010). Phylogenetic diversity measures
based on Hill numbers. Phil. Trans. R. Soc. B, 365, 3599-3609.
Alberdi, A. & Gilbert, M.T.P. (2019). A guide to the application of Hill
numbers to DNA-based diversity analyses. Mol. Ecol. Resour., 19, 804-817.
hillpart(), hilldiss(), hillprof()
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3,
dimnames = list(c("t1", "t2", "t3"), c("s1", "s2")))
hilldiv(counts)
hilldiv(counts, q = c(0, 1, 2))
plot(hilldiv(counts, q = c(0, 1, 2)))
# Supplying both a tree and a distance matrix returns neutral, phylogenetic
# and functional diversity together, distinguished by a `type` column.
tree <- ape::read.tree(text = "((t1:1,t2:1):1,t3:2);")
dist <- as.matrix(stats::dist(c(t1 = 0, t2 = 1, t3 = 4)))
hilldiv(counts, tree = tree, dist = dist)
# Restrict the output with `type` (a scalar or a vector):
hilldiv(counts, tree = tree, dist = dist, type = c("neutral", "functional"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.