9 pts total

A. 1 pt - Read in the morphometric data from Barr, 2014 on bovid astragali.

astrag <- read.table("http://hompal-stats.wabarr.com/datasets/barr_astrag_2014.txt", header=TRUE, sep="\t")
head(astrag)
##   individual                 Taxon Habitat    ACF  APD     B DistRad DMTD
## 1  AMNH81690    Aepyceros_melampus      LC 384.72 6.89 15.16    9.22 1.78
## 2  AMNH82050    Aepyceros_melampus      LC     NA 6.09 14.00    8.73 1.64
## 3  AMNH83534    Aepyceros_melampus      LC     NA 6.14 17.22    9.19 1.70
## 4  AMNH85150    Aepyceros_melampus      LC     NA 5.80 15.27    8.85 1.72
## 5 AMNH233038 Alcelaphus_buselaphus       O 607.83 7.46 18.47   11.33 2.26
## 6  AMNH34717 Alcelaphus_buselaphus       O 465.91 6.56 15.47    9.79 1.78
##   DTArea   LML   MIN   MML PMTD ProxRad  PTArea   WAF   WAT
## 1 553.14 35.78 28.04 34.39 6.33   10.00  915.50 21.39 21.83
## 2 558.17 35.46 27.28 33.18 6.54   10.50  841.79 22.47 21.11
## 3 554.00 39.15 29.99 36.94 7.63   10.65  976.25 22.07 21.54
## 4 498.67 36.61 28.02 34.09 6.97   10.00  841.71 22.55 21.03
## 5 900.76 45.25 36.03 43.55 6.83   13.85 1557.05 28.98 27.07
## 6 649.47 36.81 30.80 35.95 4.28   10.91 1139.50 24.04 25.84

B. 1 pt - Select the following colums from the data: Taxon, B, DistRad, and Habitat. Create a new dataframe with the Taxon, the Habitat and species means for B and DistRad.

library(dplyr)
selectedAstrag <- 
  astrag %>% 
  select(Taxon, B, DistRad, Habitat) %>%
  group_by(Taxon) %>%
  summarise(B = mean(B), DistRad = mean(DistRad), Habitat=unique(Habitat))

C. 1 pt - Read in the ruminant phylogeny from Hernández Fernández & Vrba, 2007.

#note I can load caper, which loads ape automatically and gives me access to the function read.tree()
library(caper)
## Loading required package: ape
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
## Loading required package: mvtnorm
rum <- read.tree("http://hompal-stats.wabarr.com/datasets/ruminants.phy")
rum
## 
## Phylogenetic tree with 197 tips and 159 internal nodes.
## 
## Tip labels:
##  Tragulus_javanicus, Tragulus_napu, Moschiola_meminna, Hyemoschus_aquaticus, Giraffa_camelopardalis, Okapia_johnstoni, ...
## 
## Rooted; includes branch lengths.

D. 1 pt - Combine the data and the tree using comparative.data() to ready the tree for pgls. Note: if you used dplyr in the steps above, you need to change the class of the resulting dataframe, because there is a bug in caper and it won’t deal with a dplyr tbl_df object. You can use this line of code to fix it class(dataframeFromDplyr) <- "data.frame"

class(selectedAstrag) <- "data.frame"
compDat <- comparative.data(phy = rum, data = selectedAstrag, names.col = "Taxon")

E. 2 pts - Plot the trimmed tree that includes just the taxa of interest in the astragalus dataset. Make it as beautiful as you can.

plot(compDat$phy)