Recently a phytools user contacted me because he was having difficulty reading a tree with bootstrap values as node labels (saved in NEXUS format from the software RAxML) into R.
The ape function
read.nexus reads in a NEXUS tree file, but doesn't handle node annotation.
The phytools function
read.simmap can read in a particular type of annotation created by the
I did suddenly remember that I'd written some code many* years ago (not kidding – 8 years, if you can believe it) to try and read a MrBayes annotated tree in NEXUS format from file. I never finished that code, but realized that I could re-purpose it to read in our RAxML tree.
I just added
this to phytools in the form of
readNexus. Let's give it a try using the phytools user's
originally tree, but with tip labels hidden.
##  '0.7.84'
Now let's plot our tree:
That's pretty hard to read. Let's first ladderize the tree and the show our bootstrap values
using pie-charts instead of numbers. To do that, I will also need to convert my node labels
numeric mode, because they are currently stored as characters.
ladderized<-ladderize(tree) plotTree(ladderized,ftype="i",fsize=0.5,lwd=1, direction="upwards") pies<-cbind( as.numeric(ladderized$node.label)/100, 1-as.numeric(ladderized$node.label)/100) nodelabels(pie=pies,piecol=c("black","white"), cex=0.3) legend(5,0.35,c("0% bootstrap","100% bootstrap"), pch=c(21,21),pt.bg=c("white","black"), cex=0.8,bty="n",pt.cex=1.5)
That's OK, right?