divent is a package forR designed to estimatediversity based on HCDT entropy or similarity-based entropy. It is areboot of theentropart package, following the tidyversemanifest and easier to use. This is a short introduction to its use.
The package allows estimating biodiversity according to the frameworkbased on HCDT entropy, the correction of its estimation-bias(Grassberger 1988; Chao and Shen 2003; Chao and Jost2015) 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 etal. 2014) is available.
Phylogenetic or functional diversity(Marconand Hérault 2015) can be estimated, considering phyloentropy asthe average species-neutral diversity over slices of a phylogenetic orfunctional tree(Pavoine and Bonsall2009).
Similarity-based diversity(Leinster andCobbold 2012) can be used to estimate(Marcon, Zhang, and Hérault 2014) functionaldiversity from a similarity or dissimilarity matrix between specieswithout requiring building a dendrogram and thus preserving the topologyof species(Pavoine, Ollier, and Dufour 2005;Podani and Schmera 2007).
The classical diversity estimators (Shannon and Simpson entropy) canbe found in many R packages. Bias correction is rarely available exceptin theEntropyEstimation(Cao andGrabchak 2014) package which provides the Zhang and Grabchak’sestimators of entropy and diversity and their asymptotic variance (notincluded indivent).
Community data is:
Example data is provided in the datasetparacou_6_abd.Let’s get the abundances of tree species in the 6.25-ha tropical forestplot #6 from Paracou forest station in French Guiana. It is divided into4 equally-sized subplots:
## Le chargement a nécessité le package : Rcpp## # A tibble: 4 × 337## site weight Abarema_jupunba Abarema_mataybifolia Amaioua_guianensis## <chr> <dbl> <int> <int> <int>## 1 subplot_1 1.56 2 2 1## 2 subplot_2 1.56 2 0 1## 3 subplot_3 1.56 2 2 0## 4 subplot_4 1.56 4 0 0## # ℹ 332 more variables: Amanoa_congesta <int>, Amanoa_guianensis <int>,## # Ambelania_acida <int>, Amphirrhox_longifolia <int>, Andira_coriacea <int>,## # Apeiba_glabra <int>, Aspidosperma_album <int>, Aspidosperma_cruentum <int>,## # Aspidosperma_excelsum <int>, Bocoa_prouacensis <int>,## # Brosimum_guianense <int>, Brosimum_rubescens <int>, Brosimum_utile <int>,## # Carapa_surinamensis <int>, Caryocar_glabrum <int>, Casearia_decandra <int>,## # Casearia_javitensis <int>, Catostemma_fragrans <int>, …## # A tibble: 4 × 3## site weight abundance## <chr> <dbl> <dbl>## 1 subplot_1 1.56 942## 2 subplot_2 1.56 872## 3 subplot_3 1.56 929## 4 subplot_4 1.56 798The data inparacou_6_abd is an object of classabundances, i.e. a tibble with species as columns and sitesas rows. It can be manipulated as any dataframe and plotted as arank-abundance curve:
Thercommunity function allows drawing randomcommunities, e.g. a log-normal one(Preston1948):
The Whittaker plot (rank-abundance curve) of a random log-normaldistribution of 10000 individuals simulated with default parameter(\(\sigma = 1\)) is produced.
The classical indices of diversity are richness (the number ofspecies), Shannon’s and Simpson’s entropies:
## # A tibble: 4 × 5## site weight estimator order diversity## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 Jackknife 3 0 355## 2 subplot_2 1.56 Jackknife 2 0 348## 3 subplot_3 1.56 Jackknife 2 0 315## 4 subplot_4 1.56 Jackknife 2 0 296## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 UnveilJ 1 4.57## 2 subplot_2 1.56 UnveilJ 1 4.73## 3 subplot_3 1.56 UnveilJ 1 4.65## 4 subplot_4 1.56 UnveilJ 1 4.55## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 Lande 2 0.976## 2 subplot_2 1.56 Lande 2 0.978## 3 subplot_3 1.56 Lande 2 0.980## 4 subplot_4 1.56 Lande 2 0.972When applied to probabilities (created withas_probaVector in the following example), noestimation-bias correction is applied: this means that indices are justcalculated by applying their definition function to the probabilities(that is the naive, or plugin estimator).
## ## Attachement du package : 'dplyr'## Les objets suivants sont masqués depuis 'package:stats':## ## filter, lag## Les objets suivants sont masqués depuis 'package:base':## ## intersect, setdiff, setequal, union## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 naive 1 4.34## 2 subplot_2 1.56 naive 1 4.48## 3 subplot_3 1.56 naive 1 4.45## 4 subplot_4 1.56 naive 1 4.32When abundances are available, many estimators can be used(Marcon 2015) to address unobserved species andthe non-linearity of the indices:
## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 UnveilJ 1 4.57## 2 subplot_2 1.56 UnveilJ 1 4.73## 3 subplot_3 1.56 UnveilJ 1 4.65## 4 subplot_4 1.56 UnveilJ 1 4.55## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 ChaoJost 1 4.51## 2 subplot_2 1.56 ChaoJost 1 4.68## 3 subplot_3 1.56 ChaoJost 1 4.62## 4 subplot_4 1.56 ChaoJost 1 4.50The best available estimator is chosen by default: its name isreturned.
Those indices are special cases of the Tsallis entropy(1988) or order\(q\) (respectively\(q=0,1,2\) for richness, Shannon,Simpson):
## # A tibble: 4 × 5## site weight estimator order entropy## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 UnveilJ 1 4.57## 2 subplot_2 1.56 UnveilJ 1 4.73## 3 subplot_3 1.56 UnveilJ 1 4.65## 4 subplot_4 1.56 UnveilJ 1 4.55Entropy should be converted to its effective number of species,i.e. the number of species with equal probabilities that would yield theobserved entropy, calledHill (1973)numbers or simply diversity(Jost2006).
## # A tibble: 4 × 5## site weight estimator order diversity## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 UnveilJ 1 96.3## 2 subplot_2 1.56 UnveilJ 1 113. ## 3 subplot_3 1.56 UnveilJ 1 105. ## 4 subplot_4 1.56 UnveilJ 1 94.6Diversity is the deformed exponential of order\(q\) of entropy, and entropy is the deformedlogarithm of of order\(q\) ofdiversity:
## [1] 42.28417 44.58777 48.83999 36.01687## [1] 0.9763505 0.9775723 0.9795250 0.9722352## [1] 0.9763505 0.9775723 0.9795250 0.9722352## [1] 42.28417 44.58777 48.83999 36.01687If an ultrametric dendrogram describing species phylogeny (here, amere taxonomy with family, genus and species) is available, phylogeneticentropy and diversity(Marcon and Hérault2015) can be calculated:
## # A tibble: 4 × 4## site weight estimator diversity## <chr> <dbl> <chr> <dbl>## 1 subplot_1 1.56 UnveilJ 41.0## 2 subplot_2 1.56 UnveilJ 52.9## 3 subplot_3 1.56 UnveilJ 46.1## 4 subplot_4 1.56 UnveilJ 43.2Recall that all those functions can be applied to a numeric vectorcontaining abundances, without having to build an object of classabundances.
## # A tibble: 1 × 3## estimator order diversity## <chr> <dbl> <int>## 1 Jackknife 0 0 100With a Euclidian distance matrix between species, similarity-baseddiversity(Leinster and Cobbold 2012; Marcon,Zhang, and Hérault 2014) is available:
# Similarity is computed from the functional distance matrix of Paracou speciesZ<-fun_similarity(paracou_6_fundist)# Calculate diversity of order 2div_similarity(paracou_6_abd,similarities = Z,q =2)## # A tibble: 4 × 5## site weight estimator order diversity## <chr> <dbl> <chr> <dbl> <dbl>## 1 subplot_1 1.56 UnveilJ 2 1.31## 2 subplot_2 1.56 UnveilJ 2 1.33## 3 subplot_3 1.56 UnveilJ 2 1.32## 4 subplot_4 1.56 UnveilJ 2 1.30Diversity can be plotted against its order to provide a diversityprofile. Order 0 corresponds to richness, 1 to Shannon’s and 2 toSimpson’s diversities:
Profiles of phylogenetic diversity and similarity-based diversity areobtained the same way.
# Similarity matrixZ<-fun_similarity(paracou_6_fundist)profile_similarity(paracou_6_abd,similarities = Z)%>% autoplotDiversity can be interpolated or extrapolated to arbitrary samplinglevels.
## # A tibble: 4 × 6## site weight estimator order level diversity## <chr> <dbl> <chr> <dbl> <dbl> <dbl>## 1 subplot_1 1.56 Chao2015 1 1000 78.1## 2 subplot_2 1.56 Chao2015 1 1000 91.1## 3 subplot_3 1.56 Chao2015 1 1000 87.2## 4 subplot_4 1.56 Chao2015 1 1000 78.8The sampling level can be a sample coverage, that is converted to theequivalent number of individuals.
## # A tibble: 4 × 6## site weight estimator order level diversity## <chr> <dbl> <chr> <dbl> <dbl> <dbl>## 1 subplot_1 1.56 Interpolation 1 304 60.5## 2 subplot_2 1.56 Interpolation 1 347 71.4## 3 subplot_3 1.56 Interpolation 1 333 68.6## 4 subplot_4 1.56 Interpolation 1 303 60.5Diversity accumulation curves are available.
Phylogenetic diversity can be addressed the same way. Confidenceintervals of the estimation can be computed, taking into accountsampling variability.
A metacommunity is the assemblage several communities.
The set of communities is described by the abundances of theirspecies and their weight.
Species probabilities in the meta-community are by definition theweighted average of their probabilities in the communities. Abundancesare calculated so that the total abundance of the metacommunity is thesum of all abundances of communities. If weights are equal, then theabundances of the metacommunity are simply the sum of those of thecommunities. If they are not, the abundances of the metacommunity aregenerally not integer values, which complicates the estimation ofdiversity.
Example:
# Abundances of three communities with four species(abd<-matrix(c(10,0,25,10,20,15,10,35,0,10,5,2 ),ncol =4))## [,1] [,2] [,3] [,4]## [1,] 10 10 10 10## [2,] 0 20 35 5## [3,] 25 15 0 2A set of communities is built.
## # A tibble: 3 × 6## site weight sp_1 sp_2 sp_3 sp_4## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>## 1 site_1 1 10 10 10 10## 2 site_2 2 0 20 35 5## 3 site_3 1 25 15 0 2The functionmetacommunity() creates a metacommunity. Toplot it, use argumenttype = "Metacommunity when plottingthespecies_distribution.
## # A tibble: 1 × 6## site weight sp_1 sp_2 sp_3 sp_4## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>## 1 metacommunity 4 24.6 45.7 56.2 15.5Each shade of grey represents a species. Heights correspond to theprobability of species and the width of each community is itsweight.
High level functions allow computing diversity of all communities(\(\alpha\) diversity), of themeta-community (\(\gamma\) diversity),and\(\beta\) diversity, i.e. thenumber of effective communities (the number of communities with equalweights and no common species that would yield the observed\(\beta\) diversity).
Thediv_part function calculates everything at once, fora given order of diversity\(q\):
## # A tibble: 7 × 6## site scale estimator order diversity weight## <chr> <chr> <chr> <dbl> <dbl> <dbl>## 1 Metacommunity gamma "UnveilJ" 1 111. 6.25## 2 Metacommunity beta "" 1 1.09 NA ## 3 Metacommunity alpha "" 1 102. NA ## 4 subplot_1 community "UnveilJ" 1 96.3 1.56## 5 subplot_2 community "UnveilJ" 1 113. 1.56## 6 subplot_3 community "UnveilJ" 1 105. 1.56## 7 subplot_4 community "UnveilJ" 1 94.6 1.56An alternative is thegamma argument of all diversityestimation function to obtain\(\gamma\) diversity instead of the diversityof each community.
## # A tibble: 1 × 4## site estimator order diversity## <chr> <chr> <dbl> <dbl>## 1 Metacommunity UnveilJ 1 111.