The other day I received the following email:
“I am playing around with the new arc.cladelabels
function. Is
it possible to add in options for color and line thickness. I see it calls
draw.arc
internally so I am assuming it would just be a matter of
adding the options "col"
and "lwd"
in the function?
It would be useful to have alternating or different colors and/or line widths
for when you are labeling all clades in the tree and there is not much space
between the arcs.”
Indeed, these are relatively simple options to add, which I have just done on GitHub. I also added an additional option which is to specify the node corresponding to the common ancestor of the clade to be labeled interactively.
The latter option is hard to demonstrate (absent a video); however the former options work as follows:
library(phytools)
tree
##
## Phylogenetic tree with 200 tips and 199 internal nodes.
##
## Tip labels:
## t7, t23, t24, t126, t127, t35, ...
##
## Rooted; includes branch lengths.
plotTree(tree,type="fan",lwd=1,ftype="off")
nodes
## [1] 203 215 264 288 323 356
text<-paste("Clade",LETTERS[1:length(nodes)])
text
## [1] "Clade A" "Clade B" "Clade C" "Clade D" "Clade E" "Clade F"
library(RColorBrewer)
cols<-brewer.pal(length(nodes),"Accent")
nulo<-mapply(arc.cladelabels,text=text,node=nodes,col=cols,
MoreArgs=list(mark.node=FALSE,lwd=6))
This function version should be obtained by installing the latest development version of phytools from GitHub.
Hello Liam,
ReplyDeleteI have been using 'cladelabels' and want to annotate the tree using multiple colors. Is this applicable to that function as well? When I tried something similar I got an error saying that I have 'unused arguments', which makes me think that that is not the case. I also want to increase the width of lines as in the former example. Thank you very much in advance for any suggestions.
Best,
Laura
Is there a way to adjust the color of the plotted clade names as well, such that the label for, say, Clade A in the above example is green as well?
ReplyDelete