if (FALSE) {
library(phytools)
library(geiger)
# create time calibrated tree
mytree<-rtree(100)
mycalibration <- makeChronosCalib(mytree, node="root", age.max=50)
phy <- chronos(mytree, lambda = 1, model = "correlated",
calibration = mycalibration, control = chronos.control() )
class(phy)<-"phylo"
# create three normally distributed phenotypic traits
traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy)))
colnames(traits) <- c("V1","V2","V3")
rownames(traits) <- phy$tip.label
# select two random tips, excluding sister taxa
pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,
which(phy$tip.label == x[1]),which(phy$tip.label == x[2])))
nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))]
focaltaxa <- nosis[,sample(1:ncol(nosis),1)]
system.time(run <- calcConvCt(phy, traits, focaltaxa))
system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=100))
plot2D(run, phy, focaltaxa[1:2], colnames(traits)[1:2], traits)
}
Run the code above in your browser using DataLab