Monday, April 30, 2012
Rescaling trees for LTT plotting
My suspicion is that his sample is from the posterior distribution of a relaxed clock Bayesian phylogenetic analysis in BEAST. In this case (because we are sampling from the posterior distribution for the age of the root node in the tree) all the trees will have slightly different root ages and thus slightly different total lengths.
What to do with this really depends on the goal of our multi-LTT plot. If we want to represent this uncertainty, as well as the uncertainty of relative branching times, we should really make our multi-LTT plot backwards in time from a constant present-day. This is not presently implemented in phytools ltt, but is the default option (and in fact the only option that works) in ape's mltt.plot. Alternatively, and more commonly (I think), we may wish our LTT plot to primarily represent the variation in relative branching times represented in our posterior sample. To do this, then, we should first rescale all our trees to have the same length. We could rescale our trees to have an arbitrary total length (say 1 or 100), or we might want to rescale our trees to all have the same length that is the average total length of our tree. The following code does the latter:
> require(geiger); require(phytools)
> trees<-pbtree(n=100,nsim=100) # trees with different lengths
> tl<-sapply(trees,function(x) max(nodeHeights(x)))
And the following is a copy of the figure above with this "fix" applied: