Monday, February 25, 2013

More on 'untangling' misplotted trees

I just posted a new function, untangle, which attempts to "untangle" branch crossing resulting from bind.tree or other functions.

It has two different methods: method="reorder" and method="read.tree" (as described here), and will also attempt to untangle SIMMAP style trees automatically using reorderSimmap. I've included it in a non-CRAN version of phytools (phytools 0.2-21), which can be downloaded from the phytools website and installed from source. This version also includes an updated version of phenogram.

Here's a quick demo of untangle with SIMMAP style trees:
> install.packages("phytools_0.2-21.tar.gz",type="source", repos=NULL)
* DONE (phytools)
> require(phytools)
Loading required package: phytools
> tree<-add.random(pbtree(n=5),n=45)
> Q<-matrix(c(-1,1,1,-1),2,2)
> rownames(Q)<-colnames(Q)<-c(1,2)
> cols<-setNames(c("blue","red"),c(1,2))
> mtree<-sim.history(tree,Q,anc="1")
> plotSimmap(mtree,cols,pts=F,lwd=3)
> mtree<-untangle(mtree)
> plotSimmap(mtree,cols,pts=F,lwd=3)

That's it.

No comments:

Post a Comment

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