This tutorial explains how to compute the family of indices presented in Chao et al. (2019) using mFD.

Let’s load data and compute functional distance

The data set used to illustrate this tutorial is the fruits dataset based on 25 types of fruits (i.e. species) distributed in 10 fruits baskets (i.e. assemblages). Each fruit is characterized by six traits values summarized in the following table:

Trait name Trait measurement Trait type Number of classes Classes code Unit
Size Maximal diameter Ordinal 5 0-1 ; 1-3 ; 3-5 ; 5-10 ; 10-20 cm
Plant Growth form Categorical 4 tree; shrub; vine; forb NA
Climate Climatic niche Ordinal 3 temperate ; subtropical ; tropical NA
Seed Seed type Ordinal 3 none ; pip ; pit NA
Sugar Sugar Continuous NA NA g/kg
Use Use as food Fuzzy 3 raw ; pastry ; jam %

We load the three objects used to compute functional framework (for more explanations, see mFD General Workflow):

• a data frame summarizing traits values for each species called fruits_traits in this tutorial:
data("fruits_traits", package = "mFD")

caption = "Species x traits data frame based on the **fruits** dataset")
Species x traits data frame based on the fruits dataset
Size Plant Climate Seed Sugar Use.raw Use.pastry Use.jam
apple 5-10cm tree temperate pip 103.9 50 50 0
apricot 3-5cm tree temperate pit 92.4 40 10 50
banana 10-20cm tree tropical none 122.3 70 20 10
currant 0-1cm shrub temperate pip 73.7 10 10 80
blackberry 1-3cm shrub temperate pip 48.8 30 10 60
blueberry 0-1cm forb temperate pip 100.0 10 40 50

• a matrix summarizing species assemblages called baskets_fruits_weights in this tutorial. Weights in this matrix can be occurrence data, abundance, biomass, coverage, etc. The studied example works with biomass (i.e. grams of a fruit in a basket) and this matrix looks as follows:

caption = "Species x assemblages matrix based on the **fruits** dataset")
Species x assemblages matrix based on the fruits dataset
apple apricot banana currant blackberry blueberry
basket_1 400 0 100 0 0 0
basket_2 200 0 400 0 0 0
basket_3 200 0 500 0 0 0
basket_4 300 0 0 0 0 0
basket_5 200 0 0 0 0 0
basket_6 100 0 200 0 0 0

• a data frame summarizing traits types called fruits_traits_cat in this tutorial (for details, see mFD General Workflow):
data("fruits_traits_cat", package = "mFD")
caption = "Traits types based on **fruits & baskets** dataset")
Traits types based on fruits & baskets dataset
trait_name trait_type fuzzy_name
Size O NA
Plant N NA
Climate O NA
Seed O NA
Sugar Q NA
Use.raw F Use

Then, we can compute functional distance using the mFD::funct.dist() function as follows:

USAGE

## [1] "Running w.type=equal on groups=c(Size)"
## [1] "Running w.type=equal on groups=c(Plant)"
## [1] "Running w.type=equal on groups=c(Climate)"
## [1] "Running w.type=equal on groups=c(Seed)"
## [1] "Running w.type=equal on groups=c(Sugar)"
## [1] "Running w.type=equal on groups=c(Use,Use,Use)"

Generalisation of Hill numbers for alpha functional diversity

The family of indices presented in Chao et al. (2019) allows computing FD based on pairwise distance between species and their weights in assemblages. This generalization of Hill numbers framework is based on two parameters:

• q: the importance of species weight compared to species distance. Values allowed in mFD are 0, 1, 2 (the most often used, see below).

• tau: the threshold of functional distinctiveness between any two species (i.e. all species with distance above this threshold are considered as functionally equally distinct). Values allowed in mFD are “min(imum)”, “mean(imum)” and “max(imum)”.

Indices are expressed as effective number of functionally equally distinct species (or virtual functional groups) and could thus be directly compared to taxonomic Hill numbers (including species richness).

NOTE For more details about the properties of Hill numbers FD read Chao et al. (2019) and especially its Figures 1 & 2.

All these indices can be computed with the function mFD::alpha.fd.hill().

Here we start by comparing the ‘classical’ Rao’s quadratic entropy expressed in Hill numbers following Ricotta & Szeidl (2009) which is the special case with q = 2 and tau = "max".

USAGE

sp_dist  = fruits_gower,
tau      = "max",
q        = 2)

Then, we can compute Hill numbers FD of order 2 computed with tau = "mean" and q = 2 as recommended in Chao et al. (2019)

USAGE

sp_dist  = fruits_gower,
tau      = "mean",
q        = 2)

We can now compare these two metrics:

round(cbind(FD2max  = baskets_FD2max$"asb_FD_Hill"[ , 1], FD2mean = baskets_FD2mean$"asb_FD_Hill"[ , 1]), 2)
##           FD2max FD2mean

We can see that FD computed with tau = "max" is less variable (ranging from 1.50 to only 1.86) than FD computed with tau = "min" (ranging from 1.72 to 4.10) illustrating its higher sensitivity to functional differences between species.

NB Note that even with q = 0, weights of species are still accounted for by FD. Hence, if the goal is to compute a richness-like index (i.e. accounting only for distance between species present), function mFD::alpha.fd.hill() should be applied to species occurrence data (coded as 0/1, previously computed using sp.tr.summary) so that all species have the same weight). Species occurrence data can be retrieve through the mFD::asb.sp.summary() function:

USAGE

# Retrieve species occurrences data:
baskets_fruits_occ <- baskets_summary$"asb_sp_occ" head(baskets_fruits_occ) ## apple apricot banana currant blackberry blueberry cherry grape ## basket_1 1 0 1 0 0 0 1 0 ## basket_2 1 0 1 0 0 0 1 0 ## basket_3 1 0 1 0 0 0 1 0 ## basket_4 1 0 0 0 0 0 0 0 ## basket_5 1 0 0 0 0 0 0 0 ## basket_6 1 0 1 0 0 0 0 0 ## grapefruit kiwifruit lemon lime litchi mango melon orange ## basket_1 0 0 1 0 0 0 1 0 ## basket_2 0 0 1 0 0 0 1 0 ## basket_3 0 0 1 0 0 0 1 0 ## basket_4 0 1 1 0 0 0 0 1 ## basket_5 0 1 1 0 0 0 0 1 ## basket_6 0 0 0 1 1 1 0 1 ## passion_fruit peach pear pineapple plum raspberry strawberry tangerine ## basket_1 1 0 1 0 0 0 1 0 ## basket_2 1 0 1 0 0 0 1 0 ## basket_3 1 0 1 0 0 0 1 0 ## basket_4 0 1 1 0 1 0 0 1 ## basket_5 0 1 1 0 1 0 0 1 ## basket_6 0 0 0 1 0 0 0 0 ## water_melon ## basket_1 0 ## basket_2 0 ## basket_3 0 ## basket_4 0 ## basket_5 0 ## basket_6 1 # Compute alpha FD Hill with q = 0: baskets_FD0mean <- mFD::alpha.fd.hill( asb_sp_w = baskets_fruits_occ, sp_dist = fruits_gower, tau = "mean", q = 0) round(baskets_FD0mean$"asb_FD_Hill", 2)
##           FD_q0

Generalisation of Hill numbers for beta functional diversity

Framework of Chao et al. (2019) also allows computing beta-diversity, with 2 framework similar to Jaccard and Sorensen ones for taxonomic diversity. The mFD:beta.fd.hill() function computes these indices.

NB Note that total weight of assemblages is affecting computation of functional beta-diversity. Hence if it is does not reflect an ecological pattern (e.g. rather difference in sampling effort), it is recommended to apply mFD::beta.fd.hill() to relative weight of species in assemblages.

# retrieve total weight per basket:
baskets_summary$"asb_tot_w" ## basket_1 basket_2 basket_3 basket_4 basket_5 basket_6 basket_7 basket_8 ## 2000 2000 2000 2000 2000 2000 2000 2000 ## basket_9 basket_10 ## 2000 2000 # Here baskets all contain 2000g of fruits, we illustrate how to compute... # relative weights using the output of asb.sp.summary: baskets_fruits_relw <- baskets_fruits_weights / baskets_summary$"asb_tot_w"
##         1         1         1         1         1         1         1         1
##         1         1

Now we can compute functional beta-diversity of order q = 2 (with tau = "mean" for higher sensitivity) with Jaccard-type index:

USAGE

# Compute index:
sp_dist   = fruits_gower,
q         = 2,
tau       = "mean",
beta_type = "Jaccard")

# Then use the mFD::dist.to.df function to ease visualizing result
mFD::dist.to.df(list_dist = list("FDq2" = baskets_betaq2$"beta_fd_q"$"q2"))
## Registered S3 method overwritten by 'dendextend':
##   method     from
##   rev.hclust vegan
##          x1        x2        FDq2