Saturday, August 8, 2015

Update to cladelabels: Horizontal labeling & better label position using adj instead of pos

I just updated the phytools function cladelabels to allow the text of clade labels to be plotted horizontally instead of rotated 90 degrees to be plotted with a vertical orientation (the default). I did this for the tree from an empirical project underway in my lab in which (on the scale the tree was being plotted) the size of one of the clades we wanted to demarcate did not allow for enough space for the desired text of the clade label.

I also switched from using pos to specify the text position in the base graphics function text to adj - which seems to work better in centering the text on the clade label.

Here is a quick example to demo the modification to the function:

set.seed(213)
tree<-rtree(n=100)
h<-max(nodeHeights(tree))
plotTree(tree,lwd=1,fsize=0.6,xlim=c(0,1.2*h))
cladelabels(tree,node=169,text="clade 1")
cladelabels(tree,node=141,text="clade 2")
cladelabels(tree,node=126,text="clade 3",orientation="horizontal")

plot of chunk unnamed-chunk-1

I have added this update to a new version of phytools (phytools 0.4-64) which can be downloaded & installed from source - and it will also be in the next CRAN version of the package.

No comments:

Post a Comment

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