Monday, February 1, 2016

Update to dotTree visualization method for non-ultrametric trees & multiple traits

I just posted an update to the new function dotTree that I documented in yesterday's post.

This update comes from two places. First, from the fact that for non-ultrametric trees the visualization using the previous version of dotTree looks kind of weird. For instance:

library(phytools)
tree<-rtree(n=26,tip.label=LETTERS)
x<-fastBM(tree)
dotTree(tree,x)

plot of chunk unnamed-chunk-1

It is not terrible, but it would be better if all the plotted tip states lined up at the same place.

Next, when I posted this to Facebook (and, actually in the original email that inspired this method), there was a request to add multiple traits. Putting these betweem the end of the tip and the tip label seemed pretty impractical.

With these factors in consideration, I decided to try a different internal plotting method - the same one that is used in the phytools function plotting method for objects of class "cophylo" (e.g., here).

This is what that looks like for the same data:

dotTree(tree,as.matrix(x),method="phylogram")

plot of chunk unnamed-chunk-2

Using this method internally & moving the dots to the right of the plotted tip labels also makes it very convenient to show multiple traits, which I also added as a feature. For example:

X<-fastBM(tree,nsim=10)
dotTree(tree,X)

plot of chunk unnamed-chunk-3

Once again, this doesn't look very good for trees with more than 60 or 70 taxa:

tree<-rtree(n=60)
X<-fastBM(tree,nsim=12)
dotTree(tree,X,fsize=0.7,cex=0.7)

plot of chunk unnamed-chunk-4

I should warn that there are certainly some bugs still being worked out (some were discovered in the writing of this post), & feedback on bugs, as well as feedback generally, is welcome.

The easiest way to use this function is to update phytools from GitHub using the devtools package, e.g.:

library(devtools)
install_github("liamrevell/phytools")

No comments:

Post a Comment