The challenge question was as follows:

Test the null hypothesis that Anolis roosevelti is nested-within or sister- to the clade of Anolis lizards consisting of:

sp<-c("cristatellus","cooki","poncensis","gundlachi","pulchellus","krugi",
    "stratulus","evermanni")

Can we reject this placement for Anolis roosevelti?

First read our data & base tree:

library(phytools)
tree<-read.tree("Revell-etal.tree.tre")
tree
## 
## Phylogenetic tree with 100 tips and 99 internal nodes.
## 
## Tip labels:
##  ahli, allogus, rubribarbus, imias, sagrei, bremeri, ...
## 
## Rooted; includes branch lengths.
X<-read.csv("Revell-etal.data.csv",header=T,row.names=1)
X<-as.matrix(X)
X<-X[,1:20]
tip<-setdiff(rownames(X),tree$tip.label)
tip
## [1] "roosevelti"

Estimate our ML tree:

mltree<-locate.yeti(tree,X,search="exhaustive",plot=FALSE)
## Optimizing the phylogenetic position of roosevelti using ML. Please wait....
## Done.

Now run our simulation-based null hypothesis test:

pr<-getDescendants(tree,findMRCA(tree,sp))
pr.tree<-locate.yeti(tree,X,search="exhaustive",constraint=pr)
## Optimizing the phylogenetic position of roosevelti using ML. Please wait....
## Done.
LR.pr<-2*(mltree$logL-pr.tree$logL)
LR.null<-vector()
nsim<-20
obj<-phyl.vcv(X[pr.tree$tip.label,],vcv(pr.tree),lambda=1)
for(i in 1:nsim){
    Xsim<-sim.corrs(tree=pr.tree,vcv=obj$R,anc=obj$alpha[,1])
    mltree.null<-locate.yeti(tree,Xsim,search="exhaustive",plot=FALSE,
        quiet=TRUE)
    pr.tree.null<-locate.yeti(tree,Xsim,search="exhaustive",
        constraint=getDescendants(tree,findMRCA(tree,sp)),
        plot=FALSE,quiet=TRUE)
    LR.null[i]<-2*(mltree.null$logL-pr.tree.null$logL)
}
P.pr<-1-mean(LR.pr>=LR.null)
P.pr
## [1] 0.05

Here, by contrast to the placement of Anolis roosevelti as sister to A. cuvieri, we can confidently reject the hypothesis that A. roosevelti is part of the main clade of Puerto Rican anoles.

Written by Liam J. Revell. Last updated July 5, 2015.