diversity_stats | R Documentation |
Calculate diversity statistics on a matrix containing counts of multilocus genotypes per population.
diversity_stats(z, H = TRUE, G = TRUE, lambda = TRUE, E5 = TRUE, ...)
z |
a table of integers representing counts of MLGs (columns) per population (rows) |
H |
logical whether or not to calculate Shannon's index |
G |
logical whether or not to calculate Stoddart and Taylor's index (aka inverse Simpson's index). |
lambda |
logical whether or not to calculate Simpson's index |
E5 |
logical whether or not to calculate Evenness |
... |
any functions that can be calculated on a vector or matrix of genotype counts. |
This function will calculate any diversity statistic for counts of
multilocus genotypes per population. This does not count allelic diversity.
The calculations of H, G, and lambda are all performed by
vegan::diversity()
. E5 is calculated as
E_{5} =
\frac{(1/\lambda) - 1}{e^{H} - 1}
.
a numeric matrix giving statistics (columns) for each population (rows).
Zhian N. Kamvar
diversity_boot()
diversity_ci()
poppr()
library(poppr)
data(Pinf)
tab <- mlg.table(Pinf, plot = FALSE)
diversity_stats(tab)
## Not run:
# Example using the poweRlaw package to calculate the negative slope of the
# Pareto distribution.
library("poweRlaw")
power_law_beta <- function(x){
xpow <- displ(x[x > 0]) # Generate the distribution
xpow$setPars(estimate_pars(xpow)) # Estimate the parameters
xdat <- plot(xpow, draw = FALSE) # Extract the data
xlm <- lm(log(y) ~ log(x), data = xdat) # Run log-log linear model for slope
return(-coef(xlm)[2])
}
Beta <- function(x){
x <- drop(as.matrix(x))
if (length(dim(x)) > 1){
res <- apply(x, 1, power_law_beta)
} else {
res <- power_law_beta(x)
}
return(res)
}
diversity_stats(tab, B = Beta)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.