A richness metric that normalizes the number of species by the log of the total sample size.
Usage
margalef(counts, margin = 1L, cpus = n_cpus())Arguments
- counts
A numeric matrix of count data (samples \(\times\) features). Typically contains absolute abundances (integer counts), though proportions are also accepted.
- margin
The margin containing samples.
1if samples are rows,2if samples are columns. Ignored whencountsis a special object class (e.g.phyloseq). Default:1- cpus
How many parallel processing threads should be used. The default,
n_cpus(), will use all logical CPU cores.
Details
Margalef's index is defined as: $$\frac{n - 1}{\ln{X_T}}$$
Where:
\(n\) : The number of features.
\(X_T\) : Total of all counts (sequencing depth).
Base R Equivalent:
Input Types
The counts parameter is designed to accept a simple numeric matrix, but
seamlessly supports objects from the following biological data packages:
phyloseqrbiomSummarizedExperimentTreeSummarizedExperiment
For large datasets, standard matrix operations may be slow. See
vignette('performance') for details on using optimized formats
(e.g. sparse matrices) and parallel processing.
References
Margalef, R. (1958). Information theory in ecology. General Systems, 3, 36-71.
Gamito, S. (2010). Caution is needed when applying Margalef diversity index. Ecological Indicators, 10(2), 550-551. doi:10.1016/j.ecolind.2009.07.006
See also
Other Richness metrics:
ace(),
chao1(),
menhinick(),
observed(),
squares()
