class: center, middle, inverse, title-slide .title[ # From taxonomic to functional and phylogenetic diversity ] .subtitle[ ## Serrapilheira/ICTP-SAIFR Training Program in Quantitative Biology and Ecology ] .author[ ### Andrea Sánchez-Tapia ] .date[ ### 3 August 2022 ] --- ### So far: + Organized repository + Map made in `tmap` for Spatial Analysis class + Code w/calculations from last class --- ## Creating functions + Think of the _application in real life_ of the function. Ex. If the function gets a single vector, or a data frame, it should work. + R functions tend to work in vectors, test at the vector or the matrix/dataframe scale first. --- ```r my_shannon <- function(x) { pi <- x/sum(x) H <- -sum(pi * log(pi)) } my_simpson <- function(x) { pi <- x/sum(x) Simp <- 1 - sum(pi^2) } my_diversity <- function(x, index = "shannon") { pi <- x/sum(x) if (index == "shannon") d <- -sum(pi * log(pi)) if (index == "simpson") d <- 1 - sum(pi^2) return(d) } ``` --- ## Biological diversity measures + __Biodiversity__ is a complex multifaceted concept that includes scales in space and time, and entities such as __species__, __traits__ and __evolutionary units__ (Pavoine and Bonsall 2011) -- + Diversity indexes have a __richness__ and __evenness__ components -- + Mathematical properties: + Must increase when more _new_ elements are added to the sample + Must be maximal when all the elements have the same frequency (__evenness__) + Some indices are proportional to sample size: a mathematical artifact --- ## Taxonomic diversity indices + Shannon diversity index $$ H = - \sum_{n=1}^{S}p_i \ln p_i $$ + Simpson's diversity index would be $$ 1 - \sum p_i^2 $$ + Inverse Simpson $$ 1/\sum p_i^2 $$ --- # Hill numbers, Rényi diversity + Common diversity indices are special cases of _Rényi diversity_ $$ H_a = 1/(1-a) * log \sum(p^a) $$ + Hill numbers (Hill 1973) $$ N_a = \exp(H_a) $$ Some different Hill numbers: Richness: `\(N_0 = S\)` Shannon diversity: `\(N_1 = e(H')\)` Inverse Simpson `\(N_2 = 1/D\)` --- ## Understanding which community is more diverse is not always straightforward .pull-left[ ```r Community.A <- c(10, 6, 4, 1) Community.B <- c(17, rep(1, 7)) library(vegan) diversity(Community.A, "shannon") diversity(Community.B, "shannon") diversity(Community.A, "invsimpson") diversity(Community.B, "invsimpson") ``` ] .pull-right[ ![](13_slides_files/figure-html/unnamed-chunk-3-1.png)<!-- --> ] --- ### Rényi diversity profiles intersect: cannot compare diversities <img src="13_slides_files/figure-html/unnamed-chunk-4-1.png" width="500" style="display: block; margin: auto;" /> --- ## From taxonomic to functional diversity: the briefest introduction to trait-based approaches in ecology + __"Functional trait"__: a morphological/physiological characteristic that interacts directly with the biotic and abiotic environment, determining the species' ability to establish and survive along environmental gradients and in the presence of other species + Restricted by the existence of fundamental trade-offs, creating integrated responses to the same factors (__ecological strategies__) + __Functional diversity:__ number, type, and distribution of functions performed by organisms within an ecosystem (Díaz & Cabido ) --- ## Trait spaces and distances + Measured at the __individual__ scale -- + Functional traits can be continuous or categorical -- + Adequate distance/dissimilarity measures: __Gower's__ distance -- + Inter-specific and intra-specific differences between individuals -- + Some examples: + Whole-plant trait: plant height, growth form + Leaf traits: Specific Leaf Area and Leaf Dry matter content --- class: middle <img src="figs/villeger.png" width="700" style="display: block; margin: auto;" /> Functional richness, functional evenness, divergence __(Villéger et al 2008)__ --- ## Phylogenetic diversity + Distance between species is __phylogenetic__. The most simplistic: numbers of nodes in a phylogenetic classification. The ideal: millions of years of the last (most recent) known split between taxa. + Phylogenetic autocorrelation: closer taxa share common ancestry, more phylogenetic diversity == more distinct taxa in the communities + A classic first measure was a dendrogram-based approach (Faith 1992) Sum of the length of the branches in a dendrogram --- class: middle, center <img src="figs/PD.png" width="801" style="display: block; margin: auto;" /> __(Faith 1992)__ <!-- SOURCE: https://image1.slideserve.com/1873912/phylogenetic-diversity-pd-l.jpg --> --- # Phylogenies in community ecology + We use topologies obtained from other authors (ex. APG III Magallón), __dated nodes__, and adjusting algorithms (Webb, Ackerly & Kembel 2008) + __Phylomatic__ (Webb, Ackerly & Kembel 2008) --- # A unifying paradigm: Rao's quadratic entropy <!-- $$ H_D(p) = \sum_{i=1}^{n} \sum_{j=1}^{n} p_i p_j d_{ij}$$ --> <img src="figs/rao.png" width="283" style="display: block; margin: auto;" /> + Where `\(d_{ij}\)` is a measure of the dissimilarity between species `\(i\)` and `\(j\)` + Quadratic entropy measures __the expected difference__ between two entities randomly drawn from the set --- ### How to conduct diversity analyses in R? + [Environmetrics CRAN Task View](https://cran.r-project.org/web/views/Environmetrics.html) (Gavin Simpson) + 📦 `vegan`, `ade4`, `FD`, `ape` + Publications! ---