bandeau

Computing Functional Diversity Indices


The R functions listed below are provided without any guarantee.
Please
contact me for any bug report or suggestion.


La
st update on 2017-02-01: addition of:
   (i) 3 new R functions "quality_funct_space_fromdist
", "species_to_FE" and  "FE_metrics"
   (ii)
new examples of why functional dendrogram do not well represent functional distances between species         in R script "A example FD",
   (iii) a R script "B example FE" illustrating how computing FD with Functional Entities.
   (iv) a R script "C example fuzzy" illustrating how computing a functional space with fuzzy-coded traits
   (v) R function "multidimFD" now scaled raw values of FDis, FSpe and FOri indices by their respective             maximum value possible given trait values of the species pool, so that values are easier to interpret

Warning about parallelization: computation of convex hull using function "convhulln" from library "geometry" is actually led by an external code (“QHull” C library) that generates a "vert.txt" file containing vertices names, in the current working directory. "multidimFD" and "multidimFbetaD" functions read this txt file for computing FD indices.
An important consequence of this "out-of-R" computation is that parallelized computation (i.e. running several scripts simultaneously in several R Terminal with a single computer) could result in erroneous assessment of FD because one code could read the output of another one (e.g. vertices of assemblage A actually came from computation of vertices of assemblage B run by another R code).
So if you need to parallelized your computation, be sure that each R code refers to a separate folder (using “setwd(/…)”) so that a unique “vert.txt” file is used by each code.

                                           _____________________________________________________


For an overview of the workflow for assessing functional diversity in a multidimensional functional space, have a look to the poster I presented at the ICRS meeting.

Click here to download a zipfile that contains
4 folders:

=> Folder "functions" contains 7 functions I wrote to help computing and illustrating FD indices:
    - "quality_funct_space" and "quality_funct_space_fromdist" for computing the quality of several functional         spaces based on species traits values or functional pairwise distance, respectively
    - "plot_funct_space" for looking at species and/or traits values positions in the best functional space
    - "multidimFD" for computing functional diversity indices for a set of assemblages
    - "multidimFbetaD" for computing functional beta-diversity indices for a set of assemblages
     - "species_to_FE" for defining functional entities for a set of species described using only qualitative traits
  - "FE_metrics" for computing functional redundancy and functional vulneriability metrics based on distribution of species in functional entities (as in Mouillot et al. 2014 PNAS)

Please read the brief help provided at the top of the R script of each function to be sure about the type of inputs allowed and about the meaning of arguments and default settings.

These R functions provide more flexibility as well as graphical outputs than older R functions linked to some of my papers about FD (namely Villéger et al. 2010 Ecol Appli, Villéger et al. 2011 Ecol Lett, Mouillot et al. 2013 Trends in Ecol & Evol, Villéger et al. 2013 Glob Ecol & Biogeogr, Mouillot et al. 2014 PNAS, Maire et al. 2015 Glob Ecol & Biogeogr).


=> Folder "scripts" contains 2 R scripts:
    - "A example FD.R" which shows the steps to follow to compute functional diversity indices

  - "B example FE.R" which shows the steps to follow when all traits are not continuous to compute functional diversity indices based on Functional Entities.
  - "C example fuzzy.R" which shows how to compute a functional space with fuzzy-coded traits (i.e. a trait described using several continuous variables, e.g. proportion of several types of prey for animal diet).

    To run these codes you will need:
    1) an access to Internet to download the files
    2) to replace he folder path in "setwd('/Volumes/Data/...')" call according to the directory
        where you saved this folder on your computer.



=> Folder "data" contains a fake dataset (1 Excel file and copy of 2 of its sheets as .txt files) used for the example.


 => Folder "result" contains outputs from the 2 scripts listed above, including jpeg files.

_________________________________________________________________________________________________


Below are some old R scripts I wrote.

A short description of each function is provided at the top of the script with a description of inputs required and of the output format. Additionally, a basic example is provided at the end of the script.

______________________________________________

GFD_matcomm

Function to compute the FD index on the best functional dendrogram as in Mouchet et al. 2008 (Oikos 117: 794-800). This function is the same than the one here but the input is a community*species matrix of presence/absence instead of a list of occurences


si_div

Function to compute isotopic diversity indices as in Cucherousset & Villéger 2015 (Ecological Indicators 56: 152-160)


chgedissJ

Function to compute change in Jaccard dissimilarity as in Villéger & Brosse 2012 (Ecological Indicators 18: 552-558)


betaQmult

Function to compute functional beta-diversity based on decomposition of the Rao's quadratic entropy index as in Villéger et al. 2012 (PLoS ONE 7: e40679)


betaH

Function to compute taxonomic beta-diversity based on decomposition of the Shannon index (Jost 2007 Ecology 88: 2427-2439) as in Villéger et al. 2012 (PLoS ONE 7: e40679)


trophdiv

Function to compute the trophic diversity indices presented in Villéger et al. 2008 (Marine Ecology Progress Series, 364: 135-146) 

 

graphtrophdiv

Graphical function to plot abundance distribution among trophic level classes as in Villéger et al. 2008 (Marine Ecology Progress Series, 364: 135-146) 


FROm

Function to compute the Functional Regularity index (FRO), proposed by Mouillot et al. 2005 (Oecologia, 142: 353–359) and modified by Villéger et al. 2008 (Marine Ecology Progress Series, 364: 135–146).

R