inv_simpson | R Documentation |
Inverse Simpson alpha diversity metric.
inv_simpson(counts, cpus = n_cpus())
counts |
An OTU abundance matrix where each column is a sample, and
each row is an OTU. Any object coercible with |
cpus |
How many parallel processing threads should be used. The
default, |
A numeric vector.
Pre-transformation: drop all OTUs with zero abundance.
In the formulas below, x
is a single column (sample) from counts
.
p
are the relative abundances.
p_{i} = \displaystyle \frac{x_i}{\sum x}
D = \displaystyle 1 / \sum_{i = 1}^{n} p_{i}\times\ln(p_{i})
x <- c(4, 0, 3, 2, 6)[-2] p <- x / sum(x) 1 / sum(p * log(p)) #> -0.7636352
Simpson EH 1949. Measurement of diversity. Nature, 163. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/163688a0")}
Other alpha_diversity:
chao1()
,
faith()
,
shannon()
,
simpson()
# Example counts matrix
ex_counts
# Inverse Simpson diversity values
inv_simpson(ex_counts)
# Low diversity
inv_simpson(c(100, 1, 1, 1, 1)) # 1.08
# High diversity
inv_simpson(c(20, 20, 20, 20, 20)) # 5
# Low richness
inv_simpson(1:3) # 2.57
# High richness
inv_simpson(1:100) # 75.37
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.