Tuesday, April 8, 2014

New options & methods for ltt95

A couple of days ago I received the following comment about the phytools function ltt95:

"I'm using ltt95 function with the times method and log transformed y axis, but I get reversed ages (both in the plot and in the results table). I’ve not been able to tackle down this small issue."

Well, this isn't precisely a bug of ltt95. ltt95 merely records the accumulation of lineages forward in time from the root; rather than backward (as I believe is more common in publications) from the present time.

In a newly updated version of the function I have now added the argument xaxis which can assume three values: "standard" (forward in time lineage accumulation, as in the current CRAN version of phytools); "flipped" (the time-from-the-present plot); and "negative" (similar to "flipped", but with negative time from the present). At the same time I also have modified ltt95 to return an object of class "ltt95" invisibly (don't worry, this is just the same matrix with some attributes); and I have added S3 generic plotting & print methods for objects of this class.

Here's a demo - but the function can be used in more diverse ways than I will demonstrate here:

> library(phytools)
Loading required package: ape
Loading required package: maps
Loading required package: rgl
> packageVersion("phytools")
[1] ‘0.4.0’
> ## simulate some trees
> trees<-pbtree(n=100,scale=50,nsim=100)
> trees
100 phylogenetic trees
> ## run ltt95
> obj<-ltt95(trees)
> ## ok, now let's flip the axis & plot on semi-log
> ## (I could have done this originally too)
> obj
Object of class "ltt95".
  alpha:        0.05
  method:       lineages
  mode:         median
  N(lineages):  100
> plot(obj,xaxis="flipped",log=TRUE)

Code for this new function version is here and it is in a phytools build, which can be downloaded & installed from source.

That's all for now.

No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.