Trait-Based Ecology Tools in R
Total Page:16
File Type:pdf, Size:1020Kb
Trait-based ecology tools in R Lars Götzenberger, Francesco de Bello, Andre TC Dias, Marco Moretti, Matty P Berg, Carlos P Carmona 2021-01-17 Contents 1 – General Introduction 7 1.1 Content and structure ............................... 7 1.2 Prerequisites .................................... 8 1.3 Scripts, packages, and additional functions and data .............. 8 1.4 Some definitions and standards .......................... 9 1.5 Acknowledgements ................................. 10 2 – Trait Data 11 2.1 Data ......................................... 11 2.2 Required packages and additional functions ................... 11 2.3 Obtaining and handling data from the LEDA plant trait database ...... 12 2.4 Handling different taxonomic concepts across data sets - dealing with syn- onymies ....................................... 14 2.5 Using the traitor package to support your trait sampling campaign ...... 22 3 – Trait dissimilarity 31 3.1 Data ......................................... 31 3.2 Required packages and additional functions ................... 31 3.3 Calculation of trait dissimilarity ......................... 31 3.4 Some problems with the Gower distance ..................... 35 3.5 Categorical and fuzzy coded traits ........................ 37 3.6 Missing values (NAs) ................................ 42 3.7 Functional groups with students’ traits ...................... 42 3.8 Some real data with the function trova ...................... 49 3.9 The gawdis function ................................ 51 3.9.1 Introduction ................................ 52 3.9.2 Loading functions ............................. 52 3.9.3 The Gower distance ............................ 52 3.9.4 Traits contribution and trait weight ................... 54 3.9.5 The function gawdis: basics ........................ 56 3.9.6 The function gawdis: analytical vs. iterative approaches ........ 58 3.9.7 The function gawdis: grouping traits .................. 59 3.9.8 The function gawdis: fuzzing coding and dummy variables ...... 63 4 – (Multivariate) species level responses 67 4.1 Data ......................................... 67 4.2 Required packages and additional functions ................... 68 4.3 “Trait-free” Canonical Correspondance Analysis ................. 69 4.4 Double Canonical Correspondance Analysis ................... 72 4.5 Functional response groups ............................ 74 4.6 RDA and regression trees ............................. 81 4.7 Boosted regression trees (BRT) .......................... 85 4.7.1 How useful are regression trees? ...................... 87 4.7.2 Aggregating models ............................. 88 4.7.3 Bagging ................................... 94 4.7.4 A “homemade” bagging example ..................... 95 4.7.5 Boosted regression trees (BRT) ...................... 98 4.7.6 Boosted regression trees for studying the relationship between traits and vegetative reproduction ........................ 99 3 5 – Community Weighted Mean (CWM) and Functional Diversity (FD) 111 5.1 Community Weighted Mean (CWM) ....................... 111 5.1.1 Data ..................................... 111 5.1.2 Required packages and additional functions ............... 112 5.1.3 Calculation of CWM with invented data ................. 112 5.1.4 Calculation of CWM with real data ................... 118 5.1.5 Can we trust the p-value of CWM-based analyses? ........... 125 5.2 Functional Diversity (FD) ............................. 128 5.2.1 Data ..................................... 128 5.2.2 Required packages and additional functions ............... 129 5.2.3 Calculation of FD with the dbFD function ................ 129 5.2.4 dbFD function with NE Spain data .................... 135 5.2.5 Package picante .............................. 141 5.2.6 Alpha, Beta and Gamma FD ....................... 150 6 – Intraspecific trait variability 155 6.1 Data ......................................... 155 6.2 Required packages and additional functions ................... 156 6.3 Intra- vs interspecific trait variability within communities ........... 156 6.4 ITV between communities ............................. 159 6.5 Decomposition of variance across scales using mixed models .......... 164 6.6 The Trait Probability Density (TPD) approach ................. 165 6.6.1 The probabilistic nature of functional diversity ............. 165 6.6.2 The TPDs function ............................. 167 6.6.3 The TPDsMean function .......................... 174 6.6.4 Estimating functional dissimilarity: the dissim function ........ 176 6.6.5 TPDc: from species to communities .................... 179 6.6.6 Functional Richness, Evenness and Divergence (REND function) .... 181 6.6.7 Beta diversity (function dissim) ..................... 184 6.6.8 Functional redundancy of communities (redundancy) ......... 186 7 – Null models 189 7.1 Data ......................................... 189 7.2 Required packages and additional functions ................... 191 7.3 Introduction to randomizations .......................... 192 7.4 Unconstrained randomizations by hand ..................... 193 7.5 Randomization functions .............................. 196 7.6 The independent swap randomization algorithm ................. 198 7.7 SES functions .................................... 200 7.8 Randomizing the trait matrix ........................... 201 7.9 Examples with real dataset ............................ 203 7.9.1 Environmental filtering .......................... 203 7.9.2 Biotic interactions ............................. 205 7.9.3 The site specific species pool and dark diversity ............. 207 8 – Traits and phylogeny 213 8.1 Data ......................................... 213 8.2 Required packages and additional functions ................... 213 8.3 Importing, handling, and visualizing phylogenetic trees ............. 213 8.4 Estimating the phylogenetic signal of a trait ................... 217 8.5 Traitgrams ..................................... 220 8.6 Phylogenetic comparative methods ........................ 221 8.7 Imputing trait data with the help of phylogeny ................. 224 8.8 Phylogenetic diversity ............................... 225 8.9 How to combine trait and phylogenetic diversity ................ 227 9 – Linking traits to ecosystem functions 229 9.1 Data ......................................... 229 9.2 Required packages and additional functions ................... 230 4 9.3 Multivariate analyses between traits and ecosystem functions ......... 231 9.4 Testing the relationship between traits and ecosystem functions ........ 236 9.5 Decomposing the net diversity effect ....................... 241 9.6 Care with FD and CWM as predictors ...................... 247 10 – Traits and trophic interactions 249 10.1 Data ......................................... 249 10.2 Required packages ................................. 249 10.3 Calculating functional aspects of food preference ................ 250 10.4 Testing the response-effect trait framework across trophic levels ........ 256 5 1 – General Introduction Welcome to the R material accompanying the reference textbook “Handbook of Trait-Based Ecology: From Theory to R Tools” (Cambridge University Press). The material we present here is a set of practicals using the statistical software R, designed to complement the book. Although it can be used without the book, the book does provide all the conceptual and mathematical ground on which this R material is built. This R material will hopefully provide you with all the technical knowledge you need to translate the theoretical foundations laid out in the book to actual data analyses. At the same time, the book will provide the ecological context for which the methods described in this manual are useful. Given the main target of the book, these techniques and analyses will mainly focus on handling and analyzing trait data, often in combination with community, environmental, and phylogenetic data, or any combination of these additional ‘ingredients’. 1.1 Content and structure We structured this document in a way so that R material chapters correspond to chapters in the book. So if we refer, for example, to R material Ch 6 you already know that this R material will contain approaches and methods that are connected to the topics contained in Chapter 6 of the book. We made this analogy in numbering as consistent as possible. As a consequence, since in the main book we do not provide specific methods in Chapter 1, 11 and 12, there is no R materials for these chapters. Some R material chapters might have subchapters that do not correspond directly with the subchapters in the book, so as to keep consecutive numbering for the subchapters. For instance, in the case of Chapter 5, in the R material we present two separate chapters for CWM 5.1 and FD 5.2, which are treated in subchapters 5.2 and 5.3 in the book. In R material Chapter 2, we introduce the package traitor that deals with missing trait data, a topic which (strictly speaking) is dealt with in Chapter 11 of the book. The following table gives you a quick overview of the contents of each R material. Figure 1.1: R materials, their related chapters and covered topics 7 1.2 Prerequisites We designed this manual for people with a basic knowledge of R and some basic statistical skills. Therefore, particularly for the material in the first chapters, we have kept things as simple as possible, with a very step-by-step approach in the R scripts and the statistical analyses considered. R was chosen as a common and open