Welcome to the short course on comparative methods, held in Bogota, Colombia at the
Universidad de los Andes as a part of
NNB3. On this blog I will post both data and scripts that you can use to carry out the analyses that you learned in the course.
R scripts:
Part 1: Introduction to comparative methods in R
Part 1
Part 2: Comparative analysis of single variables
Part 2
Part 3: Comparative analyses of two (or more!) variables
Part 3
Actual R scripts from the workshop
morning
afternoon
Files you will need:
anolisDataAppended.csv
anolis.phy
multiple_trees.phy
phel2.phy
phelsuma.csv
Challenge questions:
Problem set 1
(for after “part 1”)
(“x” = “optional” for now, you can do these later if you don’t have time; skip to non-x questions first):
1. Create a vector called "vec" that contains the numbers 1:500. Have r report the mode, length, and class of that vector
2. Create a matrix called "dataSet" that has the following elements:
0.1 1 10
0.2 2 12
0.3 3 14
0.4 4 16
Print out only the third column of this matrix. Find the mean of the third column.
x3. r has a function called var(). Find out how it works using the help page. Then find the variance of the vector z<-1:1000.
x4. Create a plot of y=x^2 where x ranges from -5 to 5.
5. Read in the data phelsuma.csv. Describe the data set. How many species are included? How many variables?
6. Read in the tree phel2.phy. Plot the tree. Is it ultrametric?
7. Do the names match in the two data sets? If not, make a tree and data set that do match using treedata().
x8. Reroot the tree using the species “ornata” as an outgroup.
Problem set 2 (for after “part 2”)
(“x” = “optional” for now, you can do these later if you don’t have time; skip to non-x questions first):
1. Carry out a test for phylogenetic signal in ln(svl) for the gecko species.
2. Reconstruct ancestral states for ln(svl) in these geckos. Make a plot to show your results.
3. Use fitContinuous to compare the fit of Brownian motion, OU, and Early Burst among these gecko species.
4. (challenge) Create a new variable that is “TRUE” for geckos with SVL greater than 50 mm, and “FALSE” otherwise. (hint: “>” does this; e.g. the R command “x > 4” returns a vector with TRUE for every x > 4 and FALSE otherwise). Reconstruct ancestral character states for this vector, and plot your results.
Problem set 3 (for after “part 3)
1. Is there an evolutionary correlation between ln(SVL) and ln(jaw) across the species of Phelsuma geckos?
2. (challenge) There is a function in geiger called “sim.char” that allows you to simulate data on a phylogenetic tree. Use this function to simulate a new continuous and a new discrete variable for your geckos. Check the help file for sim.char for some examples, and try to replicate them.
3. (challenge) Run the "auteur" analysis - an "extra" in the R scripts that I supply above - on both anoles and day gecko body size evolution.