Description Usage Arguments Details Value References Examples

View source: R/DER.R


An algorithm for differentiating samples on the basis of the rarity, heterogeneity, evenness, taxonomic/phylogenetic and functional diversity indices that better reflect the differences among assemblages.


DER(data, Samples, Species, Taxon, TaxonFunc=NULL, TaxonPhyl=NULL,
pos=NULL, varSize="Richness", varColor="Rarity", Index=NULL, corr="sqrt",
palette= "heat.colors", size=c(1,5),digitsS=0, digitsC=2, ncolor=100,
transparency=1, references=TRUE, a=1.5, q=2.5, ResetPAR=TRUE, PAR=NULL,
dbFD=NULL, LEGENDS=NULL, TEXT=NULL, COLOR=c("#EEC591FF", "black", "grey50"),
file1="Diversity indices.csv", file2="Polar coordinates.csv",
file3="Indices and area of the polygon.csv", na="NA", dec=",", row.names=FALSE, save=TRUE)



Data file with the taxonomy, abundance of the species and functional traits (optional). The format of the file must be: an optional column with the position of labels' samples in the DER plot (blue column) in the same order as the variables with the species' abundance in the samples (red columns), the columns with the taxonomy of the species (as many as needed, green columns), the columns with the abundance of the species in each sample (red columns) and optionally the columns with the functional traits of the species. Each row is an unique species, genus, family, etc.


Variables with the abundance of the species in each sample: sampling sites, dates, etc.


Variable with the name of the species (without including the genus). It may be other node of the phylogenetic tree, such as the genus, family, etc., for genus level phylogenies, family level phylogenies, etc.


Variables with the taxonomy of the species (taxonomic diversity), as many levels as needed but without including the variable with the node of the argument Species.


Optionally variables with the functional traits (functional diversity).


Optionally the name of the RData file of the class phylo with the phylogeny. The file must be in the working directory.


Optionally it is possible to indicate a column with the position of labels' samples in the DER plot. It must be as many as the number of samples and in the same order than the variables described in the argument Samples. Values of 1, 2, 3 and 4, respectively indicate positions below, to the left of, above and to the right of the specified coordinates.


This variable defines the size of the bubble in the DER plot.


This variable defines the color gradient of the bubbles in the DER plot.


The four/five indices used in the DER algorithm. If it is NULL the algorithm select one, index of rarity, one of heterogeneity, one of evenness one of taxonomy and one of the functional group (if functional traits are provided in the argument TaxonFunc) that achieve a higher dispersion among samples in a polar coordinates system.


Character string specifying the correction method to use, in the function dbFD, when the species-by-species distance matrix cannot be represented in a Euclidean space. Options are "sqrt" (default), "cailliez", "lingoes" or "none".


The color gradient of the bubbles may be one of these palettes: "heat.colors", "terrain.colors", "gray.colors", "topo.colors" or "cm.colors", or any other option defined by the user.


Range of size of the bubbles. Two values: minimum and maximum size.


Number of digits of the bubble size legend.


Number of digits of the color legend.


Gradient color of the color legend.


Transparency of the color gradient, from 0 to 1.


If it is TRUE the reference points are depicted on the DER plot.


Scale of Rényi diversity.


Scale of Tsallis diversity.


If it is FALSE, the default condition of the function PAR of the package StatR is not placed and maintained those defined by the user in previous graphics.


It accesses the function PAR of the package StatR that allows to modify many different aspects of the graph.


It accesses the function dbFD which allows to specify the arguments that calculates the functional diversity indices.


It allows to modify the legend of the bubble size.


It allows to modify the text of the labels in the bubbles.


A vector with three values: color of the ellipse, color of the points in the legend of the size of the bubbles and color of the references points in the ellipse, respectively.


CSV FILES. Filename with values of total abundance, richness and the rarity, heterogeneity, evenness, taxonomic, phylogenetic and functional diversity indices of each sample.


CSV FILES. Filename with the polar coordinates of all samples considering the four/five selected indices.


CSV FILES. Filename with the area of the convex hull (alpha=6) and Euclidean distance obtained in the polar coordinates system for all combinations of the indices.


CSV FILE. Text that is used in the cells without data.


CSV FILE. It defines if the comma "," is used as decimal separator or the dot ".".


CSV FILE. Logical value that defines if identifiers are put in rows or a vector with a text for each of the rows.


If it is TRUE, the CSV files are saved.


DER algorithm

The steps of DER algorithm are described below:

1. The function DER calculates the most often used indices (see below): a total of 39 indices that includes 2 of rarity, 14 of heterogeneity, 7 of evenness, 2 of taxonomic diversity, 8 of phylogenetic diversity and 6 of functional diversity. It is important to mention that the indices included in the groups of phylogenetic diversity and functional diversity, each explores a different facet of phylogenetic diversity (Kembel et al., 2010) and functional diversity (Laliberté et al., 2010), respectively.

Rarity indices

In the following equations S is the number of species (species richness), s is the number of samples, r_{ij} is the number of records of the species i in the sample j, R is the total number of records considering all the species in all samples, Q_i is the occurrence of species i, Q_{min} and Q_{max} are respectively the minimum and maximum occurrences in the species pool, r is the chosen rarity cutoff point (as a percentage of occurrence), w_i is the weight of the ith species in the assemblage, w_{min} and w_{max} the minimum and maximum weights respectively.

Leroy (Leroy et al., 2012; 2013)



Rarity This index is a novel contribution of this package.


Heterogeneity indices

In the following equations S is the number of species (species richness), p_i is the abundace's proportion of species i, N is the total number of individuals in the sample, n_i is the number of individuals of the species i, n_{max} is the number of individuals of the most abundant species, a and q are the orders of Rényi and Tsallis indices respectively and, finally, in Fisher's alpha the index is the α parameter.

log Shannon-Wiener (S.W.LOG2) and ln Shannon-Wiener (S.W) (Wiener, 1939; 1948; 1949; Shannon, 1948; Shannon & Weaver, 1949). See Spellerger & Fedor (2013) for an explanation of the dual use of the terms Shannon-Wiener and Shannon-Weaver to refer to this diversity index.



Fisher's alpha (Fisher et al., 1943)


Simpson (Simpson, 1949)


Inverse Simpson (InvSimpson) Williams (1964)


Brillouin (Brillouin, 1956)


Margalef (Margalef, 1959)


Rényi entropy (Rényi, 1961)


Menhinick (Menhinick, 1964)


McIntosh (McIntosh, 1967)


Inverse Berger-Parker (InvB.P) (Berger & Parker, 1970)


Hill numbers (Hill, 1973)






a or q = 0 is species richness

a or q = 1 is Shannon's index (H')

a or q = 2 is Inverse Simpson's index (D_2)

a or q = Inf is Inverse Berger-Parker index (D_{BP})

Tsallis entropy (Patil & Taillie, 1982; Tsallis, 1988)


Evenness indices

Annotations of the equations as mentioned for heterogeneity indices.

Simpson evenness (SimpsonE) (Simpson, 1949)


Pielou (PielouE) (Pielou, 1966)


McIntosh evenness (McIntoshE) (McIntosh, 1967)


Hill evenness (HillE) (Hill, 1973)

It is used Hill-Rényi numbers where in N_2 the value of a = 2 and in N_2 the value of a = 1


Heip evenness (HeipE) (Heip, 1974)


Camargo (CamargoE) (Camargo, 1992)


Smith and Wilson's Index (Evar) (Smith and Wilson, 1996)


Taxonomic diversity indices

In the following equations summation goes over species i and j, ω are the taxonomic distances among taxa, x are species abundances, and n is the total abundance for a site.

Taxonomic diversity (D) (Clarke, 1995; 1998; 2001):


Taxonomic distinctness (Dstar) (Clarke and Warwick, 1998):


Phylogenetic diversity indices

Faith's phylogenetic diversity Faith (1992)
Mean pairwise phylogenetic distance Webb et al. (2008)
Mean nearest taxon distance Webb et al. (2008)
Phylogenetic species richness Helmus et al. (2007)
Phylogenetic species variability Helmus et al. (2007)
Phylogenetic species evenness Helmus et al. (2007)
Phylogenetic species clustering Helmus et al. (2007)
Quadratic entropy Rao (1982)

Functional diversity indices

In the following equations S is the number of species, where d_{ij} is the difference between the i-th and j-th species, p_i is the abundance's proportion of the species i, p_j is the abundance's proportion of the species j, EW is weighted evenness, dist(i, j) is the Euclidean distance between species i and j, the species involved is branch l, w_i is the relative abundance of the species i, PEW_l is the partial weighted evenness, g_k are the coordinates of the center of gravity of the V species forming the vertices of the convex hull, x_{ik} is the coordinate of species i on trait k, dG_i is the Euclidean distance of the center of gravity, \bar{dG} is the mean distance of the S species to the center of gravity, Δd is the sum of abundance-weighted deviances and Δ|d| absolute abundance-weighted deviances.

Rao's quadratic entropy (Rao, 1982; Botta-Dukát, 2005):



Functional group richness (FGR) Petchey and Gaston (2006)

Functional richness (FRic) is measured as the amount of functional space (convex hull volume) filled by the community (Villéger et al., 2008).

Functional evenness (FEve) (Villéger et al., 2008):


PEW_l=\frac{EW_l}{\displaystyle∑_{l=1}^{S}EW_l} EW_l=\frac{dis(i,j)}{w_i+w_j}

Functional divergence (FDiv) (Villéger et al., 2008):


Δ{|d|}=\displaystyle∑_{i=1}^{S}w_i|dG_i-\bar{dG}| Δ{d}=\displaystyle∑_{i=1}^{S}w_i(dG_i-\bar{dG})
\bar{dG}=\frac{1}{S}\displaystyle∑_{i=1}^{S}dG_i dG_i=√{\displaystyle∑_{k=1}^{T}(x_{ik}-g_k)^2} g_k=\frac{1}{V}\displaystyle∑_{i=1}^{V}x_{ik}

Functional dispersion (FDis) (Laliberté and Legendre, 2010):

FDisp=\frac{∑{a_jz_j}}{∑{a_j}} c=\frac{∑{a_jx_{ij}}}{∑{a_j}}

2. Each index is transformed to a scale range between 0 and 1 for all samples with the following equation:

\frac{(index of the sample-min)}{(max-min)}

where min and max are the minimum and maximum values of the index considering all samples, respectively.

3. With the standardized values of the indices, the algorithm calculates the polar coordinates of all samples with all possible combinations among all groups of indices. Therefore, in each combination an index of each group of rarity, heterogeneity (species richness is included in this group), evenness, taxonomic/ phylogenetic diversity and functional diversity (if it is included functional traits in the analysis) is used for calculating the polar coordinates of all samples. In the group of taxonomic/phylogenetic diversity the user must use either taxonomy or a phylogenetic tree, so either taxonomic diversity or phylogenetic diversity indices are used in the algorithm. The X and Y polar coordinates for each sample are estimated using the following equations:

X=\displaystyle∑_{i=1}^{4}|z_j|cos(α) Y=\displaystyle∑_{i=1}^{4}|z_j|sin(α)

where z is the standardized value of the index j of the four groups considered.

Each index is assigned an angle (α). Degrees to radians angle conversion is carried out assuming that 1 degree = 0.0174532925 radians.

4. With the polar coordinates of the samples obtained for each combination, it is calculated the convex hull (alpha = 6) and the mean Euclidean distance, and the values are saved in a file.

5. The algorithm selects the combination of indices with the highest value of the mean between convex hull and mean Euclidean distance among samples, therefore priority is given to maximize dispersion among samples (see Fig. 1). The polar coordinates of the selected combination are depicted on a diagram, where it is possible to see the differences in rarity, heterogeneity, evenness and taxonomic/phylogenetic diversity and/or functional diversity (if it is included) among assemblages.

6. Finally, DER function allows the user to select the four/five indices to be used in the diagram, so the algorithm of selecting the combination with the maximum dispersion among samples is not applied.


The index Fisher alpha was estimated with the function fisher.alpha, the index Rényi with the function renyi, the index Tsallis with the function tsallis, the taxonomic diversity and taxonomic distinctness with the functions taxa2dist and taxondive, all of them of the package vegan (Oksanen et al., 2016). The ellipse is depicted with the function plotellipse of the package shape (Soetaert, 2016). The convex hull (alpha=6) was calculated with the function areapl of the package splancs (Bivand et al., 2016). The color legend of DER plot was depicted with the function color.legend of the package plotrix (Lemon et al., 2016). The rarity index of Leroy was calculated with the functions rWeights and Irr, both of the package Rarity (Leroy et al., 2012; 2103; Leroy, 2016). The functional diversity indices were calculated with the function dbFD of the package FD (Laliberté et al., 2015). The phylogenetic indices were calculated with the functions psv, psr, pse, psc, raoD, mntd, mpd and pd of the package picante (Kembel et al. 2010 2016)


The example without functional diversity is a dataset with the abundance of rotifers species in ponds (see table 1 in Mazuelos et al., 1993). In the argument Index were selected Rarity, Menhinick, McIntoshE and Dstar, which are the indices selected by the algorithm when Index=NULL (default option). The sample G3.1 had the lowest values of the indices of rarity, heterogeneity, evenness and taxonomic diversity and the pond I3.1 the highest values for all indices.


It is depicted a plot of polar coordinates estimated with the rarity, heterogeneity, evenness, taxonomic/phylogenetic and functional diversity indices, CSV files are saved with all the indices, the polar coordinates estimated with the indices specified in the argument Index or estimated by the algorithm, and the area of the convex hull and mean Euclidean distance obtained in the polar coordinates system for all combinations of the indices.


Berger, W.H., Parker, F.L. (1970) Diversity of planktonic Foramenifera in deep sea sediments. Science, 168: 1345-1347.

Bivand, R., Rowlingson, B., Diggle, P., Petris, G., Eglen, S. (2016) Spatial and Space-Time Point Pattern Analysis. R Package Version 2.01-39.

Botta-Dukát, Z. (2005) Rao's quadratic entropy as a measure of functional diversity based on multiple traits. Journal of Vegetation Science, 16: 533-540.

Brillouin, L. (1956) Science and information theory. New York: Academic Press.

Camargo, J.A. (1992) New diversity index for assessing structural alterations in aquatic communities. emphBulletin of Environmental Contamination and Toxicology, 48, 428-434.

Clarke, K.R. & Warwick, R.M. (1998). A taxonomic distinctness index and its statistical properties. Journal of Applied Ecology, 35: 523-531.

Faith, D.P. (1992) Conservation evaluation and phylogenetic diversity. Biological Conservation, 61: 1-10.

Fisher, R.A., Corbet, A.S. & Williams, C.B. (1943) The relation between the number of species and the number of individuals in a random sample of animal population. Journal of Animal Ecology, 12: 42-58.

Heip, C. 1974. A new index measuring evenness. Journal of the Marine Biological Association of the United Kingdom, 54: 555-557.

Helmus, M.R., Bland, T.J., Williams, C.J., Ives, A.R. (2007) Phylogenetic measures of biodiversity. The American Naturalist, 169: E68-E83.

Hill, M.O. (1973) Diversity and evenness: a unifying notation and its consequences. Ecology, 54: 427-432.

Hurlbert, S.H. 1971. The nonconcept of species diversity: a critique and alternative parameters. Ecology, 52: 577-586.

Kembel, S.W., Cowan, P.D., Helmus, M.R., Cornwell, W.K., Morlon, H., Ackerly, D.D., Blomberg, S.P.,Webb, C.O. (2010) Picante: R tools for integrating phylogenies and ecology. Bioinformatics, 26: 1463-1464.

Kembel, S.W., Ackerly, D.D., Blomberg, S.P., Cornwell, W.K., Cowan, P.D., Helmus, M.R., Morlon, H. & Webb, C.O. (2016) R tools for integrating phylogenies and ecology. R Package Version 1.6-2.

Laliberté, E. & Legendre, P. (2010) A distance-based framework for measuring functional diversity from multiple traits. Ecology, 91: 299-305.

Laliberté, E., Legendre, P. & Shipley, B. (2015) Measuring functional diversity (FD) from multiple traits, and other tools for functional ecology. R package version 1.0-12. Available at:

Lemon, J., Bolker, B., Oom, S., Klein, E., Rowlingson, B.,Wickham, H., Tyagi, A., Eterradossi, O., Grothendieck, G., Toews, M., Kane, J., Turner, R., Witthoft, C., Stander, J., Petzoldt, T., Duursma, R., Biancotto, E., Levy, O., Dutang, C., Solymos, P., Engelmann, R., Hecker, M., Steinbeck, F., Borchers, H., Singmann, H., Toal, T. & Ogle, D. (2016) Various plotting functions. R package version 3.6-3. Available at:

Leroy, B., Petillon, J., Gallon, R., Canard, A. & Ysnel, F. (2012) Improving occurrence-based rarity metrics in conservation studies by including multiple rarity cut-off points. Insect Conservation and Diversity, 5, 159-168.

Leroy, B., Canard, A. & Ysnel, F. (2013) Integrating multiple scales in rarity assessments of invertebrate taxa. Diversity and Distributions, 19, 794-803.

Leroy, B. (2016) Calculation of Rarity Indices for Species and Assemblages of Species. R package version 1.3-4. Available at:

Oksanen, J., Blanchet, F.G., Kindt, R., Legendre, P., Minchin, P.R., O'Hara, R.B., Simpson, G.L., Solymos, P., Henry, M., Stevens, H. & Wagner, H. (2016) Community Ecology Package. R package version 2.4-0. Available at:

Patil, G.P. & Taillie, C. (1982) Diversity as a concept and its measurement. Journal of the Acoustical Society of America, 77: 548-561.

Pielou, E.C. (1966) The measurement of diversity in different types of biological collections. Journal Theoretical Biology, 13: 131-144.

Petchey, O.L. & Gaston, K.J. (2002) Functional diversity (FD), species richness and community composition. Ecology Letters, 5: 402-411.

Margalef, R. (1958) Information theory in ecology. General Systems, 3: 36-71.

Mazuelos, N., Toja, J. & Guisande, C. (1993) Rotifers in ephemeral ponds of Doñana National Park. Hydrobiologia, 255/256: 429-434.

McIntosh, R.P. (1967) An index of diversity and the relation of certain concepts to diversity. Ecology, 48: 392-404.

Menhinick, E.P. (1964) A comparison of some species-individual diversity indices applies to samples of field insects. Ecology, 45: 859-861.

Rényi, A. (1961) On measures of information and entropy. Proceedings of the fourth Berkeley Symposium on Mathematics, Statistics and Probability Vol. 1: 547-561.

Rao, C.R. (1982) Diversity and dissimilarity coefficients: a unified approach. Theoretical Population Biology, 21: 24-43.

Shannon, C.E. (1948) A Mathematical Theory of Communication. Bell System Technical Journal, 27 (4): 379-423, 623-656.

Shannon, C.E. & Weaver, W. (1949) The Mathematical Theory of Communication. The University of Illinois Press, Illinois.

Simpson, E.H. (1949) Measurement of diversity. Nature, 163: 688.

Smith, B. & J.B. Wilson (1996) A consumer's guide to evenness indices. Oikos, 76: 70-82.

Soetaert, K. 2016. Functions for plotting graphical shapes, colors. R package version 1.4.2. Available at:

Spellerger, I.F. & Fedor P.J. (2013) A tribute to Claude Shannon (1916-2001) and a plea for more rigorous use of species richness, species diversity and the "Shannon-Wiener" Index. Global Ecology and Biogeography, 12: 177-179.

Tsallis, C. (1988) Possible generalization of Boltzmann-Gibbs statistics. Journal of Statistical Physics, 52: 479-487.

Villéger, S., Mason, N.W.H. & Mouillot, D. (2008) New multidimensional functional diversity indices for a multifaceted framework in functional ecology. Ecology 89: 2290-2301.

Webb, C.O., Ackerly, D.D. & Kembel, W. (2008) Phylocom: software for the analysis of phylogenetic community structure and trait evolution. Bioinformatics, 24: 2098-2100.

Wiener, N. (1939) The ergodic theorem. Duke Mathematical Journal, 5: 1-18.

Wiener, N. (1948) Cybernetics. Wiley, New York.

Wiener, N. (1949) The interpolation, extrapolation, and smoothing of stationary time series. Wiley, New York.


#An example without functional diversity


DER(data=Rotifers, Samples=c("J1.1","K4.1","G3.1","F2.1","K2.2","F8.2","F8.1",
"H6.2","F7.1","J6.2"), Species="Species", Taxon=c("Class","Subclass",
"Superorder","Order","Family","Genus"), pos="Pos", Index=c("Rarity","Menhinick",
"McIntoshE", "Dstar"), save=FALSE)

EcoIndR documentation built on Aug. 3, 2019, 5:02 p.m.

Related to DER in EcoIndR...