Thursday, November 8, 2012

Trick to capitalize genus names in a phylogeny

Here's the situation: we have a tree in file or memory in which the genus names of our species binomials are not capitalized. In other words:

> plotTree(tree,ftype="i")

We want a nice plot of this tree, with minimal post hoc editing, but we need the genus names to be capitalized. Here's how to do it:

foo<-function(x){
   x<-strsplit(x,split="")[[1]]
   x[1]<-toupper(x[1])
   x<-paste(x,collapse="")
}
tree$tip.label<-sapply(tree$tip.label,foo,USE.NAMES=FALSE)
plotTree(tree,ftype="i")
That's it.

BTW: I couldn't help but notice that this is my 300th post to the phytools blog! Thanks for reading.

1 comment:

  1. Nice blog man!
    I have a blog about Herpetology and science in general: http://www.projectherps.blogspot.mx/

    ReplyDelete

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