
divent is an R package that provides functions toestimate alpha, beta and gamma diversity of communities, includingphylogenetic and functional diversity.
It is a reboot of the packageentropart to make ittidy, easier to use and optimize the code that has been added alongyears of research.
You can install the development version of divent fromGitHub with:
# install.packages("pak")pak::pak("EricMarcon/divent")In the divent package, individuals of differentspecies arecounted in severalcommunities which may (or not) be aggregatedto define ametacommunity. In the metacommunity, theprobability to find a species in the weighted average of probabilitiesin communities. This is a naming convention, which may correspond toplots in a forest inventory or any data organized the same way.
# Abundances of three communities with four speciesabd<-matrix(c(10,0,25,10,20,15,10,35,0,10,5,2 ),ncol =4)# Community weightsw<-c(1,2,1)# Organize the datalibrary("divent")abd|>as_abundances(weights = w)|># Plot itplot(type ="Metacommunity")
Basic functions allow computing diversity of a community. Exampledata is a 6.25ha plot of rainforest in Paracou, French Guiana, dividedinto 4 subplots.
paracou_6_abd|>autoplot()
Entropies such as Shannon’s, Simpson’s, or Hurlbert’s, and explicitdiversity (i.e. effective number of species), aka Hill numbers, areestimated.
# Diversity of a tropical rainforestdiv_richness(paracou_6_abd)#> # 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 296ent_shannon(paracou_6_abd)#> # 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.55ent_simpson(paracou_6_abd)#> # 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.972By default, the best available estimator of diversity is used,according to the data. Diversity profiles are estimated.
profile_hill(paracou_6_abd)%>% autoplot
Communities can be simulated and plotted.
rc<-rcommunity(1,size =10000,distribution ="lnorm")autoplot(rc,fit_rac =TRUE,distribution ="lnorm")
Phylogenetic entropy and diversity can be calculated if aphylogenetic (or functional), ultrametric tree is provided, with thestate-of-the-art estimation-bias correction.
# Phylogenetic diversity of order 1, based on the taxonomydiv_phylo(paracou_6_abd,tree = paracou_6_taxo,q =1)#> # 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.2Similarity-based diversity is calculated, based on a similaritymatrix.
# 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.30The diversity of a metacommunity, i.e.
# Partitioning of diversity of order 1 (Shannon)div_part(paracou_6_abd,q =1)#> # 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.56A quickintroductionis invignette("divent").
A full documentation is available online, in the “Articles” sectionof the web site of the vignette.
Thedocumentationof the development version is also available.
Marcon, E. and Herault, B. (2015). entropart: An R Package to Measureand Partition Diversity.Journal of Statistical Software.67(8): 1-26.