| Title: | Compute and Illustrate the Multiple Facets of FunctionalDiversity |
| Version: | 1.0.7 |
| Description: | Computing functional traits-based distances between pairs of species for species gathered in assemblages allowing to build several functional spaces. The package allows to compute functional diversity indices assessing the distribution of species (and of their dominance) in a given functional space for each assemblage and the overlap between assemblages in a given functional space, see: Chao et al. (2018) <doi:10.1002/ecm.1343>, Maire et al. (2015) <doi:10.1111/geb.12299>, Mouillot et al. (2013) <doi:10.1016/j.tree.2012.10.004>, Mouillot et al. (2014) <doi:10.1073/pnas.1317625111>, Ricotta and Szeidl (2009) <doi:10.1016/j.tpb.2009.10.001>. Graphical outputs are included. Visit the 'mFD' website for more information, documentation and examples. |
| URL: | https://cmlmagneville.github.io/mFD/,https://github.com/CmlMagneville/mFD |
| BugReports: | https://github.com/CmlMagneville/mFD/issues |
| License: | GPL-2 |
| Encoding: | UTF-8 |
| LazyData: | true |
| Depends: | R (≥ 3.5) |
| Imports: | ade4, ape, betapart (≥ 1.5.4), cluster, dendextend,FactoMineR, gawdis, geometry, ggplot2, ggrepel, grid, Hmisc,patchwork, reshape2, rstatix, stats, utils, vegan |
| Suggests: | dplyr (≥ 1.0.6), knitr, magrittr, rmarkdown (≥ 2.6),stringr, tibble, tidyr |
| RoxygenNote: | 7.2.3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2024-02-26 10:43:42 UTC; au749321 |
| Author: | Camille Magneville |
| Maintainer: | Camille Magneville <camille.magneville@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2024-02-26 14:00:06 UTC |
mFD: Compute and Illustrate the Multiple Facets of Functional Diversity
Description
Computing functional traits-based distances between pairs of species for species gathered in assemblages allowing to build several functional spaces. The package allows to compute functional diversity indices assessing the distribution of species (and of their dominance) in a given functional space for each assemblage and the overlap between assemblages in a given functional space, see: Chao et al. (2018)doi:10.1002/ecm.1343, Maire et al. (2015)doi:10.1111/geb.12299, Mouillot et al. (2013)doi:10.1016/j.tree.2012.10.004, Mouillot et al. (2014)doi:10.1073/pnas.1317625111, Ricotta and Szeidl (2009)doi:10.1016/j.tpb.2009.10.001. Graphical outputs are included. Visit the 'mFD' website for more information, documentation and examples.
Author(s)
Maintainer: Camille Magnevillecamille.magneville@gmail.com (ORCID) [copyright holder]
Authors:
Nicolas Loiseaunicolas.loiseau1@gmail.com (ORCID)
Camille Albouyalbouycamille@gmail.com (ORCID)
Nicolas Casajusnicolas.casajus@fondationbiodiversite.fr (ORCID)
Thomas Claverietclaverie@gmail.com (ORCID)
Arthur Escalasarthur.escalas@gmail.com (ORCID)
Fabien Leprieurfabien.leprieur@umontpellier.fr (ORCID)
Eva Maireemg.maire@gmail.com (ORCID)
David Mouillotdavid.mouillot@umontpellier.fr (ORCID)
Sebastien Villegersebastien.villeger@cnrs.fr (ORCID)
See Also
Useful links:
Report bugs athttps://github.com/CmlMagneville/mFD/issues
Compute the set of indices based on number of species in Functional Entities
Description
This function computes the set of indices based on number of species inFunctional Entities (FEs) following Mouillotet al. (2014).
Usage
alpha.fd.fe( asb_sp_occ, sp_to_fe, ind_nm = c("fred", "fored", "fvuln"), check_input = TRUE, details_returned = TRUE)Arguments
asb_sp_occ | a matrix linking occurrences (coded as 0/1) ofspecies (columns) in a set of assemblages (rows). Warning:Anassemblage must contain at least one species. |
sp_to_fe | a list with details of species clustering into FEfrom |
ind_nm | a vector of character strings with the names offunctional diversity indices to compute among 'fred', 'fored' and 'fvuln'.Indices names must be written in lower case letters. Default: allthe indices are computed. |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
details_returned | a logical value indicating whether detailsabout indices computation should be returned. These details are requiredby |
Value
A list with:
asb_fdfe a matrix containing for each assemblage (rows),values of functional diversity indices (same names than in 'ind_nm')as well as the number of species ('nb_sp') and the number of FE(nb_fe);
ifdetails_returned is
TRUE,details_fdfe a list withasb_fe_nbsp a matrix withnumber of species per FE in each assemblage.
Author(s)
Camille Magneville
References
Mouillotet al. (2014) Functional over-redundancy and high functionalvulnerability in global fish faunas on tropical reefs.PNAS,38,13757-13762.
Examples
# Load Species*Traits dataframe:data('fruits_traits', package = 'mFD')# Load Traits categories dataframe:data('fruits_traits_cat', package = 'mFD')# Load Assemblages*Species matrix:data('baskets_fruits_weights', package = 'mFD')# Remove continuous trait:fruits_traits <- fruits_traits[, -5]fruits_traits_cat <- fruits_traits_cat[-5, ]# Compute gathering species into FEs:sp_to_fe_fruits <- mFD::sp.to.fe(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, fe_nm_type = 'fe_rank', check_input = TRUE) # Get the occurrence dataframe:asb_sp_fruits_summ <- mFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights) asb_sp_fruits_occ <- asb_sp_fruits_summ$'asb_sp_occ'# Compute alpha fd indices:alpha.fd.fe( asb_sp_occ = asb_sp_fruits_occ, sp_to_fe = sp_to_fe_fruits, ind_nm = c('fred', 'fored', 'fvuln'), check_input = TRUE, details_returned = TRUE)Illustrate Functional Diversity indices based on Functional Entities
Description
Graphical representation of distribution of species in FunctionalEntities (FE) and of indices from Mouillotet al. (2014).To plotfunctional indices, functional indices values must have been computed firstthrough the use of thealpha.fd.fe function.
Usage
alpha.fd.fe.plot( alpha_fd_fe, plot_asb_nm, plot_ind_nm = c("fred", "fored", "fvuln"), name_file = NULL, color_fill_fored = "darkolivegreen2", color_line_fred = "darkolivegreen4", color_fill_bar = "grey80", color_fill_fvuln = "lightcoral", color_arrow_fvuln = "indianred4", size_line_fred = 1.5, size_arrow_fvuln = 1, check_input = TRUE)Arguments
alpha_fd_fe | output from the function |
plot_asb_nm | a vector containing the name of the assemblage to plot. |
plot_ind_nm | a vector containing the names of the indices to plot. Itcan be |
name_file | a character string with name of file to save the figure(without extension). Default: |
color_fill_fored | a R color name or an hexadecimal code referring tothe color used to fill the part of barplots that contain species in excessin species-rich FEs. It refers to the FORed value. Default: |
color_line_fred | a R color name or an hexadecimal code referring tothe color used to draw the horizontal line referring to the FRed value.Default: |
color_fill_bar | a R color name or an hexadecimal code referring to thecolor used to draw barplots. Default: |
color_fill_fvuln | a R color name or an hexadecimal code referring tothe color used to fill barplot containing only one species forillustrating FVuln. Default: |
color_arrow_fvuln | a R color name or an hexadecimal code referring tothe color used to draw the horizontal arrow showing the proportion of FEscontaining only one species for illustrating FVuln. If there is onlyone FE containing one species, the arrow will be a point. Default: |
size_line_fred | a numeric value referring to the size of thehorizontal line illustrating FRed. Default: |
size_arrow_fvuln | a numeric value referring to the size of the arrowshowing the proportion of FEs containing only one species. Default: |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
Value
Apatchwork object with a barplot of number of species perFE. Indices names provided in 'plot_ind_nm' are illustrated. FunctionalRedundancy (average number of species per FE) is illustrated with ahorizontal line. Functional Over-redundancy (proportion of species inexcess in FE richer than average) is illustrated with top part of thesebars filled with 'color_fill_fored'. Functional Vulnerability (proportionof FE with a single species) is illustrated with bars of these vulnerableFE filled with 'color_fill_fvuln' and the double-head arrow highlightingtheir number. FE-based indices values on top of the plot. ifname_file is provided, plot saved as a 300dpi png file in theworking directory.
Author(s)
Camille Magneville and Sebastien Villeger
References
Mouillotet al. (2014) Functional over-redundancy and high functionalvulnerability in global fish faunas on tropical reefs.PNAS,111,13757-13762.
Examples
# Load Species*Traits dataframedata("fruits_traits", package = "mFD")# Load Traits categories dataframedata("fruits_traits_cat", package = "mFD")# Load Assemblages*Species matrixdata("baskets_fruits_weights", package = "mFD")# Remove continuous traitfruits_traits <- fruits_traits[ , -5]fruits_traits_cat <- fruits_traits_cat[-5, ]# Compute gathering species into FEssp_to_fe_fruits <- mFD::sp.to.fe( sp_tr = fruits_traits, tr_cat = fruits_traits_cat, fe_nm_type = "fe_rank", check_input = TRUE) # Get the occurrence matrixasb_sp_fruits_summ <- mFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights) asb_sp_fruits_occ <- asb_sp_fruits_summ$"asb_sp_occ"# Compute alpha fd indicesalpha_fd_fe_fruits <- mFD::alpha.fd.fe( asb_sp_occ = asb_sp_fruits_occ, sp_to_fe = sp_to_fe_fruits, ind_nm = c("fred", "fored", "fvuln"), check_input = TRUE, details_returned = TRUE) # Plot fd fe indicesmFD::alpha.fd.fe.plot( alpha_fd_fe = alpha_fd_fe_fruits, plot_asb_nm = c("basket_1"), plot_ind_nm = c("fred", "fored", "fvuln"), name_file = NULL, color_fill_fored = "darkolivegreen2", color_line_fred = "darkolivegreen4", color_fill_bar = "grey80", color_fill_fvuln = "lightcoral", color_arrow_fvuln = "indianred4", size_line_fred = 1.5, size_arrow_fvuln = 1, check_input = TRUE)Compute Functional alpha-Diversity indices based on Hill Numbers
Description
Compute functional alpha diversity applied to distance between speciesfollowing the framework from Chaoet al.(2019).
Usage
alpha.fd.hill( asb_sp_w, sp_dist, q = c(0, 1, 2), tau = "mean", check_input = TRUE, details_returned = TRUE)Arguments
asb_sp_w | a matrix with weight of species (columns) in a setof assemblages (rows). Rows and columns should have names. NA are notallowed. |
sp_dist | a matrix or dist object with distance betweenspecies. Species names should be provided and match those in 'asb_sp_w'.NA are not allowed. |
q | a vector containing values referring to the order ofdiversity to consider, could be 0, 1 and/or 2. |
tau | a character string with name of function to apply todistance matrix (i.e. among all pairs of species) to get the thresholdused to define 'functionally indistinct set of species'. Could be 'mean'(default), 'min' or 'max'. If tau = 'min' and there are null values in |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
details_returned | a logical value indicating whether the userwant to store values used for computing indices (see list below) |
Value
A list with:
asb_FD_Hill a matrix containing indices values for each levelof q (columns, named as 'FD_qx') for each assemblage (rows, named as inasb_sp_w)
tau_dist the threshold value applied to distance betweenspecies to compute diversity according to function provided intau
ifdetails_returned turned to TRUE a listdetailswith
asb_totw a vector with total weight of each assemblage
asb_sp_relw a matrix with relative weight of species inassemblages
Note
FD is computed applying the special case where function 'f' inequation 3c is linear:f(dij(tau)) = dij(tau)/tau, hence f(0) = 0and f(tau) = 1. FD computed with q=2 and tau = 'max' is equivalent tothe Rao's quadratic entropy from Ricotta & Szeidl (2009, J Theor Biol).FD computed with tau = 'min' is equivalent to Hill number taxonomicdiversity, thus with q=0 it is species richness (S), with q = 1 it isexponential of Shannon entropy (H) and with q = 2 it is 1/(1-D) where D isSimpson diversity. Note that even when q=0, weights of species areaccounted for in FD. Hence to compute FD based only on distance betweenspecies present in an assemblage (i.e. a richness-like index) , asb_sp_whas to contain only species presence/absence coded as 0/1 with q=0 andtau = 'mean'. If asb_sp_w contains only 0/1 and q>0, it means that allspecies have the same contribution to FD.
Author(s)
Sebastien Villeger and Camille Magneville
References
Chaoet al. (2019) An attribute diversity approach to functionaldiversity, functional beta diversity, and related (dis)similaritymeasures.Ecological Monographs,89, e01343.
Examples
# Load Species*Traits dataframe:data('fruits_traits', package = 'mFD')# Load Assemblages*Species dataframe: data('baskets_fruits_weights', package = 'mFD') # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute alpha fd hill indices:alpha.fd.hill( asb_sp_w = baskets_fruits_weights, sp_dist = sp_dist_fruits, q = c(0, 1, 2), tau = 'mean', check_input = TRUE, details_returned = TRUE)Compute a set of alpha functional indices for a set of assemblages
Description
This function computes a set of multidimensional space based indices ofalpha functional diversity. The user can choose which functional indices tocompute.
Usage
alpha.fd.multidim( sp_faxes_coord, asb_sp_w, ind_vect = c("fide", "fdis", "fmpd", "fnnd", "feve", "fric", "fdiv", "fori", "fspe"), scaling = TRUE, check_input = TRUE, details_returned = TRUE, verbose = TRUE)Arguments
sp_faxes_coord | a matrix of species coordinates in a chosenfunctional space. Species coordinates have been retrieved thanks to |
asb_sp_w | a matrix linking weight of species (columns) and aset of assemblages (rows). |
ind_vect | a vector of character string of the name offunctional indices to compute.Indices names must be written inlower case letters. Possible indices to compute are: 'fide', fdis','fmpd', 'fnnd', 'feve', 'fric', 'fdiv', 'fori' and 'fspe'. Default: allthe indices are computed. |
scaling | a logical value indicating if scaling is to be done(TRUE) or not (FALSE) on functional indices. Scaling is used to be able tocompare indices values between assemblages. Default: scaling = TRUE. |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
details_returned | a logical value indicating whether the userwant to store details. Details are used in graphical functions and thusmust be kept if the user want to have graphical outputs for the computedindices. |
verbose | a logical value indicating whether progress details should beprinted in the console. If |
Value
The following list is returned:
functional_diversity_indices matrix containing indices values(columns) for each assemblage (rows)
details list: aasb_sp_occ data.frame of speciesoccurrences in each assemblage ; aasb_sp_relatw matrix ofrelative weight of species in each assemblage ; asp_coord_all_asblist of matrices of species coordinates along functional axes for speciespresent in each assemblage ; avert_nm_all_asb list of vectors ofspecies names being vertices of the convex hull for each assemblage ; amst_all_asb list of data.frames summarizing link between speciesin the minimum spanning tree of each assemblage ; agrav_center_vert_coord_all_asb list of vectors of coordinates ofthe vertices gravity center for each assemblage ; amean_dtogravcenter_all_asb list of vectors containing meandistance to the species gravity center for each assemblage ; adist_gravcenter_global_pool vector containing the distance of eachspecies to the gravity center of all species from the global pool ; adist_nn_global_pool data.frame showing the distances of eachspecies from the global pool to its nearest neighbor ; anm_nn_all_asb data.frame containing the name of each nearestneighbor of each species present in a given assemblage ; adist_nn_all_asb data.frame containing distance of each speciespresent in a given assemblage to its nearest neighbor.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data('fruits_traits', package = 'mFD')# Load Assemblages*Species dataframe: data('baskets_fruits_weights', package = 'mFD')# Load Traits categories dataframe:data('fruits_traits_cat', package = 'mFD') # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = 'absolute', fdist_scaling = FALSE, fdendro = 'average') # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute alpha diversity indicesalpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c('PC1', 'PC2', 'PC3', 'PC4')], asb_sp_w = baskets_fruits_weights, ind_vect = c('fdis', 'fmpd', 'fnnd', 'feve', 'fric', 'fdiv', 'fori', 'fspe'), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve alpha diversity indices tablefd_ind_values_fruits <- alpha_fd_indices_fruits$functional_diversity_indicesfd_ind_values_fruitsPlot functional space and chosen functional indices
Description
Compute a graphical representation of functional indices.To plotfunctional indices, functional indices values must have been retrievethrough the use of thealpha.fd.multidimfunction.
Usage
alpha.multidim.plot( output_alpha_fd_multidim, plot_asb_nm, ind_nm = c("fide", "fric", "fdiv", "fdis", "feve", "fori", "fspe", "fnnd"), faxes = NULL, faxes_nm = NULL, range_faxes = c(NA, NA), color_bg = "grey95", shape_sp = c(pool = 3, asb1 = 21, asb2 = 21), size_sp = c(pool = 0.7, asb1 = 1, asb2 = 1), color_sp = c(pool = "grey50", asb1 = "#0072B2", asb2 = "#D55E00"), color_vert = c(pool = "grey50", asb1 = "#0072B2", asb2 = "#D55E00"), fill_sp = c(pool = NA, asb1 = "#FFFFFF30", asb2 = "#FFFFFF30"), fill_vert = c(pool = NA, asb1 = "#0072B2", asb2 = "#D55E00"), color_ch = c(pool = NA, asb1 = "#0072B2", asb2 = "#D55E00"), fill_ch = c(pool = "white", asb1 = "#0072B2", asb2 = "#D55E00"), alpha_ch = c(pool = 1, asb1 = 0.3, asb2 = 0.3), shape_centroid_fdis = c(asb1 = 22, asb2 = 22), shape_centroid_fdiv = c(asb1 = 24, asb2 = 25), shape_centroid_fspe = 23, color_centroid_fspe = "black", size_sp_nm = 3, color_sp_nm = "black", plot_sp_nm = NULL, fontface_sp_nm = "plain", save_file = FALSE, check_input = TRUE)Arguments
output_alpha_fd_multidim | a list of objects retrieved through the |
plot_asb_nm | a vector containing name(s) of assemblage(s) to plot. |
ind_nm | a vector of character string of the name of functionalindices to plot.Indices names must be written in lower caseletters. Possible indices to compute are: "fdis", "feve", "fric", "fdiv","fori" and "fspe". Default: all the indices are computed. |
faxes | a vector with names of axes to plot.You can only plotfrom 2 to 4 axes for graphical reasons: vector length should be between 2and 4. Default: faxes = NULL (the four first axes will be plotted). |
faxes_nm | a vector with axes labels if the user want different axeslabels than |
range_faxes | a vector with minimum and maximum for values for axes.Note that to have a fair representation of position of species in allplots, all axes must have the same range. Default: faxes_lim = c(NA, NA)(the range is computed according to the range of values among all axes, allaxes having the same range). |
color_bg | a R color name or an hexadecimal code used to fill plotbackground. Default: |
shape_sp | a vector gathering numeric values referring to the symbolused to draw species from the global pool and the plotted assemblage(s).It should be written as c(pool = "...", asb1 = "...", ...).(0 = high transparency, 1 = no transparency). |
size_sp | a vector gathering numeric values referring to the size ofspecies belonging to the global pool and the plotted assemblage(s).It should be written as c(pool = "...", asb1 = "...", ...). |
color_sp | a vector gathering R color names or hexadecimal codesreferring to the color of species from the global pool and studiedassemblage(s). It should be written as c(pool = "...", asb1 = "...", ...). |
color_vert | a vector gathering R color names or hexadecimal codesreferring to the color of vertices from the global pool and studiedassemblage(s). It should be written as c(pool = "...", asb1 = "...", ...). |
fill_sp | a vector gathering R color names or hexadecimal codesreferring to the filled color of species from the global pool and studiedassemblage(s). It should be written as c(pool = "...", asb1 = "...", ...). |
fill_vert | a vector gathering R color names or hexadecimal codesreferring to the filled color of vertices from the global pool and studiedassemblage(s). It should be written as c(pool = "...", asb1 = "...", ...). |
color_ch | a vector gathering R color names or hexadecimal codesreferring to the color of the convex pool of the global pool and studiedassemblage(s). It should be written as c(pool = "...", asb1 = "...", ...). |
fill_ch | a vector gathering R color names or hexadecimal codesreferring to the color to fill the convex pool of the global pool andstudied assemblage(s).It should be written as c(pool = "...", asb1 = "...", ...). |
alpha_ch | a vector gathering numeric values referring to the opacityof convex hulls of the global pool and the plotted assemblage(s).It should be written as c(pool = "...", asb1 = "...", ...).(0 = high transparency, 1 = no transparency). |
shape_centroid_fdis | a vector gathering numeric value(s) used to drawFDis centroid size. |
shape_centroid_fdiv | a vector gathering numeric value(s) used to drawFDiv centroid size. |
shape_centroid_fspe | a vector gathering numeric value used to drawFSpe centroid (i.e. center of the functional space) size. |
color_centroid_fspe | a vector gathering R color name orhexadecimal code used to draw FSpe centroid (i.e. center of thefunctional space) color. |
size_sp_nm | a numeric value referring to the size of species namesif plotted. |
color_sp_nm | a R color name or hexadecimal code referring to thecolor of names of species if plotted. |
plot_sp_nm | a vector containing species names that are to be plotted.Default: |
fontface_sp_nm | a character string for font of species labels (e.g."italic", "bold"). Default: |
save_file | a logical value telling if plots should be locallysaved or not. |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
Value
Ifname_file isNULL, it returns a list of oneggplot2 plots per functional index containing plots for combinationsof up to four axes, apatchwork figure gathering all combinations ofaxes and aggplot2 figure showing the plot caption. Ifname_file is notNULL, then those plots are saved locally.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe:data("baskets_fruits_weights", package = "mFD")# Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD")# Compute functional distancesp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average")# Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute alpha diversity indices:alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fdis", "fmpd", "fnnd", "feve", "fric", "fdiv", "fori", "fspe"), scaling = TRUE, check_input = TRUE, details_returned = TRUE)# Plot all fd alpha indices:plots_alpha <- mFD::alpha.multidim.plot(output_alpha_fd_multidim = alpha_fd_indices_fruits,plot_asb_nm = c("basket_1", "basket_5"),ind_nm = c("fdis", "fide", "fnnd", "feve", "fric", "fdiv", "fori", "fspe"),faxes = NULL,faxes_nm = NULL,range_faxes = c(NA, NA),color_bg = "grey95",shape_sp = c(pool = 3, asb1 = 21, asb2 = 21),size_sp = c(pool = 0.7, asb1 = 1, asb2 = 1),color_sp = c(pool = "grey50", asb1 = "#1F968BFF", asb2 = "#DCE319FF"),color_vert = c(pool = "grey50", asb1 = "#1F968BFF", asb2 = "#DCE319FF"),fill_sp = c(pool = NA, asb1 = "#1F968BFF", asb2 = "#DCE319FF"),fill_vert = c(pool = NA, asb1 = "#1F968BFF", asb2 = "#DCE319FF"),color_ch = c(pool = NA, asb1 = "#1F968BFF", asb2 = "#DCE319FF"),fill_ch = c(pool = "white", asb1 = "#1F968BFF", asb2 = "#DCE319FF"),alpha_ch = c(pool = 1, asb1 = 0.3, asb2 = 0.3),shape_centroid_fdis = c(asb1 = 22, asb2 = 24),shape_centroid_fdiv = c(asb1 = 22, asb2 = 24),shape_centroid_fspe = 23,color_centroid_fspe = "black",size_sp_nm = 3, color_sp_nm = "black",plot_sp_nm = NULL,fontface_sp_nm = "plain",save_file = FALSE,check_input = TRUE) # Check FRic plot:plots_alpha$fric$patchworkSummarize Assemblage x Species data frame
Description
This function computes a summary helping you to picture assemblages. Forthis function to work, there must be no NA in yourasb_sp_w data frame.
Usage
asb.sp.summary(asb_sp_w)Arguments
asb_sp_w | a matrix showing assemblages (rows) composition in species(columns). Note that species namesmust be the names of rows. |
Value
A list with:
asb_sp_w_occ | a matrix with species occurrences in eachassemblage. |
sp_tot_w | a vector gathering species biomass/abundance perspecies. |
asb_tot_w | a vector gathering total abundance/biomass perassemblage. |
asb_sp_richn | a vector gathering species richness perassemblage. |
asb_sp_nm | a list gathering the names of species of eachassemblage. |
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Assemblages x Species Matrixdata('baskets_fruits_weights', package = 'mFD')# Summarize Assemblages DatamFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights)Plot background of multidimensional plots
Description
This function creates a ggplot object with customized axes range(same for both), names and background
Usage
background.plot(range_faxes, faxes_nm, color_bg)Arguments
range_faxes | a vector with minimum and maximum values of axes. Notethat to have a fair representation of position of species in all plots,they should have the same range. Default: |
faxes_nm | a vector with axes labels for figure. |
color_bg | a R color name or an hexadecimal code used to fill plotbackground. Default: |
Value
A ggplot object plotting background of multidimensional graphs.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
background <- background.plot(range_faxes = c(-1, 2), faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") backgroundDataset: Baskets Composition in Fruits Species
Description
This dataset represents the abundance of 25 fruits species in 10 baskets.
Usage
baskets_fruits_weightsFormat
A matrix of integers with 10 rows (baskets) and 25 columns(species).
See Also
fruits_traits,fruits_traits_cat
Examples
## Not run: # Load Assemblages x Species Matrixdata("baskets_fruits_weights", package = "mFD")baskets_fruits_weights[1:5, 1:5]# Summarize Assemblages DatamFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights)## End(Not run)Compute Functional beta-Diversity indices based on Hill Numbers
Description
Compute functional beta-diversity indices based on Hill numbers applied todistance between species following the framework from Chaoet al. (2019).
Usage
beta.fd.hill( asb_sp_w, sp_dist, q = c(0, 1, 2), tau = "mean", beta_type = "Jaccard", check_input = TRUE, details_returned = TRUE)Arguments
asb_sp_w | a matrix with weight of species (columns) in a setof assemblages (rows). Rows and columns should have names. NA are notallowed. |
sp_dist | a matrix or dist object with distance betweenspecies. Species names should be provided and match those in 'asb_sp_w'.NA are not allowed. |
q | a vector containing values referring to the order ofdiversity to use |
tau | a character string with name of function to apply todistance matrix (i.e. among all pairs of species) to get the thresholdused to define 'functionally indistinct set of species'. Could be qet to'mean' (default), 'min' or 'max'. |
beta_type | a character string with name of framework used forcomputing beta-diversity, either 'Jaccard' (default) or 'Sorensen'. |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
details_returned | a logical value indicating whether the userwant to store values used for computing indices (see list below) |
Value
A list with:
asb_FDbeta a list with for each value of q adistobject with beta functional diversity indices for all pairs of assemblagesitem ifstore.details turned to TRUE a listdetails with
malpha_fd_q a list with for each value of q adistobject with mean alpha functional diversity indices for all pairs ofassemblages
gamma_fd_q a list with for each value of q adistobject with gamma functional diversity indices for all pairs of assemblages
Note
When q=1 Jaccard-like and Sorensen-like beta-diversity are identical.FD computed with tau='min' is equivalent to Hill number taxonomic betadiversity. If tau='min' and there are species with null distance, tau isset to the minimum non-null value and a warning message is displayed.Indices values are stored asdist objects to optimize memory.See below example of how merging distance values in adataframe withdist.to.df
Author(s)
Sebastien Villeger and Camille Magneville
References
Chaoet al. (2019) An attribute diversity approach to functionaldiversity, functional beta diversity, and related (dis)similaritymeasures.Ecological Monographs,89, e01343.
Examples
# Load Species*Traits dataframe:data('fruits_traits', package = 'mFD')# Load Traits types dataframe: data('fruits_traits_cat', package = 'mFD') # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute beta functional hill indices:baskets_beta <- beta.fd.hill( asb_sp_w = baskets_fruits_weights, sp_dist = sp_dist_fruits, q = c(0,1,2), tau = 'mean', beta_type = 'Jaccard', check_input = TRUE, details_returned = TRUE) # Then use the mFD::dist.to.df function to ease visualizing result:## for q = 0:mFD::dist.to.df(list_dist = list(FDq2 = baskets_beta$beta_fd_q$q0))## for q = 1:mFD::dist.to.df(list_dist = list(FDq2 = baskets_beta$beta_fd_q$q1))## for q = 2:mFD::dist.to.df(list_dist = list(FDq2 = baskets_beta$beta_fd_q$q2))Compute Functional beta-Diversity indices for pairs of assemblages in amultidimensional space
Description
Computes a set of indices of pairwise functional beta-diversity(dissimilarity and its turnover and nestedness-resultant components) basedon overlap between convex hulls in a multidimensional space. For detailsabout indices formulas see Villegeret al. (2013). This functions standsonfunctional.betapart.core.pairwise.
Usage
beta.fd.multidim( sp_faxes_coord, asb_sp_occ, check_input = TRUE, beta_family = "Jaccard", details_returned = TRUE, betapart_step = TRUE, betapart_chullopt = list(conv1 = "Qt", conv2 = "QJ"), betapart_para = FALSE, betapart_para_opt = betapart::beta.para.control())Arguments
sp_faxes_coord | a matrix with coordinates of species (rows) onfunctional axes (columns). Species coordinates have been retrieved thanksto |
asb_sp_occ | a matrix with presence/absence (coded as 0/1)of species (columns) in a set of assemblages (rows). |
check_input | a logical value defining whether inputs arechecked before computation of indices. Possible error messages will thusmay be more understandable for the user than R error messages. Default: |
beta_family | a character string for the type of beta-diversityindex to use, 'Jaccard' (default) and/or 'Sorensen'. |
details_returned | a logical value indicating whether the userwants to details_returned. Details are used in the graphical function |
betapart_step | a logical value indicating whether thecomputation progress should be displayed in the R console. Default: |
betapart_chullopt | a A list of two named vectors of character conv1and conv2 defining the options that will be used to compute the convexhulls (through the options of geometry::convhulln function). For furtherdetails see help of |
betapart_para | a logical value indicating whether internalparallelization should be used to compute pairwise dissimilarities.Default: |
betapart_para_opt | a list with details about parallelization.Default value means those parameters are set according to computerspecifications. |
Value
A list with:
pairasb_fbd_indices a list withfor eachindex adist object with values for all pairs of assemblages.Indices names start with the abbreviation of the type of dissimilarityindex ('jac' for Jaccard-like and 'sor' for Sorensen-like dissimilarity)and end with abbreviation of component ('diss': dissimilarity, 'turn' itsturnover component, and 'nest' its nestedness-resultant component).
ifstore_details is TRUE,
details_beta list:inputs a list withsp_faxes_coord andasb_sp_occon which indices were computed (required for drawing graphics),pool_vertices a list of vectors (1 per assemblage) with names ofspecies being vertices of the convex hull shaping all species;asb_FRic a vector with volume of the convex hull shaping eachassemblage (relative to volume filled by all species) ;asb_vertices a list of vectors (1 per assemblage) with names ofspecies being vertices of the convex hull
Note
All assemblages should have a number of species strictly higher thanthe number of functional axes.Computing intersection of convex hulls in space of >5 dimensions is yetimpossible with most computers.This function uses R libraries 'betapart' (> =1.5.4) for indicescomputation.Indices values are stored asdist objects to optimize memory.See below example of how merging distance values in adataframe withdist.to.df.
Author(s)
Sebastien Villeger and Camille Magneville
References
Villegeret al. (2013) Decomposing functional beta-diversity reveals thatlow functional beta-diversity is driven by low functional turnover inEuropean fish assemblages.Global Ecology and Biogeography,22,671-681.
Examples
## Not run: # Load Species*Traits dataframe:data('fruits_traits', package = 'mFD')# Load Assemblages*Species dataframe: data('baskets_fruits_weights', package = 'mFD') # Load Traits categories dataframe:data('fruits_traits_cat', package = 'mFD') # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = 'absolute', fdist_scaling = FALSE, fdendro = 'average') # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Get the occurrence dataframe:asb_sp_fruits_summ <- mFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights) asb_sp_fruits_occ <- asb_sp_fruits_summ$'asb_sp_occ'# Compute beta diversity indices:beta_fd_fruits <- mFD::beta.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c('PC1', 'PC2', 'PC3', 'PC4')], asb_sp_occ = asb_sp_fruits_occ, check_input = TRUE, beta_family = c('Jaccard'), details_returned = TRUE)# merging pairwise beta-diversity indices in a data.framedist.to.df(beta_fd_fruits$pairasb_fbd_indices)## End(Not run)Illustrate Functional beta-Diversity indices for pairs of assemblages in amultidimensional space
Description
Illustrate overlap between convex hulls shaping species assemblages in amultidimensional functional space.Before plotting beta functionaldiversity indices should have been computed using thebeta.fd.multidimfunction.
Usage
beta.multidim.plot( output_beta_fd_multidim, plot_asb_nm, beta_family, plot_sp_nm = NULL, faxes = NULL, name_file = NULL, faxes_nm = NULL, range_faxes = c(NA, NA), color_bg = "grey95", shape_sp = c(pool = 3, asb1 = 22, asb2 = 21), size_sp = c(pool = 0.7, asb1 = 1.2, asb2 = 1), color_sp = c(pool = "grey50", asb1 = "blue", asb2 = "red"), fill_sp = c(pool = NA, asb1 = "white", asb2 = "white"), fill_vert = c(pool = NA, asb1 = "blue", asb2 = "red"), color_ch = c(pool = NA, asb1 = "blue", asb2 = "red"), fill_ch = c(pool = "white", asb1 = "blue", asb2 = "red"), alpha_ch = c(pool = 1, asb1 = 0.3, asb2 = 0.3), nm_size = 3, nm_color = "black", nm_fontface = "plain", check_input = TRUE)Arguments
output_beta_fd_multidim | the list returned by |
plot_asb_nm | a vector with names of the 2 assemblages for whichfunctional beta-diversity will be illustrated. |
beta_family | a character string for the type of beta-diversity indexfor which values will be printed, |
plot_sp_nm | a vector containing species names that are to be plotted.Default: |
faxes | a vector with names of axes to plot (as columns names in |
name_file | a character string with name of file to save the figure(without extension). Default: |
faxes_nm | a vector with axes labels for figure. Default: as |
range_faxes | a vector with minimum and maximum values of axes. Notethat to have a fair representation of position of species in all plots,they should have the same range. Default: |
color_bg | a R color name or an hexadecimal code used to fillplot background. Default: |
shape_sp | a vector with 3 numeric values referring to the shape ofsymbol used for species from the 'pool' absent from the 2 assemblages, andfor species present in the 2 assemblages ('asb1', and 'asb2'),respectively. Default: |
size_sp | a numeric value referring to the size of symbols forspecies. Default: |
color_sp | a vector with 3 names or hexadecimal codes referring to thecolour of symbol for species. Default is: |
fill_sp | a vector with 3 names or hexadecimal codes referring to thecolor to fill symbol (if |
fill_vert | a vector with 3 names or hexadecimal codesreferring to the colour to fill symbol (if |
color_ch | a vector with 3 names or hexadecimal codes referring to theborder of the convex hulls of the pool of species and by the 2 assemblages.Default is: |
fill_ch | a vector with 3 names or hexadecimal codes referring to thefilling of the convex hull of the pool of species and of the 2 assemblages.Default is |
alpha_ch | a vector with 3 numeric value for transparency ofthe filling of the convex hulls (0 = high transparency, 1 = notransparency). Default is: |
nm_size | a numeric value for size of species label. Default is |
nm_color | a R color name or an hexadecimal code referring to the colorof species label. Default is |
nm_fontface | a character string for font of species labels (e.g."italic", "bold"). Default is |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
Value
Ifname_file isNULL, it returns apatchworkfigure with overlap between convex hulls projected in 2-dimensional spacesfor the given pair of assemblages. Values of functional beta-diversityindices are shown on top-right corner of the figure. Ifname_file isnotNULL, the plot is saved locally.
Author(s)
Sebastien Villeger and Camille Magneville
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD")# Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD")# Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average")# Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Get the occurrence dataframe: asb_sp_fruits_summ <- mFD::asb.sp.summary(asb_sp_w = baskets_fruits_weights) asb_sp_fruits_occ <- asb_sp_fruits_summ$"asb_sp_occ"# Compute beta diversity indices: beta_fd_fruits <- mFD::beta.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_occ = asb_sp_fruits_occ, check_input = TRUE, beta_family = c("Jaccard"), details_returned = TRUE)# Compute beta fd plots: beta.multidim.plot( output_beta_fd_multidim = beta_fd_fruits, plot_asb_nm = c("basket_1", "basket_6"), beta_family = c("Jaccard"), plot_sp_nm = c("apple", "cherry", "lemon"), faxes = paste0("PC", 1:4), name_file = NULL, faxes_nm = NULL, range_faxes = c(NA, NA), color_bg = "grey95", shape_sp = c(pool = 3, asb1 = 22, asb2 = 21), size_sp = c(pool = 0.8, asb1 = 1, asb2 = 1), color_sp = c(pool = "grey50", asb1 = "blue", asb2 = "red"), fill_sp = c(pool = NA, asb1 = "white", asb2 = "white"), fill_vert = c(pool = NA, asb1 = "blue", asb2 = "red"), color_ch = c(pool = NA, asb1 = "blue", asb2 = "red"), fill_ch = c(pool = "white", asb1 = "blue", asb2 = "red"), alpha_ch = c(pool = 1, asb1 = 0.3, asb2 = 0.3), nm_size = 3, nm_color = "black", nm_fontface = "plain", check_input = TRUE)Compute distance of a given point to its nearest neighbor in the functionalspace and the identity of the nearest neighbor
Description
This function is used in functional indices computation.
Usage
dist.nearneighb(sp_faxes_coord, ref_sp)Arguments
sp_faxes_coord | a matrix of species coordinates in a chosenfunctional space. Species coordinates have been retrieved thanks to |
ref_sp | a character string referring to the name of the referencespecies. |
Value
A list containing the nearest neighbor identitynn_id and alist of the distance of the reference point to its nearest neighbornn_ref_sp_dist.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute the distance of "pear" to its nearest neighbor(s): dist_nn_pear <- dist.nearneighb(sp_faxes_coord_fruits, ref_sp = "pear") dist_nn_pearCompute distances of all points to a given point in the functional space
Description
This function computes the distances of all species to a reference species.It is used in FSpe, FOri and FNND computation.
Usage
dist.point(sp_faxes_coord, ref_sp)Arguments
sp_faxes_coord | a matrix of species coordinates in a chosen functionalspace. Species coordinates have been retrieved thanks to |
ref_sp | a character string referring to the name of the referencespecies. |
Value
A vector of species distances to the reference species.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Retrieve the distances of all species to "pear": dist_pear <- dist.point(sp_faxes_coord_fruits, ref_sp = "pear") dist_pearMerge distance object(s) into a single data frame
Description
This function merges distance object(s) into a single data frame which rowsare pairs of elements and column(s) distance metric(s). It stands on thedist_long function.
Usage
dist.to.df(list_dist)Arguments
list_dist | a list of dist object(s). All dist objects should have aname (e.g. name of distance metric) and the same labels (i.e. names ofsets between which distance was computed). |
Value
A data frame which first and second columns (namesx1 andx2)contain names of the 2 sets involved in each pair, and with one column foreach dist object (named after its name inlist_dist.
Author(s)
Sebastien Villeger
Examples
# Create dist objects: dist_A <- round(dist(matrix(runif(10, 0, 1), 5, 2, dimnames = list(letters[1:5], NULL))), 2)dist_B <- round(dist(matrix(runif(10, 0, 1), 5, 2, dimnames = list(letters[1:5], NULL))), 2)dist_C <- round(dist(matrix(runif(10, 0, 1), 5, 2, dimnames = list(letters[1:5], NULL))), 2)# First example with only 1 distance:dist.to.df(list(dA = dist_A))# Second example with 3 distances:dist.to.df(list(d1 = dist_A, d2 = dist_B, d3 = dist_C))Plot FDis index
Description
This function plots FDis index for a given pair of functional axes and forone or several assemblages. It adds segments between species relativeweights and assemblage cenntroid on the background plot.
Usage
fdis.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_fide_coord2D, plot_sp = TRUE, shape_sp, color_sp, fill_sp, shape_fide, size_fide, color_fide, fill_fide, color_segment, width_segment, linetype_segment)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_fide_coord2D | a list (with names as in |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
shape_fide | a numeric value referring to the shape of the symbol usedfor fide centroid if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
size_fide | a numeric value referring to the size of the symbol used forfide centroid plotting if one assemblage to plot or a vector numeric valuesif several assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRsize", asb2 = "secondRsize",...). |
color_fide | a R color name or an hexadecimal code referring to thecolorof fide centroid if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_fide | a R color name or an hexadecimal code referring to the colorto fill assemblage centroid symbol (if |
color_segment | a R color name or an hexadecimal code referring to thecolor of of the segment linking axes and centroid from the studiedassemblage if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
width_segment | a numeric value referring to the width of the segmentlinking fide centroid and functional axes if one assemblage to plot or avector numeric values if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRsize", asb2 = "secondRsize", ...). |
linetype_segment | a numeric value referring to the linetype of thesegment linking fide centroid and functional axes if one assemblage to plotor a vector numeric values if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRlinetype", asb2 = "secondRlinetype", ...). |
Value
A ggplot object showing FDis index for one or several assemblage(s)and a given pair of functional axes.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fdis"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve fide values through alpha.fd.multidim outputs: fruits_asb_fide_coord2D <- alpha_fd_indices_fruits$functional_diversity_indices[c("fide_PC1", "fide_PC2")] fruits_asb_fide_coord2D_b1 <- fruits_asb_fide_coord2D[c("basket_1"), ] fruits_asb_sp_relatw_b1 <- alpha_fd_indices_fruits$details$asb_sp_relatw["basket_1", ] # Retrieve FDis plot: fdis_plot <- fdis.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_fide_coord2D = list(basket_1 = fruits_asb_fide_coord2D_b1), plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", shape_fide = list(basket_1 = 18), size_fide = list(basket_1 = 5), color_fide = list(basket_1 = "blue"), fill_fide = list(basket_1 = "blue"), color_segment = list(basket_1 = "red"), width_segment = list(basket_1 = 1), linetype_segment = list(basket_1 = "dashed")) fdis_plotPlot FDiv indice
Description
This plot fDiv indice for a given pair of functional axes and one or severalassemblages. This function adds mean distance to center of gravity ofvertices, points and vertices of 1:N assemblages on the background plot
Usage
fdiv.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_vertices_nD, asb_vertG_coord2D, plot_sp = TRUE, shape_sp, color_sp, fill_sp, shape_vert, color_vert, fill_vert, shape_vertG, size_vertG, color_vertG, fill_vertG)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_vertices_nD | a list (with names as in asb_sp_coord2D) of vectorswith names of species being vertices in n dimensions. |
asb_vertG_coord2D | a list (with names as in asb_sp_coord2D) containingfor each assemblage the coordinates of center of gravity of vertices for agiven pair of axes |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
shape_vert | a numeric value referring to the shape of the symbol usedfor vertices plotting if one assemblage to plot or a vector numeric valuesif several assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_vert | a R color name or an hexadecimal code referring to thecolor of vertices if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). If color_vert = NA,vertices are not plotted (for shapes only defined by color, ie shapeinferior to 20. Otherwise |
fill_vert | a R color name or an hexadecimal code referring to the colorof vertices symbol filling (if |
shape_vertG | a numeric value referring to the shape to use to plot thecenter of gravity of vertices if one assemblage to plot or a vector numericvalues if several assemblages to plot. If more than one assemblage to plot,the vector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
size_vertG | a numeric value referring to the size of the symbol usedfor the center of gravity of vertices if one assemblage to plot or a vectornumeric values if several assemblages to plot. If more than one assemblageto plot, the vector should be formatted as: c(asb1 = "firstRsize", asb2 ="secondRsize", ...). |
color_vertG | a R color name or an hexadecimal code referring to thecolor of the center of gravity of vertices. if one assemblage to plot or avector of R color names or hexadecimal codes if several assemblages toplot. If more than one assemblage to plot, the vector should be formattedas: c(asb1 = "firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_vertG | a R color name or an hexadecimal code referring to thecolor to fill the center of gravity of vertices (if |
Value
A ggplot object plotting background of multidimensional graphs andFDiv indice.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FDiv: alpha_fd_ind <- mFD::alpha.fd.multidim(sp_faxes_coord = sp_faxes_coord_fruits[ , c("PC1", "PC2", "PC3", "PC4")],asb_sp_w = baskets_fruits_weights,ind_vect = c("fdiv"),scaling = TRUE,check_input = TRUE,details_returned = TRUE) # Retrieve inputs of the fdiv.plot() function for "basket_1" and PC1, PC2 # ... through alpha.fd.multidim outputs: fruits_asb_sp_relatw_b1 <- alpha_fd_ind$details$asb_sp_relatw["basket_1", ] fruits_asb_vertices_nD_b1_2D <- alpha_fd_ind$details$asb_vert_nm["basket_1"] fruits_asb_vertG_coord_b1 <- alpha_fd_ind$details$asb_G_coord["basket_1"] fruits_asb_vertG_coord_b1_2D <- fruits_asb_vertG_coord_b1[[1]][c("PC1", "PC2")] # Retrieve FDiv plot: fdiv_plot <- fdiv.plot( ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_vertices_nD = fruits_asb_vertices_nD_b1_2D, asb_vertG_coord2D = list(basket_1 = fruits_asb_vertG_coord_b1_2D), plot_sp = TRUE, shape_sp = 16, color_sp = c(basket_1 = "red"), fill_sp = "red", color_vert = "red", fill_vert = "red", shape_vert = 16, shape_vertG = list(basket_1 = 18), size_vertG = list(basket_1 = 2), color_vertG = list(basket_1 = "blue"), fill_vertG = list(basket_1 = "blue")) fdiv_plotPlot FEve index
Description
This function plots FEve index for a given pair of functional axes and oneor several assemblages. It adds Minimum Spanning Tree (MST) of a givenassemblage on the background plot.
Usage
feve.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_mst, plot_sp = TRUE, shape_sp, color_sp, fill_sp, color_mst, width_mst, linetype_mst)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_mst | a list (with names as in |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
color_mst | a R color name or an hexadecimal code referring to the colorthe MST if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
width_mst | a numeric value referring to the width of segments of theMST if one assemblage to plot or a vector numeric values if severalassemblages to plot. If more than one assemblage to plot, the vector shouldbe formatted as: c(asb1 = "firstRsize", asb2 = "secondRsize", ...). |
linetype_mst | a numeric value referring to the linetype of the segmentsrepresenting the MST if one assemblage to plot or a vector numeric valuesif several assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRlinetype", asb2 ="secondRlinetype", ...). |
Value
A ggplot object showing FEve index on the background plot.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("feve"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve fide values through alpha.fd.multidim outputs: fruits_asb_mst_b1 <- alpha_fd_indices_fruits$details$asb_mst["basket_1"] fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] fruits_asb_sp_relatw_b1 <- alpha_fd_indices_fruits$details$asb_sp_relatw["basket_1", ] # Retrieve FEve plot: feve_plot <- feve.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_mst = fruits_asb_mst_b1, plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", color_mst = list(basket_1 = "blue"), width_mst = list(basket_1 = 1), linetype_mst = list(basket_1 = "solid")) feve_plotPlot FIde index
Description
Plot FIde index given a pair of functional axes for one or severalassemblages. It adds the centroid of species for each assemblage andsegments showing centroid coordinates on functional axes on the backgroundplot.
Usage
fide.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_fide_coord2D, plot_sp = TRUE, shape_sp, color_sp, fill_sp, shape_fide, size_fide, color_fide, fill_fide, color_segment, width_segment, linetype_segment)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_fide_coord2D | a list (with names as in asb_sp_coord2D) ofvectors with coordinates of the centroid of species for each assemblagefor a given pair of axes. |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
shape_fide | a numeric value referring to the shape of the symbol usedfor fide centroid plotting if one assemblage to plot or a vector numericvalues if several assemblages to plot. If more than one assemblage to plot,the vector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
size_fide | a numeric value referring to the size of the symbol used forfide centroid plotting if one assemblage to plot or a vector numeric valuesif several assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRsize", asb2 = "secondRsize",...). |
color_fide | a R color name or an hexadecimal code referring to thecolor of species centroid for agiven assemblage if one assemblage to plotor a vector of R color names or hexadecimal codes if several assemblages toplot. If more than one assemblage to plot, the vector should be formattedas: c(asb1 = "firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_fide | a R color name or an hexadecimal code referring to the colorto fill assemblage centroid symbol (if |
color_segment | a R color name or an hexadecimal code referring to thecolor of of the segment linking axes and centroid from the studiedassemblage if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
width_segment | a numeric value referring to the width of the segmentlinking fide centroid and functional axes if one assemblage to plot or avector numeric values if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRsize", asb2 = "secondRsize", ...). |
linetype_segment | a numeric value referring to the linetype of thesegment linking fide centroid and functional axes if one assemblage to plotor a vector numeric values if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRlinetype", asb2 = "secondRlinetype", ...). |
Value
A ggplot object with FIde index, species and background.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fide"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve fide values through alpha.fd.multidim outputs: fruits_asb_fide_coord2D <- alpha_fd_indices_fruits$functional_diversity_indices[c("fide_PC1", "fide_PC2")] fruits_asb_fide_coord2D_b1 <- fruits_asb_fide_coord2D[c("basket_1"), ] fruits_asb_sp_relatw_b1 <- alpha_fd_indices_fruits$details$asb_sp_relatw["basket_1", ] # Retrieve FIde plot: fide_plot <- fide.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_fide_coord2D = list(basket_1 = fruits_asb_fide_coord2D_b1), plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", shape_fide = list(basket_1 = 18), size_fide = list(basket_1 = 5), color_fide = list(basket_1 = "blue"), fill_fide = list(basket_1 = "blue"), color_segment = list(basket_1 = "red"), width_segment = list(basket_1 = 1), linetype_segment = list(basket_1 = "dashed")) fide_plotPlot FNND index
Description
This function plots FNND index for a given pair of functional axes and forone or several assemblages
Usage
fnnd.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_nn_asb, plot_sp = TRUE, shape_sp, color_sp, fill_sp, color_segment, width_segment, linetype_segment)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_nn_asb | a list gathering for each species of a studied assemblageits nearest neighbour(s) in the assemblage. |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_sp | a numeric value referring to the shape used to plot speciesbelonging to the studied assemblage. |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
color_segment | a R color name or an hexadecimal code referring to thecolor of of the segment linking nearest neighbors in a given assemblage ora vector of R color names or hexadecimal codes if several assemblages toplot. If more than one assemblage to plot, the vector should be formattedas: c(asb1 = "firstRcolorname", asb2 = "secondRcolorname", ...). |
width_segment | a numeric value referring to the size of the segmentlinking nearest neighbors in a given assemblage or a vector of numericvalues if several assemblages to plot. If more than one assemblage to plot,the vector should be formatted as: c(asb1 = "firstRwidth", asb2 ="secondRwidth", ...). |
linetype_segment | a character string referring to the linetype used tolink nearest neighbors in the studied assemblages or a vector of characterstrings if several assemblages to plot. If more than one assemblage toplot, the vector should be formatted as: c(asb1 = "firstRlinetype", asb2 ="secondRlinetype", ...). |
Value
A ggplot object with FNND index.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fnnd"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve nearest neighbor(s) names and relative weights ... # ... through alpha.fd.multidim outputs: fruits_asb_nn_asb_b1 <- alpha_fd_indices_fruits$details$asb_nm_nn_asb["basket_1"] fruits_asb_sp_relatw_b1 <- alpha_fd_indices_fruits$details$asb_sp_relatw["basket_1", ] # Retrieve FNND plot: fnnd_plot <- fnnd.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_nn_asb = fruits_asb_nn_asb_b1 , plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", color_segment = list(basket_1 = "blue"), width_segment = list(basket_1 = 1), linetype_segment = list(basket_1 = "solid")) fnnd_plotPlot FOri
Description
This function plots FOri index for a given pair of functional axes and forone or several assemblages. It adds the distance of species from the studiedto their nearest neighbour(s) from the global pool.
Usage
fori.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, asb_nn_pool, pool_coord2D, plot_pool = TRUE, plot_sp = TRUE, shape_pool, size_pool, color_pool, fill_pool, shape_sp, color_sp, fill_sp, color_segment, width_segment, linetype_segment)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
asb_nn_pool | a list gathering for each species of a studied assemblageits nearest neighbour(s) in the global pool. |
pool_coord2D | a matrix (ncol = 2) with coordinates ofspecies present in the global pool for a given pair of functional axes. |
plot_pool | a logical value indicating whether species of eachassemblage should be plotted or not. Default: |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_pool | a numeric value referring to the shape used to plot speciespool. |
size_pool | a numeric value referring to the size of species belongingto the global pool. |
color_pool | a R color name or an hexadecimal code referring to thecolor of the pool. This color is also used for FRic convex hull color. |
fill_pool | a R color name or an hexadecimal code referring to thecolour to fill species symbol (if |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
color_segment | color_segment a R color name or an hexadecimal codereferring to the color of of the segment linking nearest neighbors in theglobal pool or a vector of R color names or hexadecimal codes if severalassemblages to plot. If more than one assemblage to plot, the vector shouldbe formatted as: c(asb1 = "firstRcolorname", asb2 = "secondRcolorname",...). |
width_segment | a numeric value referring to the size of the segmentlinking nearest neighbors in the global pool or a vector of numericvalues if several assemblages to plot. If more than one assemblage to plot,the vector should be formatted as: c(asb1 = "firstRwidth", asb2 ="secondRwidth", ...). |
linetype_segment | a character string referring to the linetype used tolink nearest neighbors in the global pool or a vector of characterstrings if several assemblages to plot. If more than one assemblage toplot, the vector should be formatted as: c(asb1 = "firstRlinetype", asb2 ="secondRlinetype", ...). |
Value
A ggplot object with FOri index.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
## Not run: # Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fori"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve nearest neighbor(s) names through alpha.fd.multidim outputs: fruits_asb_nn_pool_b1 <- alpha_fd_indices_fruits$details$asb_nm_nn_pool["basket_1"] # Retrieve FNND plot: fori_plot <- fori.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), asb_nn_pool = fruits_asb_nn_pool_b1, pool_coord2D = sp_faxes_coord_fruits[, c("PC1", "PC2")], plot_pool = TRUE, plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", shape_pool = 4, size_pool = 2, color_pool = "grey", fill_pool = "grey", color_segment = list(basket_1 = "red"), width_segment = list(basket_1 = 1), linetype_segment = list(basket_1 = "solid")) fori_plot## End(Not run)Plot FRic index
Description
This function plots FRic index for a given pair of functional axes and oneor several assemblages. It adds convex hull(s), points and vertices of1:N assemblages on the background plot
Usage
fric.plot( ggplot_bg, asb_sp_coord2D, asb_vertices_nD, plot_sp = TRUE, color_ch, fill_ch, alpha_ch, shape_sp, size_sp, color_sp, fill_sp, shape_vert, size_vert, color_vert, fill_vert)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of axes for a given pairof functional axes. |
asb_vertices_nD | a list (with names as in asb_sp_coord2D) of vectorswith names of species being vertices in n dimensions. |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: plot_sp = TRUE. |
color_ch | a R color name or an hexadecimal code referring to the colorof the border of the convex hull filled by the pool of species if oneassemblage to plot or a vector of R color names or hexadecimal codes ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRcolorname", asb2 ="secondRcolorname", ...). |
fill_ch | a R color name or an hexadecimal code referring to the colorof convex hull filling if one assemblage to plot or a vector of R colornames or hexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
alpha_ch | a numeric value referring to the value of transparency ofthe convex hull filling (0 = high transparency, 1 = notransparency) if one assemblage toplot or a vector numeric values if several assemblages to plot. If morethan one assemblage to plot, the vector should be formatted as: c(asb1 ="firstRtransparency", asb2 = "secondRtransparency", ...). |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
size_sp | a numeric value referring to the size of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRsize", asb2 ="secondRsize", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
shape_vert | a numeric value referring to the shape of the symbol usedfor vertices plotting if one assemblage to plot or a vector numeric valuesif several assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
size_vert | a numeric value referring to the size of the symbol used forvertices plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRsize", asb2 ="secondRsize", ...). |
color_vert | a R color name or an hexadecimal code referring to thecolor of vertices if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). If color_vert = NA,vertices are not plotted (for shapes only defined by color, ie shapeinferior to 20. Otherwise |
fill_vert | a R color name or an hexadecimal code referring to the colorof vertices symbol filling (if |
Value
A ggplot object plotting background of multidimensional graphs andFRic convex hulls.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord # Retrieve species coordinates matrix for the assemblage "basket_1": sp_filter <- mFD::sp.filter(asb_nm = c("basket_1"), sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) sp_faxes_coord_fruits_b1 <- sp_filter$`species coordinates` # Reduce it to the two studid axes: PC1 and PC2: sp_faxes_coord_fruits_b1_2D <- sp_faxes_coord_fruits_b1[, c("PC1", "PC2")]# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve vertices names: vert_nm_fruits <- vertices(sp_faxes_coord_fruits_b1_2D, order_2D = TRUE, check_input = TRUE) # Plot in white the convex hull of all fruits species: ggplot_fric <- mFD::fric.plot( ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = sp_faxes_coord_fruits_b1_2D), asb_vertices_nD = list(basket_1 = vert_nm_fruits), plot_sp = TRUE, color_ch = c("basket_1" = "black"), fill_ch = c("basket_1" = "white"), alpha_ch = c("basket_1" = 0.3), size_sp = c("basket_1" = 1), shape_sp = c("basket_1" = 16), color_sp = c("basket_1" = "red"), fill_sp = c("basket_1" = "red"), size_vert = c("basket_1" = 1), color_vert = c("basket_1" = "red"), fill_vert = c("basket_1" = "red"), shape_vert = c("basket_1" = 16)) ggplot_fricDataset: Traits Values of Fruits Species
Description
This dataset represents the value of 6 traits for 15 fruits species.Important: Species names must be specified as the data frame row names(not in an additional column).
Usage
fruits_traitsFormat
A data frame with 25 rows (species) and the following columns(traits):
- Size
an ordered factor describing the size of fruits species
- Plant
an unordered factor describing the type of plant
- Climate
an ordered factor describing the climate regions
- Seed
an ordered factor describing the type of seed
- Sugar
a numeric describing the quantity of sugar
- Use.raw
an integer (percentage) describing the proportion of a rawuse (fuzzy trait) of the fruit
- Use.pastry
an integer (percentage) describing the proportion of apastry use (fuzzy trait) of the fruit
- Use.jam
an integer (percentage) describing the proportion of ajam use (fuzzy trait) of the fruit
See Also
fruits_traits_cat,baskets_fruits_weights
Examples
## Not run: # Load Species x Traits Data Framedata("fruits_traits", package = "mFD")fruits_traits# Load Traits Informationdata("fruits_traits_cat", package = "mFD")fruits_traits_cat# Summarize Species x Traits DatamFD::sp.tr.summary(tr_cat = fruits_traits_cat, sp_tr = fruits_traits)## End(Not run)Dataset: Fruits Traits Informations
Description
This dataset summarizes information about the 6 traits used in thefruits_traits dataset.
Usage
fruits_traits_catFormat
A data frame with 8 rows (traits) and the following three columns:
- trait_name
a character giving the trait name
- trait_type
a character giving the trait type (O for Ordinaltrait,N for Nominal trait,Q for Quantitative trait, andFfor Fuzzy-coded trait)
- fuzzy_name
a character giving the name of fuzzy-coded traits(i.e.
Use) to which 'sub-traits' (i.e.raw,pastry, andjam)belongs
Note
If your dataset does not contain fuzzy trait, the columnfuzzy_namecan be ignored but the first two columns are mandatory.
Traits in this dataset correspond to columns (traits) of thefruits_traitsdataset.
See Also
fruits_traits,baskets_fruits_weights
Examples
## Not run: # Load Traits Informationdata("fruits_traits_cat", package = "mFD")fruits_traits_cat# Load Species x Traits Data Framedata("fruits_traits", package = "mFD")# Summarize Species x Traits DatamFD::sp.tr.summary(tr_cat = fruits_traits_cat, sp_tr = fruits_traits)## End(Not run)Plot FSpe
Description
This function plots FSpe index for a given pair of functional axes and forone or several assemblages. It adds the mean position of species from theglobal pool and the distance of each species from the studied assemblage(s)on the background plot
Usage
fspe.plot( ggplot_bg, asb_sp_coord2D, asb_sp_relatw, center_coord2D, pool_coord2D, plot_pool = TRUE, plot_sp = TRUE, shape_pool, size_pool, color_pool, fill_pool, shape_sp, color_sp, fill_sp, color_center, fill_center, shape_center, size_center, color_segment, width_segment, linetype_segment)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
asb_sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in each assemblage for a given pair of functional axes. |
asb_sp_relatw | a list of vector gathering species relative weight ineach assemblage. It can be retrieved through the |
center_coord2D | a list containing the coordinates of the center of theglobal pool for two given functional axes |
pool_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in the global pool for a given pair of functional axes. |
plot_pool | a logical value indicating whether species of eachassemblage should be plotted or not. Default: |
plot_sp | a logical value indicating whether species of each assemblageshould be plotted or not. Default: |
shape_pool | a numeric value referring to the shape used to plotspecies pool. |
size_pool | a numeric value referring to the size of species belongingto the global pool. |
color_pool | a R color name or an hexadecimal code referring to thecolor of the pool. This color is also used for FRic convex hull color.Default: |
fill_pool | a R color name or an hexadecimal code referring to thecolour to fill species symbol (if |
shape_sp | a numeric value referring to the shape of the symbol used forspecies plotting if one assemblage to plot or a vector numeric values ifseveral assemblages to plot. If more than one assemblage to plot, thevector should be formatted as: c(asb1 = "firstRshape", asb2 ="secondRshape", ...). |
color_sp | a R color name or an hexadecimal code referring to the colorof species if one assemblage to plot or a vector of R color names orhexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
fill_sp | a R color name or an hexadecimal code referring to the colorof species symbol filling (if |
color_center | a R color name or an hexadecimal code referring to thecolor of the center of the global pool. |
fill_center | a R color name or an hexadecimal code referring to thecolour to fill the center of the global pool (if |
shape_center | a numeric value referring to the shape used to plot thecenter of the global pool. |
size_center | a numeric value referring to the size of the center ofthe global pool. |
color_segment | a R color name or an hexadecimal code referring to thecolor of the segments linking each species of a given assemblage to thecenter of functional space if one assemblage to plot or a vector of R colornames or hexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRcolorname", asb2 = "secondRcolorname", ...). |
width_segment | a numeric value referring to thewidth of the segments linking each species of a given assemblage to thecenter of functional space if one assemblage to plot or a vector of R colornames or hexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRwidth", asb2 = "secondRwidth", ...). |
linetype_segment | a character string referring to thelinetype of the segment linking each species of a given assemblage to thecenter of functional space if one assemblage to plot or a vector of R colornames or hexadecimal codes if several assemblages to plot. If more than oneassemblage to plot, the vector should be formatted as: c(asb1 ="firstRlinetype", asb2 = "secondRlinetype", ...). |
Value
A ggplot object with FSpe index on the background plot.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
## Not run: # Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve the matrix of species coordinates for "basket_1" and PC1 and PC2 sp_filter <- mFD::sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) fruits_asb_sp_coord_b1 <- sp_filter$`species coordinates` fruits_asb_sp_coord2D_b1 <- fruits_asb_sp_coord_b1[, c("PC1", "PC2")] # Use alpha.fd.multidim() function to get inputs to plot FIde: alpha_fd_indices_fruits <- mFD::alpha.fd.multidim( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], asb_sp_w = baskets_fruits_weights, ind_vect = c("fspe"), scaling = TRUE, check_input = TRUE, details_returned = TRUE) # Retrieve nearest neighbor(s) names through alpha.fd.multidim outputs: fruits_center_coord2D <- alpha_fd_indices_fruits$details$pool_O_coord[c("PC1", "PC2")] # Retrieve FNND plot: fspe_plot <- fspe.plot(ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = fruits_asb_sp_coord2D_b1), asb_sp_relatw = list(basket_1 = fruits_asb_sp_relatw_b1), center_coord2D = fruits_center_coord2D, pool_coord2D = sp_faxes_coord_fruits[, c("PC1", "PC2")], plot_pool = TRUE, plot_sp = TRUE, shape_sp = 16, color_sp = "red", fill_sp = "red", shape_pool = 4, size_pool = 2, color_pool = "grey", fill_pool = "grey", color_center = "blue", fill_center = "blue", shape_center = 18, size_center = 3, color_segment = list(basket_1 = "red"), width_segment = list(basket_1 = 1), linetype_segment = list(basket_1 = "solid")) fspe_plot## End(Not run)Compute functional distance between species
Description
For a given combination of traits, this function returns the functionaldistance matrix between species.
Usage
funct.dist( sp_tr, tr_cat, metric, scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)Arguments
sp_tr | a data frame of traits values (columns) for each species(rows). |
tr_cat | a data frame containing three columns for each trait (rows):
|
metric | the distance to be computed: |
scale_euclid | only when computing euclidean distance a string value tocompute (or not) scaling of quantitative traits using the |
ordinal_var | a character string specifying the method to be used forordinal variables (i.e. ordered). |
weight_type | the type of used method to weight traits. |
stop_if_NA | a logical value to stop or not the process if the |
Value
adist object containing distance between each pair of species.
Note
If thesp_tr data frame containsNA you can eitherchose to compute anyway functional distances (but keep in mind thatFunctional measures are sensitive to missing traits!) or you candelete species with missing or extrapolate missing traits (seeJohnsonet al. (2020)).
Author(s)
Nicolas Loiseau and Sebastien Villeger
References
de Belloet al. (2021) Towards a more balanced combination of multipletraits when computing functional differences between species.Method in Ecology and Evolution,12, 443-448.
Gower (1971 ) A general coefficient of similarity and some of itsproperties.Biometrics,27, 857-871.
Johnsonet al. (2020) Handling missing values in trait data.Global Ecology and Biogeography,30, 51-62.
Podani (1999) Extending Gower's general coefficient of similarity to ordinalcharacters,Taxon,48, 331-340.
Examples
# Load Species x Traits datadata("fruits_traits", package = "mFD")# Load Traits x Categories datadata("fruits_traits_cat", package = "mFD")# Remove fuzzy traits for this example and thus remove lat column:fruits_traits <- fruits_traits[ , -c(6:8)]fruits_traits_cat <- fruits_traits_cat[-c(6:8), ]fruits_traits_cat <- fruits_traits_cat[ , -3]# Compute Functional Distancesp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)sp_dist_fruitsPlot species position in a functional space
Description
This function illustrates the position of species along pairs of axes of afunctional space
Usage
funct.space.plot( sp_faxes_coord, faxes = NULL, name_file = NULL, faxes_nm = NULL, range_faxes = c(NA, NA), color_bg = "grey95", color_pool = "darkturquoise", fill_pool = "white", shape_pool = 21, size_pool = 1, plot_ch = TRUE, color_ch = "darkblue", fill_ch = "white", alpha_ch = 1, plot_vertices = TRUE, color_vert = "darkturquoise", fill_vert = "darkturquoise", shape_vert = 22, size_vert = 1, plot_sp_nm = NULL, nm_size = 3, nm_color = "black", nm_fontface = "plain", check_input = TRUE)Arguments
sp_faxes_coord | a matrix of species coordinates in amultidimensional functional space. Species coordinates have been retrievedthanks to |
faxes | a vector with names of axes to plot (as columns names in |
name_file | a character string with name of file to save thefigure (without extension). Default: |
faxes_nm | a vector with axes labels for figure. Default: as |
range_faxes | a vector with minimum and maximum values of axesused for all plots to have a fair representation of position of species.Default: |
color_bg | a R color name or an hexadecimal code used to fill plotbackground. Default: |
color_pool | a R color name or an hexadecimal code referring to thecolor of symbol for species. Default: |
fill_pool | a R color name or an hexadecimal code referring to thecolor to fill species symbol (if |
shape_pool | a numeric value referring to the shape of symbol used forspecies. Default: |
size_pool | a numeric value referring to the size of symbol forspecies. Default: |
plot_ch | a logical value indicating whether the convex hull shapingthe pool of species should be illustrated. If |
color_ch | a R color name or an hexadecimal code referring to theborder of the convex hull filled by the pool of species. Default: |
fill_ch | a R color name or an hexadecimal code referring to thefilling of the convex hull filled by the pool of species. Default: |
alpha_ch | a numeric value for transparency of the filling of theconvex hull (0 = high transparency, 1 = no transparency). Default: |
plot_vertices | a logical value defining whether vertices of the convexhull shaping the pool of species should be illustrated. If |
color_vert | a character value referring to the color of symbol forvertices if |
fill_vert | a character value referring to the color for filling symbolfor vertices (if |
shape_vert | a numeric value referring to the symbol used to showvertices position if |
size_vert | a numeric value referring to the size of symbol forvertices Default: |
plot_sp_nm | a vector containing species names that are to be printednear their position. Default: |
nm_size | a numeric value for size of species label. Default is |
nm_color | a R color name or an hexadecimal code referring to the colorof species label. Default: |
nm_fontface | a character string for font of species labels (e.g."italic", "bold"). Default: |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
Value
Ifname_file isNULL, a list containingggplot2objects is returned: plots of functional space along all pairs of axes(named according to axes names, e.g. "PC1_PC2"), figure 'caption', and thefull figure 'patchwork' built using the librarypatchwork.Ifname_file is notNULL a 300dpi png fileis saved in the working directory. Ranges of axes are the same for allpanels and if required projection of the convex hull computed in themultidimensional space provided as inputsp_faxes_coord isillustrated with a polygon. Species being vertices of this convex hull areshown with aesthetics provided as inputs..._vert. Labels forspecies listed inplot_sp_nm are added with if required arrowsusingggrepel. Summary about species and dimensionality are printedon top-right corner of the figure.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD")# Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD")# Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average")# Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Plot functional spaces:mFD::funct.space.plot( sp_faxes_coord = sp_faxes_coord_fruits[, c("PC1", "PC2", "PC3", "PC4")], faxes = NULL, name_file = NULL, faxes_nm = NULL, range_faxes = c(NA, NA), color_bg = "grey95", color_pool = "darkturquoise", fill_pool = "white", shape_pool = 21, size_pool = 1, plot_ch = TRUE, color_ch = "darkblue", fill_ch = "white", alpha_ch = 1, plot_vertices = TRUE, color_vert = "darkturquoise", fill_vert = "darkturquoise", shape_vert = 22, size_vert = 1, plot_sp_nm = NULL, nm_size = 3, nm_color = "black", nm_fontface = "plain", check_input = TRUE)Compute FUSE (Functionally Unique, Specialized and Endangered)
Description
This index takes into account species functional uniqueness (also calledFunctional Originality), species specialisation and species IUCN status.
Usage
fuse(sp_dist, sp_faxes_coord, nb_NN = 5, GE, standGE = FALSE)Arguments
sp_dist | a dist object provided by |
sp_faxes_coord | a data frame with the coordinates of the species on amultidimensional space based on a selected number of axes derived from aPrincipal Coordinate Analysis (PCoA). The species are in rows and the PCOAaxes are in column. |
nb_NN | a numerical value giving the number of nearest neighbor toconsider. Default: |
GE | a numerical vector giving the IUCN status rank (DD = NA, LC = 0,NT = 1, VU = 2, EN = 3, CR = 4) or the IUCN extinction probabilityassociated with each status. See Mooerset al. (2008) for furtherinformation. For example, DD = NA, LC = 0, NT = 0.1, VU = 0.4, EN = 0.666,and CR = 0.999). |
standGE | a logical value to standardize the GE values. |
Value
A data frame with species in rows and the following metrics incolumns:
FUSE: functionally unique, specialized and endangered (seePimientoet al. (2020);
FUn_std: functional uniqueness standardized between 0 and 1 (seeMouillotet al. (2013);
FSp_std: functional specialization standardized between 0 and 1(see Mouillotet al. (2013);
Author(s)
Fabien Leprieur and Camille Albouy
References
Mouillotet al. (2013) Rare species support vulnerable functions inhigh-diversity ecosystems.PLoS Biology,11, e1001569.
Pimientoet al. (2020) Functional diversity of marine megafauna in theAnthropocene.Science Advances,6, eaay7650.
Violleet al. (2007) Let the concept of trait be functional!Oikos,116, 882-892.
Examples
# Load species traits data:sp_tr <- read.csv(system.file('extdata', 'data_traits_MMA_ursus.csv', package = 'mFD'), dec = ',', sep = ';', header = TRUE, row.names = 1, na.strings='NA')# Trait compilation and ordination:dimorphism <- ordered(sp_tr$dimorphism)breeding_site <- ordered(sp_tr$breeding_site)social_behavior <- ordered(sp_tr$social_behavior)weight_max <- log(sp_tr$adult_weight_max)social_group <- log(sp_tr$social_group_mean) # Trait Matrix construction:sp_tr_end <- data.frame( main_diet = sp_tr$main_diet, foraging_water_depth = sp_tr$foraging_water_depth, foraging_location = sp_tr$foraging_location, fasting_strategy = sp_tr$fasting_strategy, female_sexual_maturity = sp_tr$female_sexual_maturity, weaning = sp_tr$weaning, gestation = sp_tr$gestation, inter_litter = sp_tr$inter_litter, breeding_site = sp_tr$breeding_site, social_group = sp_tr$social_group_mean, social_behavior = sp_tr$social_behavior, weight_max = sp_tr$adult_weight_max, dimorphism = sp_tr$dimorphism) rownames(sp_tr_end) <- rownames(sp_tr) # Function weigthing vector:v <- c(0.25, 0.25, 0.25, 0.25, 0.20, 0.20, 0.20, 0.20, 0.20, 0.5, 0.5, 0.5, 0.5) # Gower distance calculation:sp_tr_end$main_diet <- as.factor(sp_tr_end$main_diet)sp_tr_end$foraging_water_depth <- as.factor(sp_tr_end$foraging_water_depth)sp_tr_end$foraging_location <- as.factor(sp_tr_end$foraging_location)sp_tr_end$breeding_site <- as.factor(sp_tr_end$breeding_site)sp_tr_end$social_behavior <- as.factor(sp_tr_end$social_behavior)sp_dist_tr <- cluster::daisy(sp_tr_end, metric = c('gower'), type = list(symm = c(4)), weights = v) # Principal coordinate analysesPcoa <- ade4::dudi.pco(ade4::quasieuclid(sp_dist_tr), scann = FALSE, nf = 40)sp_faxes_coord <- Pcoa$li[1:40] # FUSE calculation: FUSE_res <- mFD::fuse( sp_dist = sp_dist_tr, sp_faxes_coord = as.matrix(sp_faxes_coord), nb_NN = 5, GE = sp_tr$IUCN_num, standGE = TRUE) FUSE_res FUSE_res2 <- mFD::fuse( sp_dist = sp_dist_tr, sp_faxes_coord = as.matrix(sp_faxes_coord), nb_NN = 5, GE = sp_tr$IUCN_50, standGE = TRUE) FUSE_res2 FUSE_res3 <- mFD::fuse( sp_dist = sp_dist_tr, sp_faxes_coord = as.matrix(sp_faxes_coord), nb_NN = 5, GE = sp_tr$IUCN_100, standGE = TRUE) FUSE_res3Compute the Minimum Spanning Tree (MST) linking species of a givenassemblage
Description
This function computes the MST linking species of a given assemblage and isused to compute FEve index.
Usage
mst.computation(sp_faxes_coord_k)Arguments
sp_faxes_coord_k | a matrix relating species coordinates for speciespresent in a given assemblage. |
Value
A dist object summarizing the MST for all species of a givenassemblagemst_asb_k.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute the distance of "pear" to its nearest neighbor(s): mst_fruits <- mst.computation(sp_faxes_coord_fruits) mst_fruitsPlot individual plots along a pair of functional axes into a unique graph
Description
This function gathers panels into a uniquepatchwork graphwith caption.
Usage
panels.to.patchwork(panels, plot_caption)Arguments
panels | a list of ggplot objects illustrating an index on two givenfunctional axes. There must be either one, three or six ggplot objects giventhe number of studied functional axes. |
plot_caption | a ggplot object illustrating the caption of thefinal patchwork plot. |
Value
A unique ggplot object gathering functional panels and caption.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
## Retrieve FRic plot:# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix: sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord # Retrieve species coordinates matrix for the assemblage "basket_1": sp_filter <- mFD::sp.filter(asb_nm = c("basket_1"), sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights) sp_faxes_coord_fruits_b1 <- sp_filter$`species coordinates` # Reduce it to the two studed axes: PC1 and PC2: sp_faxes_coord_fruits_b1_2D <- sp_faxes_coord_fruits_b1[, c("PC1", "PC2")]# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve vertices names: vert_nm_fruits <- vertices(sp_faxes_coord_fruits_b1_2D, order_2D = TRUE, check_input = TRUE) # Plot in white the convex hull of all fruits species: ggplot_fric <- mFD::fric.plot( ggplot_bg = ggplot_bg_fruits, asb_sp_coord2D = list(basket_1 = sp_faxes_coord_fruits_b1_2D), asb_vertices_nD = list(basket_1 = vert_nm_fruits), plot_sp = TRUE, color_ch = c("basket_1" = "black"), fill_ch = c("basket_1" = "white"), alpha_ch = c("basket_1" = 0.3), size_sp = c("basket_1" = 1), shape_sp = c("basket_1" = 16), color_sp = c("basket_1" = "red"), fill_sp = c("basket_1" = "red"), size_vert = c("basket_1" = 1), color_vert = c("basket_1" = "red"), fill_vert = c("basket_1" = "red"), shape_vert = c("basket_1" = 16)) ggplot_fric ## Create a caption summing up FRic values # retrieve values to plot:top_fric <- c("Functional richness", "basket_1", "")asb_fd_ind <- alpha_fd_indices_fruits <- mFD::alpha.fd.multidim(sp_faxes_coord = sp_faxes_coord_fruits[ , c("PC1", "PC2", "PC3", "PC4")],asb_sp_w = baskets_fruits_weights,ind_vect = c("fric"),scaling = TRUE,check_input = TRUE,details_returned = TRUE)values_fric <- c(round(asb_fd_ind$functional_diversity_indices["basket_1", "fric"], 3), "")# customize position of texts in the plot:spread_faxes <- (range_sp_coord_fruits[2] - range_sp_coord_fruits[1])hh <- c(1, 2.5, 4, 5.5)vv <- 0.3# plot window:x <- NULLy <- NULLplot_caption <- ggplot2::ggplot(data.frame(x = range_sp_coord_fruits, y = range_sp_coord_fruits), ggplot2::aes(x = x, y = y)) + ggplot2::scale_x_continuous(limits = range_sp_coord_fruits, expand = c(0, 0)) + ggplot2::scale_y_continuous(limits = range_sp_coord_fruits, expand = c(0, 0)) + ggplot2::theme_void() + ggplot2::theme(legend.position = "none") + ggplot2::geom_rect(xmin = range_sp_coord_fruits[1], xmax = range_sp_coord_fruits[2], ymin = range_sp_coord_fruits[1], ymax = range_sp_coord_fruits[2], fill = "white", colour ="black")# plot names of index and of assemblages:h <- NULLv <- NULLtop <- NULLx <- NULLy <- NULLplot_caption <- plot_caption + ggplot2::geom_text(data = data.frame( h = range_sp_coord_fruits[1] + spread_faxes * 0.15 * hh[c(1,3:4)], v = range_sp_coord_fruits[2] - spread_faxes * rep(0.2, 3), top = top_fric), ggplot2::aes(x = h, y = v, label = top), size = 3, hjust = 0.5, fontface = "bold")# plot FRic values:values_lab <- NULLdata_caption <- data.frame( h = range_sp_coord_fruits[1] + spread_faxes * 0.15 * hh[2:4], v = range_sp_coord_fruits[2] - spread_faxes*rep(vv, 3), values_lab = c("FRic", values_fric))plot_caption <- plot_caption + ggplot2::geom_text(data = data_caption, ggplot2::aes(x = h, y = v, label = values_lab), size = 3, hjust = 0.5, fontface = "plain")## Create patchwork:patchwork_fric <- mFD::panels.to.patchwork(list(ggplot_fric), plot_caption)patchwork_fricPlot species from the pool
Description
Plot all species from the study case and associated convex hull
Usage
pool.plot( ggplot_bg, sp_coord2D, vertices_nD, plot_pool = TRUE, shape_pool = 3, size_pool = 0.8, color_pool = "grey95", fill_pool = NA, color_ch = NA, fill_ch = "white", alpha_ch = 1, shape_vert = 3, size_vert = 1, color_vert = "black", fill_vert = NA)Arguments
ggplot_bg | a ggplot object of the plot background retrieved throughthe |
sp_coord2D | a list of matrix (ncol = 2) with coordinates ofspecies present in the pool for a given pair of axes |
vertices_nD | a list (with names as in sp_coord2D) of vectors withnames of species being vertices in n dimensions. |
plot_pool | a logical value indicating whether species of eachassemblage should be plotted or not. Default: plot_pool = TRUE. |
shape_pool | a numeric value referring to the shape used to plotspecies pool. Default: |
size_pool | a numeric value referring to the size of species belongingto the global pool. Default: |
color_pool | a R color name or an hexadecimal code referring to thecolor of the pool. This color is also used for FRic convex hull color.Default: |
fill_pool | a R color name or an hexadecimal code referring to thecolour to fill species symbol (if |
color_ch | a R color name or an hexadecimal code referring to theborder of the convex hull filled by the pool of species. Default: |
fill_ch | a R color name or an hexadecimal code referring to thefilling of the convex hull filled by the pool of species. Default is: |
alpha_ch | a numeric value for transparency of the filling of theconvex hull (0 = high transparency, 1 = no transparency). Default: |
shape_vert | a numeric value referring to the shape used to plotvertices if vertices should be plotted in a different way than otherspecies. If |
size_vert | a numeric value referring to the size of symbol forvertices. Default: |
color_vert | a R color name or an hexadecimal code referring to thecolor of vertices if plotted. If color_vert = NA, vertices are not plotted(for shapes only defined by color, ie shape inferior to 20. Otherwise fillmust also be set to NA). Default: |
fill_vert | a character value referring to the color for filling symbolfor vertices (if |
Value
A ggplot object plotting background of multidimensional graphs andspecies from the global pool (associated convex hull if asked).
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces(sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits_2D <- fspaces_quality_fruits$details_fspaces$sp_pc_coord[ , c("PC1", "PC2")]# Set faxes limits:# set range of axes if c(NA, NA): range_sp_coord_fruits <- range(sp_faxes_coord_fruits_2D) range_faxes_lim <- range_sp_coord_fruits + c(-1, 1)*(range_sp_coord_fruits[2] - range_sp_coord_fruits[1]) * 0.05 # Retrieve the background plot: ggplot_bg_fruits <- mFD::background.plot( range_faxes = range_faxes_lim, faxes_nm = c("PC 1", "PC 2"), color_bg = "grey90") # Retrieve vertices names: vert_nm_fruits <- vertices(sp_faxes_coord_fruits_2D, order_2D = TRUE, check_input = TRUE) # Plot the pool: plot_pool_fruits <- pool.plot(ggplot_bg = ggplot_bg_fruits, sp_coord2D = sp_faxes_coord_fruits_2D, vertices_nD = vert_nm_fruits, plot_pool = TRUE, shape_pool = 3, size_pool = 0.8, color_pool = "grey95", fill_pool = NA, color_ch = NA, fill_ch = "white", alpha_ch = 1, shape_vert = 3, size_vert = 1, color_vert = "black", fill_vert = NA) plot_pool_fruitsCompute functional spaces and their quality
Description
Compute a Principal Coordinates Analysis (PCoA) using functional distancebetween species. Then the function evaluates the quality of spaces builtusing an increasing number of principal components. Quality is evaluated asthe (absolute or squared) deviation between trait-based distance (input) anddistance in the PCoA-based space (raw Euclidean distance or scaled distanceaccording to its maximum value and maximum of trait-based distance). Optionto compute a functional dendrogram and its quality. This function is basedon the framework presented in Maireet al. (2015).
Usage
quality.fspaces( sp_dist, fdendro = NULL, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE)Arguments
sp_dist | a dist object with pairwise distance among all species (atleast 3 species needed). Functional distance matrix from trait values canbe computed using |
fdendro | a character string indicating the clusteringalgorithm to use to compute dendrogram. Should be one of the methodrecognized by |
maxdim_pcoa | a single numeric value with maximum number of PCoA axesto consider to build multidimensional functional spaces. Default: |
deviation_weighting | a character string referring to themethod(s) used to weight the differences between species pairwise distancein the functional space and trait-based distance. |
fdist_scaling | a vector with logical value(s) specifyingwhether distances in the functional space should be scaled beforecomputing differences with trait-based distances. Scaling ensures thattrait-based distances and distances in the functional space have the samemaximum.Default: |
Value
A list with:
$quality_fspaces: a data frame with quality metric(s) foreach functional space. Functional spaces are named as 'pcoa_.d' and ifrequired 'tree_clustering method'. Quality metrics are named afterdeviation_weighting ('mad' for 'absolute' and and 'rmsd' for 'squared')and if fdist_scaling is TRUE with suffix '_scaled'.$details_trdista list with 2 elements:$trdist_summarya vector with minimum (min), maximum (max), mean (mean) and standarddeviation (sd) ofsp_dist;$trdist_euclideana logicalvalue indicating whethersp_distchecks Euclidean properties.$details_fspacesa list with 4 elements:$sp_pc_coorda matrix with coordinates of species (rows) along Principal Components(columns) with positive eigenvalues ;$pc_eigenvaluesa matrixwith eigenvalues of axes from PCoA ;$dendroa hclustobject with the dendrogram details (null if no dendrogram computed) ;$pairsp_fspaces_dista dataframe containing for each pair ofspecies (rows), their names in the 2 first columns ('sp.x' and 'sp.y'),their distance based on trait-values ('tr'), and their Euclidean(for PCoA) or cophenetic (for dendrogram if computed) distance in eachof the functional space computed ('pcoa_1d', 'pcoa_2d', ... ,'tree_clust');iffdist_scaling = TRUE,$pairsp_fspaces_dist_scaleda dataframe with scaled values of distances in functional spaces.$details_deviationa list of data frames:$dev_distspa dataframe containing for each space (columns) thedifference for all species pairs (rows) of the distance in thefunctional space and trait-based distance (i.e. positive deviationindicates overestimation of actual distance) ;$abs_dev_distspand/or$sqr_dev_distsp, dataframes with for each space (columns) and allspecies pairs (rows) the absolute or squared deviation of distance ; iffdist_scaling = TRUE$dev_distsp_scaled, and$abs_dev_distsp_scaledand/or$sqr_dev_distsp_scaled, dataframes with deviation computed on scaled distance in functional spaces.
Note
The maximum number of dimensions considered for assessing quality offunctional spaces depends on number of PC axes with positive eigenvalues(i.e. axes with negative eigenvalues are not considered); so it could belower than$maxdim_pcoa.The quality metric obtained with deviation_weighting = 'squared' andfdist_scaling = TRUE is equivalent to the square-root of the 'mSD'originally suggested in Maireet al. (2015).
Author(s)
Sebastien Villeger, Eva Maire, and Camille Magneville
References
Maireet al. (2015) How many dimensions are needed to accurately assessfunctional diversity? A pragmatic approach for assessing the quality offunctional spacesGlobal Ecology and Biogeography,24, 728-740.
Examples
# Load Species x Traits Datadata("fruits_traits", package = "mFD")# Load Traits x Categories Datadata("fruits_traits_cat", package = "mFD")# Compute Functional Distancesp_dist_fruits <- mFD::funct.dist( sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute Functional Spaces Quality (to retrieve species coordinates)fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") fspaces_quality_fruits # Retrieve Species Coordinatessp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coordsp_faxes_coord_fruitsPlot functional space quality with a chosen quality metric
Description
Plot functional space quality with a chosen quality metric
Usage
quality.fspaces.plot( fspaces_quality, quality_metric, fspaces_plot, name_file = NULL, range_dist = NULL, range_dev = NULL, range_qdev = NULL, gradient_deviation = c(neg = "darkblue", nul = "grey80", pos = "darkred"), gradient_deviation_quality = c(low = "yellow", high = "red"), x_lab = "Trait-based distance")Arguments
fspaces_quality | output from the |
quality_metric | a character string with the name of the quality metricto illustrate. Should be one of the column names of |
fspaces_plot | a vector with names of functional spaces to consider.Should be a subset of the row names of |
name_file | a character string with name of file to save thefigure (without extension). Default: |
range_dist | a vector with minimum and maximum values todisplay for species pairwise distances (x-axis for all panels and y-axesof top panel). Default: NULL, which means range is 0 to maximum distanceamong all the functional spaces to plot. |
range_dev | a vector with minimum and maximum values to displayfor deviation to trait-based distance (y-axis of middle panel). Default:NULL, which means range is set to range of deviation among all thefunctional spaces to plot. |
range_qdev | a vector with minimum and maximum values todisplay for deviation to trait-based distance (y-axis of bottom panel).Default:NULL, which means range is from 0 to the maximum of (transformed)deviation among all the functional spaces to plot. |
gradient_deviation | a vector of 3 colors for illustrating rawdeviation with |
gradient_deviation_quality | 2 colors (named 'low' and 'high') forillustrating transformed deviation used to compute quality metric with |
x_lab | a character string with title to display below X axis.Default is 'Trait-based distance'. |
Value
A png file (resolution 300dpi) saved in the current workingdirectory. Quality of each functional space is illustrated with threepanels : - top row shows trait-based distance between species vs.space-based distance. - middle row shows trait-based distance vs.deviation between space-based and trait-based distances - bottom row showstrait-based distance between species vs. transformed deviation used tocompute the quality metric All plots have the same X axis. All plots on agiven row have the same Y axis and color palette. Type of distance infunctional space (Euclidean in PCoA, Cophenetic on tree) are abbreviated,as well as type of transformation of distance (scaling) and of deviation(Absolute or Squared)
Author(s)
Sebastien Villeger and Camille Magneville
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe:data("baskets_fruits_weights", package = "mFD")# Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD")# Compute functional distancesp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE)# Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Illustrate the quality of functional spaces: mFD::quality.fspaces.plot( fspaces_quality = fspaces_quality_fruits, quality_metric = "mad", fspaces_plot = c("tree_average", "pcoa_2d", "pcoa_3d", "pcoa_4d", "pcoa_5d"), name_file = NULL, range_dist = NULL, range_dev = NULL, range_qdev = NULL, gradient_deviation = c(neg = "darkblue", nul = "grey80", pos = "darkred"), gradient_deviation_quality = c(low ="yellow", high = "red"), x_lab = "Trait-based distance")Retrieve information about species in a given assemblage
Description
This function computes names of species present in an given assemblage,their coordinates in the functional space and their weights. It is used inthealpha_FD_multidim function to filter species and compute eachfunctional indices for each community.
Usage
sp.filter(asb_nm, sp_faxes_coord, asb_sp_w)Arguments
asb_nm | a string object referring to the name of a given community. |
sp_faxes_coord | a matrix of species coordinates in a chosen functionalspace. Species coordinates have been retrieved thanks to |
asb_sp_w | a matrix linking weight of species (columns) and aset of assemblages (rows). |
Value
A vector containing names of species present in a given assemblagesp_name_asb_k, a matrix containing coordinates of species presentin a given assemblagesp_faxes_coord_k, a matrix containing weightof species present in a given assemblageasb_sp_w_k, a matrixcontaining relative weight of species present in a given assemblageasb_sp_relatw_k.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe:data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe:data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist( sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix:fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Filter species of basket_1 assemblage:sp.filter(asb_nm = "basket_1", sp_faxes_coord = sp_faxes_coord_fruits, asb_sp_w = baskets_fruits_weights)Compute Functional Entities composition based on a Species x Traits matrix
Description
Compute Functional Entities composition based on a Species x Traits matrix
Usage
sp.to.fe(sp_tr, tr_cat, fe_nm_type = "fe_rank", check_input = TRUE)Arguments
sp_tr | a data frame containing species as rows and traits as columns. |
tr_cat | a data frame containing three columns for each trait (rows):
|
fe_nm_type | a character string referring to the type of namingfunctional entities. Two possible values:"fe_rank" (FE are namedafter their decreasing rank in term of number of speciesi.e. fe_1is the one gathering most species) and"tr_val" (FE are named afternames of traits and of trait values for each FE, if possible,seedetails below). Default: |
check_input | a logical value indicating whether key features theinputs are checked (e.g. class and/or mode of objects, names of rowsand/or columns, missing values). If an error is detected, a detailedmessage is returned. Default: |
Details
fe_nm_type = "tr_val" is allowedonly if:
there are less than 7 traits;
none of them is fuzzy-coded (so that names are not too long)
all trait names and all trait values have different 2 first letters
If these 3 conditions are met, names of Functional Entities are made as acharacter string of up to 2 letters for trait name in upper case font thenup to 2 letters for trait value in lower case font, separated by "_" betweentraits. Trait names are abbreviated to a single letter whenever possible.Examples: ("TAc2_TBxx_TCyy", "TAc3_TBff_TCyy") or("A2_Bx_Cy", "A3_Bf_Cy")
Value
A list of objects containing:
fe_nm: a vector with names of all FE (followingfe_nm_type). FE are ordered according to the decreasing number ofspecies they gather.
sp_fe: a vector containing for each species the name of theFE it belongs to. FE order is done according to decreasing number ofspecies.
fe_tr: a data frame containing traits values (variables incolumns) for each FE (rows). FE order is done according to decreasingnumber of species.
fe_nb_sp: a vector with species number per FE. If all FEhave only one species, a warning message is returned. FE are orderedaccording to the decreasing number of species they gather.
details_fe: a list containing:fe_codes a vectorcontaining character referring to traits values (like a barcode) withnames as in
fe_nm_typeand sorted according tofe_nb_sp;tr_uval a list containing for each trait a vector of its uniquevalues or a data frame for fuzzy-coded traits;fuzzy_E a listwith for each fuzzy-coded trait a data frame with names of entities (E)and names of species (sp);tr_nb_uval a vector with number ofunique values per trait (or combinations for fuzzy-coded traits);max_nb_fe the maximum number of FE possible given number ofunique values per trait.
Author(s)
Sebastien Villeger, Nicolas Loiseau, and Camille Magneville
Examples
# Load species traits data: data("fruits_traits", package = "mFD")# Transform species traits data:# Only keep the first 4 traits to illustrate FEs: fruits_traits <- fruits_traits[ , c(1:4)] # Load trait types data: data("fruits_traits_cat", package = "mFD")# Transform the trait types data to only keep traits 1 - 4: fruits_traits_cat <- fruits_traits_cat[c(1:4), ]# Gather species into FEs:## gathering species into FEs (FEs named according to the decreasing...## ... number of species they gather): sp_FEs <- mFD::sp.to.fe( sp_tr = fruits_traits, tr_cat = fruits_traits_cat, fe_nm_type = "fe_rank")## display FEs names:sp_FEs$fe_nm## display for each species the name of the FE it belongs to:sp_FEs$sp_fe## display trait values for each FE:sp_FEs$fe_tr ## display the number of species per FEs:sp_FEs$fe_nb_spSummarize Species x Traits data frame
Description
This function computes a summary data helping to choose the type of analysisyou can do with your data. For this function to work, there must be no NA inyoursp_tr data frame.
Usage
sp.tr.summary(tr_cat, sp_tr, stop_if_NA = TRUE)Arguments
tr_cat | a data frame containing three columns for each trait (rows):
|
sp_tr | a data frame of traits values (columns) for each species(rows). Note that species namesmust be specified in the row names. |
stop_if_NA | a logical value indicating whether the process should stopif there is some NA in the |
Value
If there is no fuzzy-coded trait, a three-elements list with:
tr_summary_list | a table summarizing for each trait thenumber of species per modality for non-continuous trait and min, max,mean, median, and quartiles for continuous traits. |
tr_types | a list containing traits type. |
mod_list | a list containing modalities for all traits. |
If there is fuzzy-coded trait, a four-elements list with:
tr_summary_non_fuzzy_list | a table summarizing for each trait thenumber of species per modality for non-continuous trait and min, max,mean, median, and quartiles for continuous traits. |
tr_summary_fuzzy_list | a table summarizing for each subtrait min,max, mean, median and quartiles |
tr_types | a list containing traits type. |
mod_list | a list containing modalities for non-continuous trait. |
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species x Traits datadata('fruits_traits', package = 'mFD')# Load Traits x Categories datadata('fruits_traits_cat', package = 'mFD')# Summarize Species x Traits datamFD::sp.tr.summary(tr_cat = fruits_traits_cat, sp_tr = fruits_traits)Build a functional space based on continuous traits only
Description
This function computes a functional space based on continuous standardizedtraits or continuous raw traits matrix. User can either choose to computefunctional space based on PCA analysis or using one trait for one functionalaxis. For PCA analysis, center and scale arguments are consideredFALSE:if you want to center, scale or standardize by any mean your data, pleaseusetr.cont.scale function. Option makes it possible tocompute correlation between traits.
Usage
tr.cont.fspace( sp_tr, pca = TRUE, nb_dim = 7, scaling = "scale_center", compute_corr = "pearson")Arguments
sp_tr | a data frame of traits values (columns) for each species(rows). Note that species namesmust be specified in the row names andtraits must becontinuous (raw or standardized). |
pca | a logical value. If |
nb_dim | an integer referring to the maximum number of dimensions formultidimensional functional spaces. Final number of dimensions dependson the number of positive eigenvalues obtained with the PCA. High valuefor |
scaling | a string value to compute (or not) scaling of traits usingthe |
compute_corr | a string value to compute Pearson correlationcoefficients between traits ( |
Value
A list containing a matrix withmAD andmSD values for eachfunctional space to assess the quality of functional spaces), a matrixcontaining eigenvalues for each axis, the percentage of variance explainedby each axis and the cumulative percentage of variance, a data framecontaining species coordinates on each functional axis, list of distancematrices in the functional space (Euclidean distances based on trait valuesand coordinates in the functional spaces), a dist object containing initialeuclidean distances based on traits and a matrix of correlation coefficientsbetween traits (if required).
Author(s)
Camille Magneville and Sebastien Villeger
Examples
load(system.file('extdata', 'sp_tr_cestes_df', package = 'mFD'))mFD::tr.cont.fspace( sp_tr = sp_tr, pca = TRUE, nb_dim = 7, scaling = 'scale_center', compute_corr = 'pearson')Scale continuous traits
Description
This function standardizes continuous traits. It can be useful beforecomputing functional space. You will have to choose which standardizedmethod to use based on your data. For this function to work, there must beno NA in yoursp_tr data frame.
Usage
tr.cont.scale(sp_tr, std_method = "scale_center")Arguments
sp_tr | a data frame of traits values (columns) for each species(rows). Note that species namesmust be specified in the row names andtraits must becontinuous. |
std_method | a character string referring to the standardizationmethod. Possible values: |
Value
A data frame of standardized trait values (columns) for each species(rows).
Author(s)
Camille Magneville and Sebastien Villeger
Examples
load(system.file('extdata', 'sp_tr_cestes_df', package = 'mFD'))mFD::tr.cont.scale(sp_tr = sp_tr, std_method = 'scale_center')Correlation between Traits and Axes
Description
Compute relationship between all traits and all axes of the functionalspace. For continuous trait a linear model is computed and r2 and p-valueare returned. For other types of traits, a Kruskal-Wallis test is computedand eta2 statistics is returned.Option allows to plot trait-axis relationships with scatterplot and boxplotfor continuous and non-continuous traits, respectively.
Usage
traits.faxes.cor( sp_tr, sp_faxes_coord, tr_nm = NULL, faxes_nm = NULL, plot = FALSE, name_file = NULL, color_signif = "darkblue", color_non_signif = "gray80", stop_if_NA = TRUE)Arguments
sp_tr | a data frame containing species as rows and traits as columns. |
sp_faxes_coord | a matrix of species coordinates in a multidimensionalfunctional space. Species coordinates have been retrievedthanks to |
tr_nm | a vector gathering the names of traits (as in |
faxes_nm | a vector gathering the names of PCoA axes (as in |
plot | a logical value indicating whether plot illustrating relationsbetween trait and axes should be drawn.You can only plot relationshipsfor up to 10 traits and/or 10 axes. |
name_file | the file name (without extension) to save the plot as a 300dpi JPEG file. Default is |
color_signif | an R color name or an hexadecimal code referring tothe color of points when relationships between the trait and the axis issignificant. Default is |
color_non_signif | an R color name or an hexadecimal code referring tothecolor of points when relationships between the trait and the axis are notsignificant. Default is |
stop_if_NA | a logical value to stop or not the process if the |
Value
1 data frame with for each combination of trait and axis (rows), thename of the test performed, and the corresponding statistics and p-value.Ifplot = TRUE a multi-panel figure with traits as columns and axes asrows is also plotted. When relationships between trait and axis issignificant the points are colored, else they remain grayish.
Author(s)
Nicolas Loiseau and Sebastien Villeger
Examples
# Load Species x Traits Datadata("fruits_traits", package = "mFD")# Load Traits categories dataframedata("fruits_traits_cat", package = "mFD")# Compute Functional Distancesp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute Functional Spaces Quality (to retrieve species coordinates)fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve Species Coordinatessp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute Correlation between Traits and Functional AxesmFD::traits.faxes.cor( sp_tr = fruits_traits, sp_faxes_coord = sp_faxes_coord_fruits, tr_nm = NULL, faxes_nm = NULL, name_file = NULL, color_signif = "darkblue", color_non_signif = "gray80")Compute vertices of the Minimal Convex Hull shaping species from a singleassemblage in a multidimensional functional space
Description
This function identifies species that are vertices of the minimal convexhull enclosing a community in a multidimensional functional space. Thisfunction is using theconvhulln function.
Usage
vertices(sp_faxes_coord, order_2D = FALSE, check_input = FALSE)Arguments
sp_faxes_coord | a matrix of species coordinates in a chosen functionalspace. Species coordinates have been retrieved thanks to |
order_2D | a logical value defining whether vertices names arereordered so that they define a convex polygon in 2D which is convenientfor plotting. Default is |
check_input | a logical value defining whether inputs are checkedbefore computation: species names must be put as row.names, there must beno NA and species number must be superior to (axes number + 1). Default: |
Value
A vector containing names of species being verticesvert_nm.
Author(s)
Camille Magneville and Sebastien Villeger
Examples
# Load Species*Traits dataframe: data("fruits_traits", package = "mFD")# Load Assemblages*Species dataframe: data("baskets_fruits_weights", package = "mFD") # Load Traits categories dataframe: data("fruits_traits_cat", package = "mFD") # Compute functional distance sp_dist_fruits <- mFD::funct.dist(sp_tr = fruits_traits, tr_cat = fruits_traits_cat, metric = "gower", scale_euclid = "scale_center", ordinal_var = "classic", weight_type = "equal", stop_if_NA = TRUE) # Compute functional spaces quality to retrieve species coordinates matrix: fspaces_quality_fruits <- mFD::quality.fspaces( sp_dist = sp_dist_fruits, maxdim_pcoa = 10, deviation_weighting = "absolute", fdist_scaling = FALSE, fdendro = "average") # Retrieve species coordinates matrix:sp_faxes_coord_fruits <- fspaces_quality_fruits$details_fspaces$sp_pc_coord# Compute vertices and order them clockwise: vert_nm <- vertices(sp_faxes_coord_fruits[ , c("PC1", "PC2")], order_2D = TRUE, check_input = TRUE) vert_nm