entropart is a package for R designed to estimate diversity based on HCDT entropy or similarity-based entropy. This is a short introduction to its use.
The entropart package allows estimating biodiversity according to the framework based on HCDT entropy, the correction of its estimation-bias (Grassberger 1988; Chao and Shen 2003; Chao and Jost 2015) and its transformation into equivalent numbers of species (Hill 1973; Jost 2006; Marcon et al. 2014). Estimation of diversity at arbitrary levels of sampling, requiring interpolation or extrapolation (Chao et al. 2014) is available
Phylogenetic or functional diversity (Marcon and Hérault 2015) can be estimated, considering phyloentropy as the average species-neutral diversity over slices of a phylogenetic or functional tree (S. Pavoine, Love, and Bonsall 2009).
Similarity-based diversity (Leinster and Cobbold 2012) can be used to estimate (Marcon, Zhang, and Hérault 2014) functional diversity from a similarity or dissimilarity matrix between species without requiring building a dendrogram and thus preserving the topology of species (Sandrine Pavoine, Ollier, and Dufour 2005; Podani and Schmera 2007).
The classical diversity estimators (Shannon and Simpson entropy) can be found in many R packages. vegetarian (Charney and Record 2009) allows calculating Hill numbers and partitioning them according to Jost’s framework. Bias correction is rarely available except in the EntropyEstimation (Cao and Grabchak 2014) package which provides the Zhang and Grabchak’s estimators of entropy and diversity and their asymptotic variance (not included in entropart).
Community data is a numeric vector containing abundances of species (the number of individual of each species) or their probabilities (the proportion of individuals of each species, summing to 1).
Example data is provided in the dataset
paracou618. Let’s get the abundances of tree species in the 1-ha tropical forest plot #18 from Paracou forest station in French Guiana:
library("entropart") data("Paracou618") <- Paracou618.MC$Nsi[, "P018"]N18
The data in
Paracou618.MC is a
MetaCommunity, to be discovered later.
N18 is a vector containing the abundances of 425 tree species, among them some zero values. This is the most simple and common format to provide data to estimate diversity. It can be used directly by the functions presented here, but it may be declared explicitely as an abundance vector to plot it, and possibly fit a well-known, e.g. log-normal (Preston 1948), distribution of species abundance (the red curve):
<- as.AbdVector(N18) Abd18 autoplot(Abd18, Distribution="lnorm")
Abundance vectors can also be converted to probability vectors, summing to 1:
rCommunity function allows drawing random communities:
<- rCommunity(1, size=10000, Distribution = "lseries", alpha = 30) rc autoplot(rc, Distribution="lseries")
The Whittaker plot of a random log-series (Fisher, Corbet, and Williams 1943) distribution of 10000 individuals simulated with parameter \(\alpha=30\) is produced.
The classical indices of diversity are richness (the number of species), Shannon’s and Simpson’s entropies:
## None ## 149
## None ## 4.421358
## None ## 0.9794563
When applied to a probability vector (created with
as.ProbaVector or a numeric vector summing to 1), no estimation-bias correction is applied: this means that indices are just calculated by applying their definition function to the probabilities (that is the plugin estimator).
When abundances are available (a numeric vector of integer values or an object created by
as.ProbaVector), several estimators are available (Marcon 2015) to address unobserved species and the non-linearity of the indices:
## Jackknife 3 ## 309
## UnveilJ ## 4.772981
## Lande ## 0.9814969
The best available estimator is chosen by default: its name is returned.
Those indices are special cases of the Tsallis entropy (1988) or order \(q\) (respectively \(q=0,1,2\) for richness, Shannon, Simpson):
## UnveilJ ## 4.772981
Entropy should be converted to its effective number of species, i.e. the number of species with equal probabilities that would yield the observed entropy, called Hill (1973) numbers or simply diversity (Jost 2006).
## UnveilJ ## 118.2713
Diversity is the deformed exponential of order \(q\) of entropy, and entropy is the deformed logarithm of of order \(q\) of diversity:
## UnveilJ ## 53.97842
## UnveilJ ## 0.9814741
## UnveilJ ## 0.9814741
## UnveilJ ## 53.97842
Diversity can be plotted against its order to provide a diversity profile. Order 0 corresponds to richness, 1 to Shannon’s and 2 to Simpson’s diversities:
<- CommunityProfile(Diversity, Abd18) DP autoplot(DP)
If an ultrametric dendrogram describing species’ phylogeny (here, a mere taxonomy with family, genus and species) is available, phylogenetic entropy and diversity (Marcon and Hérault 2015) can be calculated:
## alpha or gamma phylogenetic or functional diversity of order 1 of distribution ## Abd18 ## with correction: Best ## Phylogenetic or functional diversity was calculated according to the tree ## Paracou618.Taxonomy ## ## Diversity is normalized ## ## Diversity equals: 53.73643
With a Euclidian distance matrix between species, similarity-based diversity (Leinster and Cobbold 2012; Marcon, Zhang, and Hérault 2014) is available:
# Prepare the similarity matrix <- as.matrix(Paracou618.dist) DistanceMatrix # Similarity can be 1 minus normalized distances between species <- 1 - DistanceMatrix/max(DistanceMatrix) Z # Calculate diversity of order 2 Dqz(Abd18, q=2, Z)
## Best ## 1.477898
Profiles of phylogenetic diversity and similarity-based diversity are obtained the same way.
PhyloDiversity is an object with a lot of information so an intermediate function is necessary to extract its
<- CommunityProfile(Dqz, Abd18, Z=Z) sbDP <- CommunityProfile(function(X, ...) PhyloDiversity(X, ...)$Total, Abd18, Tree=Paracou618.Taxonomy) pDP autoplot(pDP)
A meta-community is an object defined by the package. It is a set of communities, each of them decribed by the abundance of their species and their weight. Species probabilities in the meta-community are by definition the weighted average of their probabilities in the communities.
The easiest way to build a meta-community consists of preparing a dataframe whose columns are communities and lines are species, and define weights in a vector (by default, all weights are equal):
library("entropart") <- data.frame(C1 = c(10, 10, 10, 10), C2 = c(0, 20, 35, 5), C3 = c(25, 15, 0, 2), row.names = c("sp1", "sp2", "sp3", "sp4")))(df
## C1 C2 C3 ## sp1 10 0 25 ## sp2 10 20 15 ## sp3 10 35 0 ## sp4 10 5 2
<- c(1, 2, 1)w
MetaCommunity function creates the meta-community. It can be plotted:
<- MetaCommunity(Abundances = df, Weights = w) MC plot(MC)
Each shade of grey represents a species. Heights correspond to the probability of species and the width of each community is its weight.
Paracou618.MC is an example meta-community provided by the package. It is made of two 1-ha communities (plots #6 and #18) of tropical forest.
High level functions allow computing diversity of all communities (\(\alpha\) diversity), of the meta-community (\(\gamma\) diversity), and \(\beta\) diversity, i.e. the number of effective communities (the number of communities with equal weights and no common species that would yield the observed \(\beta\) diversity).
DivPart function calculates everything at once, for a given order of diversity \(q\):
<- DivPart(q = 1, MC = Paracou618.MC) p summary(p)
## HCDT diversity partitioning of order 1 of metaCommunity Paracou618.MC ## ## Alpha diversity of communities: ## P006 P018 ## 66.00455 83.20917 ## Total alpha diversity of the communities: ##  72.88247 ## Beta diversity of the communities: ## None ## 1.563888 ## Gamma diversity of the metacommunity: ## None ## 113.98
The \(\alpha\) diversity of communities is 73 effective species. \(\gamma\) diversity of the meta-community is 114 effective species. \(\beta\) diversity is 1.56 effective communities, i.e. the two actual communities are as different from each other as 1.56 ones with equal weights and no species in common.
DivEst function decomposes diversity and estimates confidence interval of \(\alpha\), \(\beta\) and \(\gamma\) diversity following Marcon et al. (2012). If the observed species frequencies of a community are assumed to be a realization of a multinomial distribution, they can be drawn again to obtain a distribution of entropy.
<- DivEst(q = 1, Paracou618.MC, Simulations = 50)de
# Margin adjustment required for this vignette html output par(mar=c(1,1,2.2,1)) autoplot(de)
The result is a
Divest object which can be summarized and plotted.
DivProfile calculates diversity profiles. The result is a
DivProfile object which can be summarized and plotted.
<- DivProfile(q.seq = seq(0, 2, 0.1), Paracou618.MC) dp autoplot(dp)
Plot #18 can be considered more diverse than plot #6 because their profiles (top right figure, plot #18 is the dotted red line, plot #6, the solid black one) do not cross (Tothmeresz 1995): its diversity is systematically higher. The shape of the \(\beta\) diversity profile shows that the communities are more diverse when their dominant species are considered.
The bootstrap confidence intervals of the values of diversity (Marcon et al. 2012, 2014) are calculated if
NumberOfSimulations is not 0.
DivProfile use plugin estimators by default. To force them to apply the same estimators as community functions, the argument
Biased = FALSE must be entered. They compute Tsallis entropy and Hill numbers by default. A dendrogram in the argument
Tree or a similarity matrix in the argument
Z will make them calculate phylogenetic diversity or similarity-based diversity.