The R functions listed below are provided
without any guarantee.
Please contact me
for any bug report or suggestion.
Last 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
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
by an external code (“QHull” C library) that generates a "vert.txt"
file containing vertices names, in the current working directory.
"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.
here to download a zipfile that contains 4 folders:
=> Folder "functions"
contains 7 functions I wrote to help computing and illustrating FD
and "quality_funct_space_fromdist" for
computing the quality of several functional
spaces based on species traits values or functional
pairwise distance, respectively
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
al. 2015 Glob Ecol &
=> Folder "scripts" contains 2 R scripts:
for looking at species and/or traits values positions in
the best functional space
for computing functional diversity indices for a set of assemblages
for computing functional beta-diversity indices for a set of assemblages
for defining functional entities for a set of species described using only qualitative traits
for computing functional redundancy and functional vulneriability metrics based on
distribution of species in functional entities (as in Mouillot et al. 2014 PNAS)
- "A example FD.R" which shows the steps to follow to compute functional
- "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
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.
some old R scripts I wrote.
description of each function is provided at the top of the script with
description of inputs required and of the output format. Additionally,
a basic example is provided at the end of the script.
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
Function to compute isotopic diversity indices as in
Cucherousset & Villéger 2015 (Ecological Indicators 56: 152-160)
Function to compute change in Jaccard dissimilarity as in
Villéger & Brosse 2012 (Ecological Indicators 18: 552-558)
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)
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)
compute the trophic diversity indices presented in Villéger et al. 2008
Ecology Progress Series, 364: 135-146)
Graphical function to
plot abundance distribution among trophic level classes as in
Villéger et al. 2008 (Marine Ecology Progress Series, 364: 135-146)
compute the Functional Regularity index (FRO), proposed by Mouillot et
(Oecologia, 142: 353–359) and modified by Villéger et al. 2008 (Marine
Progress Series, 364: 135–146).