simpson | R Documentation |
Simpson alpha diversity metric.
Gauges the uniformity of species within a community. A Simpson index of 0
indicates that one or a few high abundance OTUs dominate the community,
which is indicative of low diversity.
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)) #> 2.309526
Simpson EH 1949. Measurement of diversity. Nature, 163. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/163688a0")}
Other alpha_diversity:
chao1()
,
faith()
,
inv_simpson()
,
shannon()
# Example counts matrix
ex_counts
# Simpson diversity values
simpson(ex_counts)
# Low diversity
simpson(c(100, 1, 1, 1, 1)) # 0.075
# High diversity
simpson(c(20, 20, 20, 20, 20)) # 0.8
# Low richness
simpson(1:3) # 0.61
# High richness
simpson(1:100) # 0.99
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.