Continuous Traits Framework"

About this tutorial


This tutorial explains the workflow used to compute functional space based on continuous traits and it shows how to retrieve species coordinates and species functional distances in the functional space.


DATA This tutorial uses a dataset from one of the 80 CESTES database Jeliazkov & the CESTES consortium (2019)) based on [Villeger et al. 2012] (https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0040679). This data frame contains 45 fish species from the Terminos Lagoon (Gulf of Mexico) gathered into 36 sites considered as assemblages. Each species is described with 16 continuous morphological traits.


When the dataset only gathers continuous traits, the functional space can be computed using one trait for one dimension or using Principal Component Analysis (PCA: convert correlations among samples into a 2D plot). NB Using a PCoA on continuous traits and euclidean distance is the same than using a PCA (clusters made by minimizing the linear distance (PCoA) are the same as those obtained by maximizing linear correlations (PCA)).


1. Load dataset


The species traits data frame has rows corresponding to species and columns corresponding to traits. The different traits are summed up in the following table:


| Trait name | Trait signification | |:----------:|:--------------------------------:| | logM | log(mass) | | Ogsf | Oral gape surface | | OgSh | Oral gape shape | | OgPo | Oral gape position | | GrLg | Gill raker length | | GtLg | Gut length | | EySz | Eye size | | EyPo | Eye position | | BdSh | Body transversal shape | | BdSf | Body transversal surface | | PfPo | Pectoral fin position | | PfSh | Aspect ratio of the pectoral fin | | CpHt | Caudal peduncle throttling | | CfSh | Aspect ratio of the caudal fin | | FsRt | Fins surface ratio | | FsSf | Fins surface to body size ratio |


To work with mFD with only continuous traits, you must load two objects:


# load dataset:
sp_tr <- read.csv(system.file("extdata", "data_cestes_sp_tr.csv", 
                              package = "mFD"), dec = ",", sep = ":")

rownames(sp_tr) <- sp_tr$"Sp"
sp_tr <- sp_tr[ , -1]

# display the table:
knitr::kable(head(sp_tr), 
             caption = "Species x Traits data frame based on *CESTES* dataset")


# load dataset:
asb_sp_w <- read.csv(system.file("extdata", "data_cestes_asb_sp_w.csv", 
                                 package = "mFD"), dec = ",", sep = ":")

rownames(asb_sp_w) <- paste0("site", sep = "_", asb_sp_w$Sites)
asb_sp_w <- asb_sp_w[ , -1]

asb_sp_w$Urobatis_jamaicensis <- as.numeric(asb_sp_w$Urobatis_jamaicensis)

# remove sites 12, 23, 35 because FRic can not be computed on it...
# ... (for a clean example):
asb_sp_w <- asb_sp_w[-c(11, 22, 33), ]

# display the table:
knitr::kable(asb_sp_w[1:7, 1:6], 
             caption = "Species x Assemblages data frame based on *CESTES* dataset for the first six species and first seven sites")


2. Compute the functional space


Based on the species-trait data frame or the species-standardized traits data frame, mFD allows to build a functional space based on a PCA or using each trait as a dimension. (NB Using up to the 1.0.3 version of the mFD package does not allow weighting continuous traits, it will be done in a next version of the package. You can use the col.w argument of the PCA function of the FactomineR package.). The function used to compute functional space with continuous traits is called mFD::tr.cont.fspace() and is used as follow:


USAGE

mFD::tr.cont.fspace(
  sp_tr        = sp_tr, 
  pca          = TRUE, 
  nb_dim       = 7, 
  scaling      = "scale_center",
  compute_corr = "pearson")


It takes as inputs:


In this example, we will compute a PCA based on a maximum number of 7 dimensions and get Pearson's correlation coefficients:


fspace <- mFD::tr.cont.fspace(
  sp_tr        = sp_tr, 
  pca          = TRUE, 
  nb_dim       = 10, 
  scaling      = "scale_center",
  compute_corr = "pearson")


If the PCA is computed, the output contains:

NB mean absolute deviation (mad) reflects the actual magnitude of errors that affect distances, hence FD metrics ; mean squared deviation (msd) reflects the potential risk associated with a few species pairs being strongly misplaced in the functional space (Maire et al. (2015)).


fspace$"quality_metrics"


NB The lower the quality metric is, the better the quality of your space is. Here, thanks to mAD and mSD value, we can see that as the number of dimensions increases, the quality increases. However, to decrease computation time, we can chose to work with the 6D space which has good quality of functional space. Generally, you must keep in mind a trade-off between the number of axes and quality of functional space. Increasing the number of functional axes increases computation time.



fspace$"eigenvalues_percentage_var"



head(fspace$"sp_faxes_coord")



dist_mat <- as.matrix(fspace$sp_dist_multidim$"6D")
dist_mat[1:5, 1:5]



dist_mat <- as.matrix(fspace$sp_dist_init)
dist_mat[1:5, 1:5]



fspace$"tr_correl"


Here we can notice that there is no strong correlation between traits. NB However, if some strong correlation is to be found, then one of the two correlated trait can be remove from the analysis.

If the PCA is not computed, outputs are the same except that mad and msd are not computed and that only one distance object is returned.


3. Plot functional space, compute and illustrate indices


Then, based on the species coordinates matrix, steps are similar as those listed in the mFD General Workflow, from step 5 till the end.


References




Try the mFD package in your browser

Any scripts or data that you put into this service are public.

mFD documentation built on May 29, 2024, 7:25 a.m.