<<

Introduction to phylogenetic comparative methods in R Pável Matos October 17, 2019

This is a tutorial that captures the essence of comparative methods using phylogenies. We will use both simulated and real-world data, along with basic statistics implemented in R packages. The lecture is divided in three sections: 1) Handling and visualizing phylogenies and traits data in the R environment; 2) Understanding the principles of Brownian motion and its use in evolutionary correlations among species traits; 3) Working with phylogenetically independent contrasts (PIC) and phylogenetic generalized least squares regression (PGLS) using R.

Package installations This tutorial was created using R v.3.6.1. You can download the latest R version from the CRAN site. We require two of the most popular phylogenetic R packages: ape and phytools: • ape is an essential R package for handling phylogenetic trees and running analyses of comparative data, including ancestral state reconstruction, diversification rate analyses, and DNA distance computation. • phytools is also handy for manipulating phylogenetic trees and includes other comparative methods and functions not available in ape. We begin this tutorial by installing them: if(!require(ape))install.packages("ape") if(!require(phytools))install.packages("phytools") # the nlme package will allow us to fit Gaussian linear mixed-effects model if(!require(phytools))install.packages("nlme") # the dplyr package will help us to handle data tables if(!require(phytools))install.packages("dplyr")

And loading the phylogenetic R packages into our R working space: library(ape) library(phytools) library(nlme)

Other important phylogenetic packages include phylobase (manipulating trees and comparative data), geiger (methods for fitting evolutionary models to phylogneies), and caper (phylogenetic comparative analyses). You can visit the following CRAN Task View to see all R packages that can handle phylognetic and comparative data. Once we have our working R libraries correctly loaded, we can set the working directory by using the setwd(). The working directory is the place where the data for this tutorial should be stored. setwd("C:/Users/pavel/Desktop") getwd() # check where your current working directory is

## [1] "C:/Users/pavel/Desktop"

SECTION 1: Phylogenetic trees using R packages There are several ways to represent phylogenetic trees. The two most common types of trees are phylograms and .

1 Phylograms contain information on topology (phylogenetic relationships among species) and branch lengths that represent evolutionary change (e.g., number of nucleotide substitutions). Let’s simulate and visualize a phylogram having 20 species. phylo = rtree(n=20) plot(phylo)

t5 t13 t20 t10 t19 t17 t1 t18 t9 t7 t12 t8 t14 t3 t2 t16 t15 t4 t6 t11

Dendrograms are a special kind of phylograms, in that the tips of the have the same distance from the root. Dendrograms are also called ultrametric trees, which usually depict times of divergence (e.g., millions of years). Let’s again simulate a phylogeny, and have this as an ultrametric tree with 30 extant species dendro = pbtree(n=30) plot(dendro); axisPhylo()

2 t21 t20 t26 t25 t1 t15 t14 t17 t16 t9 t8 t19 t18 t12 t5 t11 t10 t4 t3 t7 t28 t27 t6 t24 t30 t29 t23 t22 t13 t2

3 2.5 2 1.5 1 0.5 0

To add node labels in the phylogeny, simply type nodelabels()

3 plot(dendro); axisPhylo(); nodelabels()

t21 59 t20 57 t26 58 t25 t1 t15 51 56 t14 52 t17 55 t16 53 t9 45 54 t8 t19 31 50 49 t18 t12 43 46 t5 47 t11 48 t10 40 t4 44 t3 t7 41 t28 42 32 t27 t6 37 t24 38 t30 39 t29 33 t23 36 35 t22 34 t13 t2

3 2.5 2 1.5 1 0.5 0

HINT: To spread out the image, you can save the plot as pdf adjusting for width and height sizes. Running

4 the command below will save the figure in your working directory. pdf(file = "mytree.pdf", width =9, height = 12) plot(dendro); axisPhylo(); nodelabels() dev.off() # Now, look for the pdf file at your working directory

We can edit and manipulate phylogenetic trees using the R packages ape and phytools. For example, we can find and highlight species of interest in the phylogeny. In this case, we want to find species “t10” in the phylogeny. find.species = c("t10") plot(dendro); axisPhylo(); add.arrow(dendro, tip = find.species, hedl = 0.05, col = "red", offset = 0.1)

5 t21 t20 t26 t25 t1 t15 t14 t17 t16 t9 t8 t19 t18 t12 t5 t11 t10 t4 t3 t7 t28 t27 t6 t24 t30 t29 t23 t22 t13 t2

3 2.5 2 1.5 1 0.5 0

We can also find the most recent common ancestor (MRCA) of two species. For example, let’s find the MRCA of species “t10” and “t13” in the phylogeny.

6 node = fastMRCA(dendro, "t10", "t13") plot(dendro); axisPhylo(); nodelabels(node = node)

t21 t20 t26 t25 t1 t15 t14 t17 t16 t9 t8 t19 t18 t12 t5 t11 t10 t4 t3 t7 t28 32 t27 t6 t24 t30 t29 t23 t22 t13 t2

3 2.5 2 1.5 1 0.5 0

7 Additionally, if the MRCA falls inside the phylogeny, we can extract the subclade containing the MRCA and all of its descendants from the original phylogeny. sub. = extract.clade(dendro, node) # we can plot the extracted clade using # plot(sub.clade)

8 original tree extracted clade

t21 t1 t20 t15 t26 t14 t25 t17 t1 t15 t16 t14 t9 t17 t8 t16 t19 t9 t18 t8 t12 t19 t5 t18 t12 t11 t5 t10 t11 t4 t10 t3 t4 t7 t3 t28 t7 t28 32 t27 32 t27 t6 t6 t24 t24 t30 t30 t29 t29 t23 t23 t22 t22 t13 t13 t2 t2

3 2 1 0 2.5 2 1.5 1 0.5 0

Alternatively, we can either prune or keep a number of species from the tree. For example, we want to remove the following 10 species out of our phylogeny: “t1”, “t2”, “t3”, “t4”, “t5”,

9 “t6”, “t7”, “t8”, “t9”, and “t10”. par(mfrow = c(1,2)) sp.set = c("t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "t9", "t10") plot(dendro, main = "original tree"); axisPhylo() pr1.tree = drop.tip(dendro, sp.set) plot(pr1.tree, main = "all except 10 species"); axisPhylo();

10 original tree all except 10 species

t21 t21 t20 t20 t26 t25 t26 t1 t25 t15 t14 t15 t17 t16 t14 t9 t17 t8 t19 t16 t18 t19 t12 t5 t18 t11 t12 t10 t4 t11 t3 t28 t7 t28 t27 t27 t24 t6 t24 t30 t30 t29 t29 t23 t23 t22 t22 t13 t2 t13

3 2 1 0 3 2.5 2 1.5 1 0.5 0

Or, we want to keep all the 10 taxa of interest in the phylogeny, and remove all other species.

11 par(mfrow = c(1,2)) plot(dendro, main="original tree"); axisPhylo() pr2.tree = drop.tip(dendro, setdiff(dendro$tip.label, sp.set)) plot(pr2.tree, main = "only 10 species"); axisPhylo();

12 original tree only 10 species

t21 t1 t20 t26 t25 t9 t1 t15 t14 t8 t17 t16 t9 t8 t5 t19 t18 t12 t10 t5 t11 t10 t4 t4 t3 t7 t3 t28 t27 t6 t7 t24 t30 t29 t23 t6 t22 t13 t2 t2

3 2 1 0 2.5 2 1.5 1 0.5 0

It is also possible to store many phylogenetic trees in one single R object (You can encounter a set of phylogenetic trees, for example, in the posterior distribution from a Bayesian phylogenetic inference).

13 Let’s store a copy of each of the 5 simulated trees above in one single R object called multi.phylo. multi.phylo = c(phylo, dendro, sub.clade, pr1.tree, pr2.tree) multi.phylo

## 5 phylogenetic trees We can call any element in the multi.phylo object. For example, we want to plot the first simulated phylogram. plot(multi.phylo[[1]])

t5 t13 t20 t10 t19 t17 t1 t18 t9 t7 t12 t8 t14 t3 t2 t16 t15 t4 t6 t11

Finally, we can save and load phylogenetic trees in several formats. The two most common tree formats are newick and nexus, which can be recognized by R functions having .tree() and .nexus(), respectively. To save the phylogenies, type the following: write.tree(dendro, file=".newick.tre") write.nexus(dendro, file="dendrogram.nex.tre")

Now, you can load the saved tree files.

14 dendro.newick = read.tree(file="dendrogram.newick.tre") dendro.nexus = read.nexus(file="dendrogram.nex.tre") # plot the loaded dendrogram saved in plot(dendro.newick)

15 t21 t20 t26 t25 t1 t15 t14 t17 t16 t9 t8 t19 t18 t12 t5 t11 t10 t4 t3 t7 t28 t27 t6 t24 t30 t29 t23 t22 t13 t2

Let’s have a look at how both tree files are structured.

16 # newick format writeLines(readLines("dendrogram.newick.tre"))

## ((((t2:1.053143244,(t13:0.485929273,(t22:0.1143679921,t23:0.1143679921):0.3715612808):0.5672139707):0.8313475122,(((t29:0.004229910377,t30:0.004229910377):0.08356128786,t24:0.08779119824):0.5997932488,t6:0.687584447):1.196906309):0.8978588367,(((t27:0.05897751674,t28:0.05897751674):0.6279206004,t7:0.6868981171):1.822953508,((t3:0.8435732792,t4:0.8435732792):1.210003923,((((t10:0.5839565914,t11:0.5839565914):0.2271813406,t5:0.811137932):0.3769129703,(t12:0.4923276469,(t18:0.3339928798,t19:0.3339928798):0.158334767):0.6957232554):0.6220279902,((((t8:0.6140755837,t9:0.6140755837):0.4216540133,(t16:0.4729586968,t17:0.4729586968):0.5627709003):0.2148269302,(t14:0.4803316293,t15:0.4803316293):0.7702248979):0.332428687,t1:1.582985214):0.2270936782):0.2434983098):0.4562744233):0.2724979672):0.103205451,((t25:0.07774284778,t26:0.07774284778):0.4423811885,(t20:0.2324601897,t21:0.2324601897):0.2876638466):2.365431007); # nexus format writeLines(readLines("dendrogram.nex.tre"))

## #NEXUS ## [R-package APE, Thu Oct 17 12:10:07 2019] ## ## BEGIN TAXA; ## DIMENSIONS NTAX = 30; ## TAXLABELS ## t2 ## t13 ## t22 ## t23 ## t29 ## t30 ## t24 ## t6 ## t27 ## t28 ## t7 ## t3 ## t4 ## t10 ## t11 ## t5 ## t12 ## t18 ## t19 ## t8 ## t9 ## t16 ## t17 ## t14 ## t15 ## t1 ## t25 ## t26 ## t20 ## t21 ## ; ## END; ## BEGIN TREES; ## TRANSLATE ## 1 t2, ## 2 t13, ## 3 t22, ## 4 t23, ## 5 t29, ## 6 t30, ## 7 t24,

17 ## 8 t6, ## 9 t27, ## 10 t28, ## 11 t7, ## 12 t3, ## 13 t4, ## 14 t10, ## 15 t11, ## 16 t5, ## 17 t12, ## 18 t18, ## 19 t19, ## 20 t8, ## 21 t9, ## 22 t16, ## 23 t17, ## 24 t14, ## 25 t15, ## 26 t1, ## 27 t25, ## 28 t26, ## 29 t20, ## 30 t21 ## ; ## TREE * UNTITLED = [&R] ((((1:1.053143244,(2:0.485929273,(3:0.1143679921,4:0.1143679921):0.3715612808):0.5672139707):0.8313475122,(((5:0.004229910377,6:0.004229910377):0.08356128786,7:0.08779119824):0.5997932488,8:0.687584447):1.196906309):0.8978588367,(((9:0.05897751674,10:0.05897751674):0.6279206004,11:0.6868981171):1.822953508,((12:0.8435732792,13:0.8435732792):1.210003923,((((14:0.5839565914,15:0.5839565914):0.2271813406,16:0.811137932):0.3769129703,(17:0.4923276469,(18:0.3339928798,19:0.3339928798):0.158334767):0.6957232554):0.6220279902,((((20:0.6140755837,21:0.6140755837):0.4216540133,(22:0.4729586968,23:0.4729586968):0.5627709003):0.2148269302,(24:0.4803316293,25:0.4803316293):0.7702248979):0.332428687,26:1.582985214):0.2270936782):0.2434983098):0.4562744233):0.2724979672):0.103205451,((27:0.07774284778,28:0.07774284778):0.4423811885,(29:0.2324601897,30:0.2324601897):0.2876638466):2.365431007); ## END;

SECTION 2: Brownian Brownian motion is a random process that models independent successive changes over time. Such changes are drawn from a normal distribution with mean zero and variance proportional to time: (σ2 × ∆t); in other words, we expect that, under Brownian motion, successive changes follow a normal distribution with a variance increasing linearly through time with a rate of σ2. We can simulate our own Brownian motion evolution. First, without taking into account a phylogenetic tree, and later, considering the phylogeny. We’ll let the process run for 10 generations (time) and a rate of 0.01 per generation (the variance: σ2). t =0 :10 # discrete time from 0 to 10 s2 = 0.01 # rate parameter # simulate multivariate random deviates from a normal distribution x = rnorm(n = length(t) -1, sd = sqrt(s2)) # get cumulative sum of all successive changes x = c(0, cumsum(x)) plot(t, x, type = "l", ylim = c(-1.5, 1.5), xlab = "time (t)", ylab = "x (some phenotype)")

18 1.5 1.0 0.5 −0.5 x (some phenotype) −1.5 0 2 4 6 8 10

time (t)

We can visualize the random nature of the Brownian motion by running the process two more times. y = c(0, cumsum(rnorm(n = length(t) -1, sd = sqrt(s2)))) z = c(0, cumsum(rnorm(n = length(t) -1, sd = sqrt(s2)))) plot(t, x, type = "l", ylim = c(-1.5, 1.5), xlab = "time (t)", ylab = "x (some phenotype)"); lines(t, y, col="red"); lines(t, z, col="green")

19 1.5 1.0 0.5 −0.5 x (some phenotype) −1.5 0 2 4 6 8 10

time (t)

And finally let it run for 100 times.

20 1.5 1.0 0.5 phenotype −0.5 −1.5 0 2 4 6 8 10

time

We can see that in the last generation (10th), the simulated trait follows a normal distribution.

21 trait at 10th generation 1.5 20 1.0 15 0.5 10 frequency phenotype −0.5 5 0 −1.5 0 2 4 6 8 10 −4 −2 0 2 4

time phenotype

Given that variance is proportional to time in the Brownian motion process, we expect to have a higher variance when we run the same process for longer time. Let’s run the same Brownian process this time for 100 generations and for 1,000 generations. Let’s compare the variances at the last generations.

22 trait at 10th generation 25 4 20 2 15 0 frequency phenotype 10 −2 5 −4 0

1 5 10 50 100 500 −5 0 5

time (log scale) phenotype

trait at 100th generation 20 4 2 15 0 10 frequency phenotype −2 5 −4 0

1 5 10 50 100 500 −5 0 5

time (log scale) phenotype

trait at 1000th generation 25 4 20 2 15 0 frequency phenotype 10 −2 5 −4 0

1 5 10 50 100 500 −5 0 5

time (log scale) phenotype

23 All fine. Let’s now simulate the Brownian motion on a phylogenetic tree. Remember that the evolutionary paths of traits among taxa are not independent because species share common ancestries (and common states at parental lineages). For this reason, any comparative study involving correlations among phenotypes, environment, or any other character states, should not assume that the data points were drawn independently; such studies should correct for species covariance due to phylogenetic relatedness (Felsenstein, 1985). We’ll use the fastBM() function from the R package phytools to simulate the Brownian process on each tree branch. In this way, we simulate covariances between sister species as common Brownian processes along parental branches. We can simulate a new ultrametric tree with 60 species. This time we will simualte a “coalescent tree shape”, i.e., long branches close to the root and short branches among close relatives, to emphasize the point that species are not independent and that closely related species would share similar phenotypes due to common ancestry. tr = rcoal(n = 60) bm.trait1 = fastBM(tr) # visualize both the ultrametric tree with branches scaled to time, and a phenogram # depicting the Brownian evolution of a simulated trait along branches par(mfrow = c(1,2)) plot(tr, main = "ultrametric tree"); axisPhylo() phenogram(tr, bm.trait1, spread.labels = TRUE, main = "trait evolution")

24 ultrametric tree trait evolution

t34 t55 t22 t56

t21 1.0 t30 t43 t11 t50 t21 t4 t54 t54 t11 t4 t45 t56 t10 t50 t13 t13 t52 t30

t41 0.5 t41 t53 t45 t9 t43 t7 t53 t42 t52 t8 t6 t28 t23 t47 t36 t60 t31 t12 t48 t20 t10 t14 0.0 t37 t5 t17 t40 t57 t44 t35 t58 t38 t32 t16 t27 t26 t2 t18 phenotype t39 t24 t3 t1 t59 t19 t29 t33 −0.5 t51 t5 t8 t29 t25t15 t32 t19t33 t58 t49 t2 t46 t3 t22 t59 t28 t39 t1 t34 t6 t24

t23 −1.0 t40 t16 t48 t17 t31 t60t37 t36 t18 t27 t57 t44 t7t12 t46 t42t9 t25 t38 t49 t20t26 t15 t14

t51 −1.5 t55 t35t47

0.8 0.6 0.4 0.2 0 0.0 0.2 0.4 0.6 0.8

time

Let’s simulate another uncorrelated trait under Brownian evolution. We’ll find out what happen when we fit a linear regression model to these points, making the implicit assumption that all the data points are independent and identically distributed.

25 bm.trait2 = fastBM(tr) plot(bm.trait1, bm.trait2) fit.lm <- lm(bm.trait2 ~ bm.trait1) abline(fit.lm, col = "red") 1.0 0.5 0.0 bm.trait2 −0.5

−1.5 −1.0 −0.5 0.0 0.5 1.0

bm.trait1

It seems that these two traits are correlated. But we know that this is not true. We simulated two independent traits without an evolutionary correlation between both. summary(fit.lm)

## ## Call: ## lm(formula = bm.trait2 ~ bm.trait1) ## ## Residuals: ## Min 1Q Median 3Q Max ## -1.26905 -0.07693 0.10043 0.25775 0.72270 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 0.06837 0.09240 0.740 0.46234 ## bm.trait1 -0.37275 0.09980 -3.735 0.00043 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 ## ## Residual standard error: 0.4851 on 58 degrees of freedom ## Multiple R-squared: 0.1939, Adjusted R-squared: 0.18

26 ## F-statistic: 13.95 on 1 and 58 DF, p-value: 0.0004305 Indeed, a simple linear regression assuming independece of data points suggests significance. We have demonstrated that not taking a phylogeny into account can increase the chances for type I error (false positive) when correlating traits among species. How can we account for data points that are related by a phylogeny relationships? In the next section, we will use two methods that deals with covariance among species data: independent contrasts and phylogenetic gls.

SECTION 3: Phylogenetically independent contrasts (PIC) and phylogenetic generalized least squares regression (PGLS) using R. Joseph Felsenstein published in 1985 a solution to take into account evolutionary correlation in comparative (see the paper). His algorithm transforms the original species data into contrasts between species reflected at the nodes of a phylogenetic tree. Following a Brownian evolution model, the standardized contrast between two tips, i and j, is:

X − X √i j vi + vj

Where, X is the trait value and v is the variance (relative to branch length). Once we have calculated the contrasts between two extant tips, we continue “down” the tree by estimating trait value at the node k using the following weighted average formula:

(1/vi)Xi + (1/vj)Xj Xk = 1/vi + 1/vj

Finally, we remove the tips i and j and increase a bit the branch lenght below node k. This will account for error in assigning a value to Xk. We use following formula to calculate how much we will lengthen the branch:

vivj vi + vj

You can visit the paper by Garland Jr. and Adolph in 1994 to find further discussion and examples using the standardized contrasts. Here, we will quickly revisit these formulas using a very simple example taken from Wikipedia:

27 The function pic() from the ape R package implements Felsenstein’s algorithm. Let’s apply it to the simulated traits above, and also to an empirical dataset. # PIC on the simulated data pic.trait1 = pic(bm.trait1, tr) pic.trait2 = pic(bm.trait2, tr) plot(pic.trait1, pic.trait2) fit.lm.pic <- lm(pic.trait2 ~ pic.trait1 - 1) # we fit the lm without an intercept term abline(fit.lm.pic, col = "red")

28 2 1 0 pic.trait2 −1 −2

−2 −1 0 1 2

pic.trait1

summary(fit.lm.pic)

## ## Call: ## lm(formula = pic.trait2 ~ pic.trait1 - 1) ## ## Residuals: ## Min 1Q Median 3Q Max ## -2.2993 -0.9069 -0.2195 0.3332 1.6426 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## pic.trait1 0.1713 0.1284 1.334 0.188 ## ## Residual standard error: 0.9259 on 58 degrees of freedom ## Multiple R-squared: 0.02976, Adjusted R-squared: 0.01303 ## F-statistic: 1.779 on 1 and 58 DF, p-value: 0.1875 The spurious correlation has been removed! Now, we can apply PIC to a real-world dataset. We will focus on the Bergmann’s rule: body size increases in colder climates. Let’s take the data from Alhajeri and Steppan (2016), which include the average species body mass and the average bioclimatic variables of 1315 species. Now, we will get a comprehensive rodent phylogeny. We will extract the species of interest from the mammal phylogenetic trees available at PHYLACINE v.1.2 (Faurby et al. (2019)). For practical reasons, we will use

29 one single mammal phylogeny randomly picked from the 1,000 available trees in PHYLACINE. Download the data from pavelmatos.wordpress.com/teaching, and save them in your current working directory: 1) one random tree from the complete mammal phylogeny in PHYLACINE v.1.2.

2) a single table with body mass and bioclimatic variables for . The bioclimatic variables are coded as follows:

Code Bioclimatic variable BIO1 Average annual temperature BIO2 Average diurnal range in temperature BIO3 Isothermality BIO4 Temperature seasonality BIO5 Maximum temperature of the warmest month BIO6 Minimum temperature of coldest month BIO7 Annual range in temperature BIO8 Average temperature of the wettest quarter BIO9 Average temperature of the driest quarter BIO10 Average temperature of the warmest quarter BIO11 Average temperature of the coldest quarter BIO12 Annual precipitation BIO13 Precipitation of the wettest month BIO14 Precipitation of the driest month BIO15 Seasonality of precipitation BIO16 Precipitation of wettest quarter BIO17 Precipitation of driest quarter BIO18 Precipitation of warmest quarter BIO19 Precipitation of coldest quarter

# read the mammal phylogeny mammal.tr = read.nexus("Complete_phylogeny_random.nex.txt") # read the table rod.traits <- read.csv("rodent_traits.csv.txt", header =T, row.names =1) # this replaces spaces to underscores in species names to match labels in tree row.names(rod.traits) <- gsub("","_",row.names(rod.traits)) # look at the first entries in the data frame head(rod.traits)

## MASS BIO1 BIO2 BIO3 BIO4 BIO5 BIO6 BIO7 ## Abditomys_latidens 268.0 21.92 8.01 68.23 97.42 27.80 16.06 11.74 ## Abeomelomys_sevia 54.9 16.48 11.02 88.34 55.62 22.72 10.24 12.48 ## Abrawayaomys_ruschii 63.0 19.36 13.42 57.14 365.82 30.76 7.26 23.50 ## Abrocoma_bennettii 251.0 10.11 12.87 58.86 350.74 21.99 0.01 21.98 ## Abrocoma_boliviensis 158.0 16.67 13.09 71.77 171.60 24.63 6.40 18.23 ## Abrocoma_cinerea 194.0 8.02 16.71 65.68 311.95 19.34 -6.18 25.52 ## BIO8 BIO9 BIO10 BIO11 BIO12 BIO13 BIO14 BIO15 ## Abditomys_latidens 22.04 21.43 23.12 20.60 2631.52 421.34 39.34 60.77 ## Abeomelomys_sevia 17.02 15.75 17.05 15.70 2509.20 299.69 115.13 32.15 ## Abrawayaomys_ruschii 22.50 15.90 23.72 14.86 1748.65 184.97 103.00 17.32 ## Abrocoma_bennettii 6.30 13.89 14.47 5.88 322.78 76.59 2.20 106.25 ## Abrocoma_boliviensis 18.53 14.57 18.53 14.38 654.00 120.33 12.67 81.50 ## Abrocoma_cinerea 11.07 4.62 11.18 3.68 291.64 77.44 1.27 128.50 ## BIO16 BIO17 BIO18 BIO19 SUBTR. LARGE

30 ## Abditomys_latidens 1116.45 157.10 631.38 264.55 N Y ## Abeomelomys_sevia 850.50 373.78 839.59 379.09 N N ## Abrawayaomys_ruschii 498.02 350.06 489.97 379.51 N N ## Abrocoma_bennettii 198.44 9.49 10.41 189.38 N Y ## Abrocoma_boliviensis 351.67 44.33 351.67 49.33 N Y ## Abrocoma_cinerea 191.50 6.38 167.41 7.34 N Y We will keep all the rodent species that have body size and climatic data from the mammal phylogeny. # Rodent species that have trait data TipsWant <- row.names(rod.traits) # keep only the taxa we are interested on rod.tr = drop.tip(mammal.tr, setdiff(mammal.tr$tip.label, TipsWant)) plot(rod.tr); axisPhylo()

31 CastorDipodomys fibercanadensis deserti Dipodomys gravipesvenustusagilisordiinelsonispectabilis Dipodomys compactuscalifornicusheermannistephensimicropsingens MicrodipodopsDipodomys merriaminitratoideselatorphillipsii megacephaluspallidus Perognathus parvusamplusinornatuslongimembrisflavusmerriami ChaetodipusPerognathus nelsoniintermediuslineatusformosusfasciatusflavescens Chaetodipus spinatusarenariusfallaxcalifornicuspernixpenicillatus HeteromysChaetodipus anomalusdesmarestianusaustralisnelsoni baileyihispidus ThomomysHeteromys gaumerioresterusbottaeumbrinustownsendiibulbivorus OrthogeomysZygogeomys trichopus hispiduslaniuscavatorunderwoodiheterodus OrthogeomysPappogeomysCratogeomys fumosuscastanopsmerriamigrandiscuniculus bulleri ThomomysGeomys pinetistropicalispersonatusarenariusbursarius monticola AnomalurusPedetesThomomys capensis talpoidesmazama pusillusderbianuspelii JaculusStylodipusIdiurusZenkerellaAnomalurus macrotiszenkeri orientalisjaculus teluminsignis beecrofti ZapusNapaeozapusAllactagaDipus sagittaprinceps elatereuphraticatetradactyla insignis SicistaCannomysZapus hudsoniustrinotatussubtilisnapaeabetulina badius TachyoryctesRhizomysSpalax microphthalmusleucodonehrenbergi pruinosussumatrensis macrocephalus DelanymysCalomyscusMyospalaxTachyoryctes psilurusmyospalaxaspalaxbrooksi bailwardi splendens CricetomysBeamysMystromysPetromyscus hindei albicaudatuseminigambianus monticulariscollinus SteatomysMegadendromusPrionomysSaccostomus parvuskrebsiipratensisbatesi campestrismearnsi nikolausi MacrotarsomysDendromusMalacothrix typicamesomelasmelanotisnyikaelovatimystacalis ingens BrachytarsomysNesomysBrachyuromysHypogeomysMacrotarsomys rufus antimena ramirohitrabetsileoensis bastardi albicauda EliurusGymnuromys minormyoxinustanalawebbipenicillatus roberti MesocricetusPhodopusEliurus majori campbellisungorus newtoniauratus NeofiberArvicolaOndatraPrometheomysCricetusCricetulusMesocricetus sapiduszibethicuscricetusalleni migratorius brandti schaposchnikowi MicrotusDinaromysArvicola amphibiuscabreraeochrogastermontebellikikuchii bogdanovi Microtus mexicanuschrotorrhinusquasiaterpinetorumoaxacensisguatemalensis Microtus townsendiioregonimiurusxanthognathusabbreviatuscalifornicus Microtus richardsoniumbrosuslongicaudusmontanuspennsylvanicuscanicaudus Microtus levisarvalissubterraneusduodecimcostatussaviimultiplex EolagurusLagurusChionomysLemmiscusMicrotus lagurusagrestissocialisguentheri luteus nivaliscurtatus MyodesEothenomysHyperacriusEllobius smithiifuscocapillustalpinus fertiliswynneimelanogaster AlticolaMyodes strelzowiroyleicalifornicusgapperiglareolusrufocanus LemmusSynaptomysAlticola stoliczkanusargentatus sibiricus borealiscooperi PhenacomysArborimusLemmusMyopus schisticolor lemmus albipespomolongicaudus intermediusungava IchthyomysDicrostonyx tweediihydrobatespittieristolzmannihudsoniusgroenlandicus NeusticomysChibchanomys venezuelaemussoimonticolusperuviensisoyapocki trichotis AbrothrixAndinomysWiedomysDelomys dorsalissublineatussanbornilongipilis pyrrhorhinos edax NotiomysChelemysAbrothrix lanosusolivaceusjelskiiandinusedwardsii macronyxmegalonyx EligmodontiaGraomysGeoxus valdivianus domorumgriseoflavusedithae morenimorganipuerulus PhyllotisAndalgalomysPunomysEligmodontia magisterdarwini lemminus typus pearsoniolrogi Phyllotis xanthopygusbonariensisdefinitusosgoodicaprinushaggardi AuliscomysLoxodontomysPhyllotis osilaeandiumamicus pictusboliviensis micropus CalomysPhyllotisNeotomysAuliscomys wolffsohnilauchahummelinckiboliviae ebriosus sublimis Calomys lepidusmusculinussorelluscallosuscallidustener OligoryzomysMicroryzomysNeacomys spinosusguianaetenuipes microtisminutusaltissimus Oligoryzomys andinusgriseolusfulvescenseliurusdestructorarenalis Oligoryzomys nigripeschacoensisdelticolalongicaudatusmagellanicusflavescens OryzomysMelanomys palustrisgorgasicouesi caliginosuszunigaerobustulus HolochilusPseudoryzomysNectomys squamipesrattuschacariusbrasiliensis simplex OecomysHolochilusLundomys cleberispeciosusrobertiflavicansconcolor molitorsciureus Oecomys rutilusbicolorsuperansphaeotismamoraetrinitatis ZygodontomysHandleyomysOecomys rexparicola intectusfuscatus brevicaudabrunneus IrenomysRhagomysJuliomysWilfredomysScolomys pictipes tarsalisucayalensismelanops rufescens oenax GalenomysEuneomysChinchillula petersonichinchilloidesfossormordax garleppisahamae RhipidomysReithrodon auritus macconnellivenezuelaemastacaliscaucensisleucodactyluslatimanus Rhipidomys venustusaustrinuswetzelifulviventercouesinitela ThomasomysPhaenomys ferrugineus hylophiluspyrrhonotuskalinowskiigracilismonochromos Thomasomys niveipesvestitusnotatusladewibaeopscinereus Thomasomys aureusdaphneparamorumischyrusincanuseleusis Thomasomys oreasbombycinusrosalindasilvestriscinereiventertaczanowskii BrucepattersoniusBibimysAepeomysChilomysAbrawayaomys chacoensistorresi instans lugens ruschii iheringi OxymycterusKunsiaScapteromysLenoxusBlarinomys tomentosusfronto apicalis breviceps tumidusparamensis Oxymycterus incahispidusangularisrufushiskaakodontius AkodonOxymycterus mimus delatorhucuchanasutusroberti Akodon siberiaetobamolinaedoloresiniscatusdayi Akodon affinistorquesaerosusorophilusalbiventersanctipaulensisbudini Akodon cursorsimulatorlindberghineocenusvariusmollis Akodon subfuscussylvanuslutescenskofordifumeussurdusjuninensis AkodonPodoxymysThaptomysDeltamys serrensisazaraeboliviensisspegazzinii kempi nigritaroraimae NecromysThalpomys lactensobscuruspunctulatusurichi cerradensislasiotis RheomysAnotomysNecromys mexicanusthomasileanderamoenuslasiurustemchuki SigmodonRheomys raptor mascotensisallenihispidusinopinatusochrognathus NyctomysOtonyctomysSigmodon sumichrastialstonileucotisfulviventerarizonae hatti OchrotomysTylomysOtotylomys tumbalensismiraenudicaudusbullaris phyllotis nuttalli PeromyscusScotinomysBaiomys musculustaylori xerampelinusteguina gossypinushooperi Peromyscus polionotusmaniculatuskeenimelanotissejugisleucopus Peromyscus evamerriamieremicuscalifornicuscrinitusfurvus PeromyscusOsgoodomys pectoralisochraventerdifficilisattwateripolius banderanus Peromyscus simulusboyliiwinkelmannitrueibullatusgratus PeromyscusMegadontomysHabromys lepturuschinantecolophurussimulatus stirtoni thomasi Peromyscus melanocarpusperfulvusmelanophrysmekisturusmegalopsmelanurus Peromyscus mexicanusyucatanicusaztecusgrandisguatemalensiszarhynchus OnychomysNeotomodonPodomysPeromyscus floridanus leucogastertorridusarenicolagymnotis alstoni ReithrodontomysIsthmomys pirrensis spectabilisgracilismexicanusbrevirostrisdarienensis Reithrodontomys hirsutuschrysopsismegalotiscrepermicrodontenuirostris Reithrodontomys fulvescenssumichrastiraviventrisburtimontanushumulis NeotomaNelsonia neotomodonfloridanapalatinanelsonimexicanagoldmani Neotoma devialepidacinereaphenaxmicropusangustapalata HodomysXenomysNeotoma albigulastephensifuscipesbryantinelsonialleni DeomysLophuromys ferrugineus flavopunctatuswoosnamisikapusimelanonyxnudicaudus Acomys kempipercivaliwilsonisubspinosusspinosissimuslouisae GerbillurusUranomysAcomys cahirinusminousrussatus ruddi vallinus GerbilliscusDesmodillusTateraGerbillurus indica setzeri leucogasterrobustusnigricaudusinclusus auricularis GerbillurusGerbilliscus tytonis kempibrantsiiguineaeafravalidus MerionesPsammomysGerbillurus unguiculatushurrianaelibycuspersicus paeba obesus TaterillusMeriones arenariusshawitristramicrassusvinogradovi GerbillusSekeetamysTaterillusAmmodillus nanushenleyigracilispygargusemini imbellis calurus Gerbillus cheesmaniperpallidusamoenusgerbilluspusillus LophiomysDesmodilliscusPachyuromysGerbillus pyramidumgleadowiandersoninigeriae imhausi duprasi braueri MusMuriculusMalacomys musculusspretusplatythrix imberbis longipesedwardsi Mus indutussetzeritritoncarolibooduga TokudaiaApodemusMus bufosetulosusminutoidesmahometmusculoides osimensis witherbyi Apodemus agrariussemotusmystacinusuralensissylvaticusflavicollis PraomysStenocephalemysApodemus moriohartwigi speciosus albocaudataruppigriseicauda MastomysPraomys derooidaltonijacksonitullbergi shortridgeinatalensis ZelotomysColomysMyomyscusMastomys goslingi couchaerythroleucushildegardeaewoosnami verreauxii HylomyscusHeimyscusPraomys delectorum fumosus denniaeparvusalleniaeta OenomysThamnomysMillardiaHylomyscus meltada hypoxanthusornatus stellakempivenustus AethomysHybomysDephomysStochomys univittatusplanifronstrivirgatus kaiseri defualongicaudatus GrammomysThallomysAethomys hindeichrysophiluspaedulcusnigricauda cometesmacmillani PelomysMylomysDasymysGrammomys fallax dybowskiiincomtus minnaeibeanusdolichurus LemniscomysDesmomysRhabdomysPelomys minorisseli harringtoni pumilio rosaliastriatus ArvicanthisLemniscomys blicki barbarusmacculusmittendorfigriselda OtomysParotomysGolundaArvicanthis laminatusdenti ellioti littledaleibrantsiiniloticusabyssinicus ChiropodomysHapalomysOtomys angoniensisirroratussaundersiae longicaudatus calamianensisgliroides PogonomysChiropodomys championisylvestrismacrourus muroidespusillusmajor MacruromysHyomysCrossomysMicrohydromysPogonomys goliathdammermani moncktoniloriae major richardsoni AnisomysCoccymysLorentzimysChiruromys imitatorruemmleri vatesforbesilamianouhuysi ParaleptomysXenuromysLeptomysHydromysParahydromys ernstmayrieleganschrysogaster barbatus wilhelmina asper XeromysPseudohydromysParaleptomys myoides rufilatus murinusoccidentalisellermanifuscus LeggadinaZyzomys pedunculatusargurusmainiwoodwardi forrestilakedownensis MastacomysNotomys cervinusalexismitchelliifuscusaquilo fuscus Pseudomys pilligaensisnovaehollandiaeoralisshortridgeidelicatulusoccidentalis Pseudomys fumeusapodemoidesalbocinereusnanusgracilicaudatusbolami Pseudomys australisdesertorfieldihermannsburgensischapmanijohnsoni MelomysProtochromysSolomysPseudomys salebrosusponceletirufescensobiensis higginsi fellowsi ParamelomysMelomys burtonicervinipescapensisbougainvilleleucogaster rubex MesembriomysParamelomys moncktonimollislevipesplatyopslorentzii macrurus UromysLeporillusConilurusMesembriomys neobritannicusanak penicillatusconditorapicalis gouldii AbeomelomysPogonomelomysUromys imperatorcaudimaculatushadrourusrex sevia mayeri MammelomysMallomys istapantapgunungrothschildiaroaensis lanosusrattoides ApomysChrotomysRhynchomysArchboldomys abrae whiteheadimindorensisgonzalesi isarogensis luzonensis Apomys musculussacobianusinsignishyloceteslittoralisdatae MaxomysApomys microdon suriferbartelsiiwhiteheadiinasalticola LenothrixNiviventerMaxomys canus rajahbaeodonochraceiventerpanglimaconinga NiviventerLeopoldamys culturatuscremoriventerrapitfulvescensniviventer sabanus SundamysParuromysBunomysLeopoldamys fratrorumchrysocomus infraluteusmuelleridominator edwardsi RattusAbditomysBullimus loseaargentiventerexulanseveretti bagobus latidens Rattus tunneyifuscipesnitidusrattusnorvegicustiomanicusbaluensis Rattus lutreolussordidusmorotaiensisannandaleicollettivillosissimus Rattus steinipraetormordaxleucopusniobevandeusenirichardsoni Rattus feliceusjobiensiselaphinusverecundusnovaeguineae BatomysMicromysBerylmysBandicotaNesokia indica grantibowersi minutussavileibengalensisindica CtenodactylusFeloviaPhloeomysBatomys vae salomonseni cumingipallidus valigundi HystrixMassoutieraPectinator cristatabrachyuracrassispinispumila spekei mzabi HeterocephalusAtherurusTrichysHystrix indicaafricaeaustralisfasciculata macrourusafricanus glaber ThryonomysHeliophobiusBathyergusGeorychusCryptomys hottentotuscapensissuillusjanetta gregorianus argenteocinereus CoendouChaetomysPetromusThryonomys bicolornycthemeraprehensilistypicus subspinosus swinderianus DasyproctaCuniculus taczanowskiipaca punctataleporinafuliginosaguamara MyoproctaDasyprocta acouchypratti azaraeprymnolophamexicanakalinowskii CaviaMicrocavia tschudiimagnafulgidaaperea australisshiptoniniata KerodonDolichotisGalea flavidensmusteloidesspixii rupestris salinicolapatagonum ChinchillaLagidiumLagostomusDinomys branickii viscaciawolffsohnichinchillalanigera maximus CtenomysAbrocoma tuconaxsteinbachiboliviensisbennettiicinerea Ctenomys fulvussaltariusmaulinussociabiliscolburnipontifex Ctenomys lewisifraterconoverileucodondorsalisopimus Ctenomys validusmagellanicusargentinusoccultuslatrotucumanus Ctenomys pearsoniperuanusperrensitorquatushaigisericeus Ctenomys emilianusazaraeknightiporteousibonettoiminutus AconaemysSpalacopusOctodontomysCtenomys talarummendocinusaustralis sageicyanus gliroides TympanoctomysOctomysOctodonAconaemys lunatusbridgesidegusmimax fuscus barrerae CallistomysCapromysGeocapromysCarterodonPlagiodontia pilorides sulcidenspictus aedium browniiingrahami Proechimys longicaudatussemispinosuscanicollisbrevicaudaguairaequadruplicatus Proechimys cuvierihoplomyoidessimonsidecumanusmincaeguyannensis HoplomysProechimys gymnurus goeldiichrysaeolussteereirobertioconnelli KannabateomysOlallamysDiplomysThrichomys labiliscanicepsalbicaudaedax apereoides amblyonyx PhyllomysEchimysDactylomys chrysurussaturnus unicolor boliviensisdactylinusperuanus lamarumbrasiliensisblainvilliinigrispinusthomasidasythrix MesomysLonchothrixMakalata macruradidelphoideshispidusstimulaxleniceps emiliae EuryzygomatomysClyomysTrinomysIsothrix bistriata laticepsiheringidimidiatussetosusalbispinus spinosus EliomysDryomysChaetocaudaSelevinia quercinusmelanurus lanigernitedulabetpakdalaensis sichuanensis GraphiurusGlisMuscardinus glis platyopsocularismurinuskelleni avellanarius SciurusAplodontia vulgarisyucatanensispucheraniinayaritensisdeppei rufa Sciurus colliaeisanbornilisaureogasteraestuanspyrrhinus Sciurus igniventrisspadiceusarizonensisoculatusallenigriseusrichmondi Sciurus ignitusabertigilvigulariscarolinensisgranatensisvariegatoides RheithrosciurusTamiasciurusSciurusMicrosciurus stramineus flaviventermimulussantanderensisalfaridouglasii macrotis PetinomysTamiasciurus vordermannisagittagenibarbissetosusfuscocapillus hudsonicus PetaurillusIomysHylopetes horsfieldii albonigerspadiceuslepidusphayreikinlochii PetauristaEoglaucomysGlaucomys magnificuselegansphilippensis volanssabrinus fimbriatus SciurillusPteromysPteromyscusAeromysPetaurista tephromelasthomasipusillus volansalborufuspetaurista pulverulentus FunambulusRatufa bicoloraffinisindicamacroura tristriatus DremomysFunambulus rufigenispernyilokriaheveretti pennantiisublineatuspalmarum CallosciurusRhinosciurusTamiops maritimus notatusbaluensismelanogaster laticaudatus LariscusCallosciurus insignis prevostiinigrovittatuscanicepsoresteserythraeusadamsi SundasciurusLariscus obscurushosei lowiitenuissamarensishippurus ParaxerusExilisciurusMyosciurusSundasciurus lucifer concinnuswhiteheadiexilispumilio brookei Paraxerus ochraceuscepapivexillariuspoensispalliatusflavovittiscooperi FunisciurusParaxerus boehmialexandri congicuscarruthersipyrropuslemniscatusbayonii EpixerusProtoxerusFunisciurus ebii aubinniistangeri anerythrussubstriatusleucogenysisabella HeliosciurusAmmospermophilus mutabilisrufobrachiumgambianusundulatuspunctatusruwenzorii nelsoni SpermophilusAmmospermophilus citellusrelictusfulvus leucurusinterpresharrisii CynomysSpermophilus ludovicianusparvidensgunnisonileucurus pygmaeussuslicus MarmotaCynomys caligatamarmotaolympuscaudatamonaxmexicanus XerusAtlantoxerusMarmota inaurisrutilusprincepserythropus flaviventrisvancouverensis getulus

70 60 50 40 30 20 10 0

32 Our rodent tree has 1194 species! length(rod.tr$tip.label)

## [1] 1194 It’s clear that we have more species (1315) in our trait table than in our tree (1194), because the phylogeny does not contain all described rodent species. We’ll then remove from the trait table all the taxa that are not in our rodent phylogeny. # list of taxa with traits that are not in the phylogeny remove.table = setdiff(TipsWant, mammal.tr$tip.label) # remove from table all rodent species that are not in phylogeny rod.traits = rod.traits[!(row.names(rod.traits) %in% remove.table), ]

We’re now ready to calculate the indepedent contrasts of the traits of interest: 1) body size, 2) average annual temperature (BIO1), and 3) annual precipitation (BIO12). rod.traits[["MASS"]] = log(rod.traits[["MASS"]]) # log convert body sizes rod.traits[["BIO12"]] = log(rod.traits[["BIO12"]]) # log convert annual precipitation rod.mass = rod.traits[["MASS"]] # data on body sizes rod.muP = rod.traits[["BIO12"]] # data on annual precipitation rod.muT = rod.traits[["BIO1"]] # data on average temperature

We’ll first compare body size and average temperature. pic.mass = pic(rod.mass, rod.tr) pic.muT = pic(rod.muT, rod.tr) plot(pic.muT, pic.mass) fit.pic.MT = lm(pic.mass ~ pic.muT -1) abline(fit.pic.MT, col = "red")

33 10 5 pic.mass 0 −5

−40 −20 0 20 40

pic.muT

summary(fit.pic.MT)

## ## Call: ## lm(formula = pic.mass ~ pic.muT - 1) ## ## Residuals: ## Min 1Q Median 3Q Max ## -6.3284 -0.2311 -0.0071 0.2126 10.3298 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## pic.muT 0.017553 0.004466 3.93 8.98e-05 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 ## ## Residual standard error: 0.7974 on 1192 degrees of freedom ## Multiple R-squared: 0.01279, Adjusted R-squared: 0.01196 ## F-statistic: 15.45 on 1 and 1192 DF, p-value: 8.98e-05 There is a weak (almost “flat” slope) but significant relationship between body size and temperature. However, this relationship is positive and therefore it is not in agreement with the Bergmann’s rule. Let’s now compare body size and annual precipitation. pic.mass = pic(rod.mass, rod.tr) pic.muP = pic(rod.muP, rod.tr) plot(pic.muP, pic.mass)

34 fit.pic.MP = lm(pic.mass ~ pic.muP -1) abline(fit.pic.MP, col = "red") 10 5 pic.mass 0 −5

−4 −2 0 2 4 6

pic.muP summary(fit.pic.MP)

## ## Call: ## lm(formula = pic.mass ~ pic.muP - 1) ## ## Residuals: ## Min 1Q Median 3Q Max ## -6.5778 -0.2291 -0.0137 0.2198 10.3581 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## pic.muP 0.18968 0.03941 4.813 1.68e-06 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 ## ## Residual standard error: 0.7949 on 1192 degrees of freedom ## Multiple R-squared: 0.01907, Adjusted R-squared: 0.01824 ## F-statistic: 23.17 on 1 and 1192 DF, p-value: 1.675e-06 Here there is also a weak but significant positive relationship between body size and annual precipitation. In their paper, Alhajeri and Steppan concluded that the Bergmann’s rule might not operate at large taxonomic scales, especifically in the Order Rodentia. However, they supported the hypothesis of increased body sizes

35 associated with higher primary (if annual precipitation can explain productivity). To conclude this tutorial, let’s touch briefly the phylogenetic gls. We will use the function gls() from the nlme package to fit a linear model using generalized least squares. We use the ape package to define within-group correlation (covariance between species) structure. First, we will describe species covariance as a result of a Brownian motion process. For this, we use the ape function corBrownian(): brownian = corBrownian(value =1, rod.tr) # value is the initial value of # gamma, a constant that is multiplied by the distance of nodes to the root # when calculating covariance under a Brownian motion brownian

## Uninitialized correlation structure of class corBrownian And we apply the gls using the defined variance-covariance structure to estimate the relationship between rodent body size and mean temperature: pgls.bm.MT = gls(MASS ~ BIO1, data = rod.traits, correlation = brownian) summary(pgls.bm.MT)

## Generalized least squares fit by REML ## Model: MASS ~ BIO1 ## Data: rod.traits ## AIC BIC logLik ## 3407.158 3422.408 -1700.579 ## ## Correlation Structure: corBrownian ## Formula: ~1 ## Parameter estimate(s): ## numeric(0) ## ## Coefficients: ## Value Std.Error t-value p-value ## (Intercept) 5.992405 1.0908606 5.493282 0 ## BIO1 -0.022548 0.0024177 -9.326432 0 ## ## Correlation: ## (Intr) ## BIO1 -0.037 ## ## Standardized residuals: ## Min Q1 Med Q3 Max ## -1.08409461 -0.54483136 -0.33010637 -0.05499997 1.10503755 ## ## Residual standard error: 3.700207 ## Degrees of freedom: 1194 total; 1192 residual Given that we use a Brownian evolution process, the results of PGLS are virtually the same as of PIC in terms of slope and significance: weak but significant positive relationship between body size and temperature. The flexibility of PGLS lies in the possibility to define within-group correlations. For example, one can relax the assumption of Brownian motion, as Mark Pagel did in 1999. The Pagel’s λ (lambda) parameter aims to measure “phylogenetic signal” by transforming branch lengths by a multiple of λ. When λ = 1 the tree is unchanged and the correlation is defined by a Brownian process, while for λ = 0 the branches collapse and the tree becomes a “star”, thus, the correlation follows a non-phylogenetic regression (independent data points).

36 The function corPagel() uses Pagel’s λ for building a correlation structure. Let’s investigate the relationship between rodent body size and mean temperature using a relaxed Brownian motion: lambda = corPagel(value =1, rod.tr) # value is initial value of lambda lambda

## Correlation structure of class corPagel representing ## lambda ## 1 And we’ll apply the gls under the correlation defined by Pagel’s λ. pgls.pl.MT = gls(MASS ~ BIO1, data = rod.traits, correlation = lambda) summary(pgls.pl.MT)

## Generalized least squares fit by REML ## Model: MASS ~ BIO1 ## Data: rod.traits ## AIC BIC logLik ## 2543.544 2563.877 -1267.772 ## ## Correlation Structure: corPagel ## Formula: ~1 ## Parameter estimate(s): ## lambda ## 0.9591239 ## ## Coefficients: ## Value Std.Error t-value p-value ## (Intercept) 5.656728 0.5332984 10.607061 0.0000 ## BIO1 -0.003015 0.0036941 -0.816056 0.4146 ## ## Correlation: ## (Intr) ## BIO1 -0.117 ## ## Standardized residuals: ## Min Q1 Med Q3 Max ## -2.1841710 -1.1010564 -0.6919923 -0.1285920 2.2981861 ## ## Residual standard error: 1.830264 ## Degrees of freedom: 1194 total; 1192 residual After correcting for phylogeny using PGLS and a relaxed Brownian motion (Pagel’s λ), the weak but significant body size-temperature relationship disappears (P = 0.4146)! Let’s see if the weak but significant body size-precipitation relationship disappears too. pgls.pl.MP = gls(MASS ~ BIO12, data = rod.traits, correlation = lambda) summary(pgls.pl.MP)

## Generalized least squares fit by REML ## Model: MASS ~ BIO12 ## Data: rod.traits ## AIC BIC logLik ## 2530.954 2551.288 -1261.477 ## ## Correlation Structure: corPagel

37 ## Formula: ~1 ## Parameter estimate(s): ## lambda ## 0.9576122 ## ## Coefficients: ## Value Std.Error t-value p-value ## (Intercept) 4.993944 0.5617604 8.889810 0.0000 ## BIO12 0.093256 0.0309972 3.008536 0.0027 ## ## Correlation: ## (Intr) ## BIO12 -0.362 ## ## Standardized residuals: ## Min Q1 Med Q3 Max ## -2.2463382 -1.1268005 -0.7203635 -0.1432242 2.3502549 ## ## Residual standard error: 1.811093 ## Degrees of freedom: 1194 total; 1192 residual The significance of the relationship between increased body size associated with increased annual precipitation holds. Alhajeri and Steppan suggested that, with this data and at the Order-level, rodent species tend to be larger in more productive regions. They put forward the idea that food availability, and not heat conservation as in Bergmann’s rule, is the more important mechanism driving body size variation across rodent species. There exist several other described models extending the Brownian motion process, such as the Ornstein- Uhlenbeck (evolution toward an optima ~ stabilizing selection). And of course, thorough evaluations are needed, e.g., comparing models (for instance, via Likelihood Ratio Tests), taking into account phylogenetic uncertainty (for instance, via the use of posterior distributions), etc. But strong limitations exist, including the hardly realistic assumptions under Brownian motion and its modifications Harmon, 2019, the neglectance of extinct lineages when estimating rate and trend of trait evolution Silvestro et al., 2018, or measurement errors and model-fitting misinterpretation Cooper et al., 2016. This was a tutorial that revisited the basics of comparative methods taking into account phylogenies. Now that you are familiar with the principles of PIC and PGLS, you can further sharpen your concepts by visiting the papers mentioned above and references therein.

Further practice Investigate the relationships among rodent body size and the other bioclimatic variables from Alhajeri and Steppan (2016). Can you find any other significant relationship?

38