Thursday, March 26, 2015

Interactive tree plotter to collapse & expand subtrees in R

I just posted some code to do a visualization in R in which we can, interactively, succcessively expand and collapse (to its ancestral node) any subtree of the phylogeny.

Since this is an interactive, animated exercise, it probably makes more sense for me to illustrate how it works with a screenshot video, but the code below illustrates the set up for the video demo.

library(phytools)
packageVersion("phytools")
## [1] '0.4.50'
tree<-pbtree(n=64,scale=1)
foo<-function(i,sep="._") paste(c(sample(LETTERS,1),sep,
    sample(letters,6)),collapse="")
tree$tip.label<-sapply(1:Ntip(tree),foo)
## do not run
# pruned<-collapseTree(tree)

Here is a video screeshot of the demo:

I should mention that this function is inspired by (as well as somewhat of a poor man's copy of) the interactive tree plotter on Gavin Naylor's amazing website sharksrays.org. Even if you have no interest in this tree plotter, the website is really neat so I'd encourage you to check it out.

This function is in a new non-CRAN version of phytools.

Feedback welcome.

No comments:

Post a Comment

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