This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How do I annotate a tree with boostrap scores and color code clades in ggtree?

I want to annotate a phylogenetic tree with bootstrap and add color to certain clades in ggtree. Something goes wrong when I try to do both, which has something to do with the indices of the internal nodes.

Here is a random tree with 24 tips:

 library(ape)
 set.seed(123)
 rtree <- rtree(24)

The following identifies the nodes to which I want to assign different colors:

rtree.clade <- groupClade(rtree, c(44, 37, 29))

These are the bootstrap scores:

rtree.bs <- c(1000,  918,  966,  997,  661,  631,  711, 1000,  980,  991,  999,  998, 1000, 1000,  990, 1000,  980, 1000, 
899, 755, 654, 908, 334)

In the following two trees, the bootstrap scores do not show up on the same nodes:

#Tree with color added to clades
library(ggtree)
ggtree(rtree.clade, aes(color = group)) +
geom_tiplab() +
geom_nodelab(label = rtree.bs,
           geom = 'label')
#Tree with no color
ggtree(rtree.clade) +
geom_tiplab() +
geom_nodelab(label = rtree.bs,
           geom = 'label')

In the tree without color, the bootstrap scores have been assigned to the correct nodes. It is the tree with color that is incorrect. What am I doing wrong?

r bootstrap ggtree phylogenetics

1 answer

see an example in https://yulab-smu.github.io/treedata-book/chapter2.html#data-integration for integrating bootstrap value.

For data integration, we have published a paper, https://academic.oup.com/mbe/article/35/12/3041/5142656, with lots of examples in the supplemental files.

Log in to answer this question.