/working/auteur.extended/R/get.times.R

http://github.com/eastman/auteur · R · 16 lines · 13 code · 3 blank · 0 comment · 1 complexity · 6ab405640083990a4cfd9549b168d4b0 MD5 · raw file

  1. get.times<-function(phy)
  2. {
  3. df=data.frame(phy$edge)
  4. names(df)=c("anc","des")
  5. anc=lapply(df$des,get.ancestors.of.node,phy)
  6. order.edges=c(0,phy$edge.length)[order(c(Ntip(phy)+1,df$des))]
  7. df$time=0
  8. for(n in 1:length(anc)){
  9. df$time[n]=sum(order.edges[anc[[n]]])+order.edges[df$des[n]]
  10. }
  11. df=rbind(c(0,Ntip(phy)+1,0),df)
  12. return(df)
  13. }