chao1 | R Documentation |
Chao1 alpha diversity metric.
A non-parametric estimator of the number of unobserved species in a sample.
The Chao1 index estimates total species richness based on the number of
species that occur only once (singletons) and twice (doubletons) in the
sample.
chao1(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.
Prerequisite: all counts are whole numbers.
In the formulas below, x
is a single column (sample) from counts
.
n
is the total number of non-zero OTUs, a
is the number of
singletons, and b
is the number of doubletons.
D = \displaystyle n + \frac{a^{2}}{2b}
x <- c(1, 0, 3, 2, 6) sum(x>0) + (sum(x==1) ^ 2) / (2 * sum(x==2)) #> 4.5
Note that when x
does not have any singletons or doubletons
(a = 0, b = 0
), the result will be NaN
. When x
has singletons
but no doubletons (a > 0, b = 0
), the result will be Inf
.
Chao A 1984. Non-parametric estimation of the number of classes in a population. Scandinavian Journal of Statistics, 11:265-270.
Other alpha_diversity:
faith()
,
inv_simpson()
,
shannon()
,
simpson()
# Example counts matrix
ex_counts
# Chao1 diversity values
chao1(ex_counts)
# Low diversity
chao1(c(100, 1, 1, 1, 1)) # Inf
# High diversity
chao1(c(20, 20, 20, 20, 20)) # NaN
# Low richness
chao1(1:3) # 3.5
# High richness
chao1(1:100) # 100.5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.