Sunday, June 16, 2013

Okay, so I have a sample of 500 dated trees from my posterior. How to use this method for all of them? 
I haven't come across anyone actually doing this in practice. So let me work out the code right now.

This is probably wrong but I am going to try it:
#declare variables
i<-1
count<-0
final.data.frame<-data.frame()
other.data.frame<-data.frame()

#for every tree in the list
while (i <= length(mini.list)){
  #for that tree run the functions;#10000for testings sake
result<-evol.rate.mcmc(mini.list[[i]],x,ngen=10000,control=list(sd2=2.0,sdlnr=3.0))

  min_split<-minSplit(mini.list[[i]],result$mcmc[21:101,c("node","bp")]) 
  mcmc<-posterior.evolrate(mini.list[[i]],min_split,result$mcmc[21:101,],result$tips[201:1001])
  this.mcmc.data<-as.data.frame(mcmc)
  
#if the nodes produce the same edge, combine the data
if((mini.list[[1]]$edge[this.mcmc.data$node,]==mini.list[[i]]$edge[this.mcmc.data$node,])==TRUE)
  {
    final.data.frame<-rbind(final.data.frame, this.mcmc.data)
  }
#if not put in a different data frame
  else{
    other.data.frame<-rbind(other.data.frame, this.mcmc.data)
    count<-rbind(count, i)
  }
  
  i<-i+1
}
cat("count:", count, "\n")

No comments:

Post a Comment