Thursday, July 9, 2015

New feature in LTT plotter to overlay plotted tree

I just posted a version of the function ltt (Lineage-Through-Time) that permits the user to automatically overlay the phylogeny on a lineage through time plot. I wrote about how to do this manually in a previous post. This update is part of a new version of phytools, phytools 0.4-60, which has been submitted to CRAN - but for now can also be downloaded and installed from source from the phytools page.

Here is a demo of how it works:

library(phytools)
packageVersion("phytools")
## [1] '0.4.60'
tree<-pbtree(n=26,tip.label=LETTERS)
## simulated tree:
plotTree(tree)

plot of chunk unnamed-chunk-1

obj<-ltt(tree,plot=FALSE)
## object of class "ltt"
obj
## Object of class "ltt" containing:
## 
## (1) A phylogenetic tree with 26 tips and 25 internal nodes.
## 
## (2) Vectors containing the number of lineages (ltt) and branching times (times) on the tree.
## 
## (3) A value for Pybus & Harvey's "gamma" statistic of -1.0815, p-value = 0.2795.
## regular ltt plot
plot(obj)

plot of chunk unnamed-chunk-2

## overlay tree on plot
plot(obj,show.tree=TRUE)

plot of chunk unnamed-chunk-3

That's all there is to it. At present I don't have it set up to change the color of the tree - however, there is an option to increase or decrease the transparency:

plot(obj,show.tree=TRUE,transparency=0.2)

plot of chunk unnamed-chunk-4

That's it for now. Stay tuned for another post detailing the updates in the latest phytools version.

No comments:

Post a Comment

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