Add annotation to ggtree in R

149 Views Asked by At

My goal is to draw a tree and add some annotation in a table next to the tree. I'd like to add both colors and text (the given data is in a dataframe).

I was able to draw the tree and the labels, but can't work out how to add the table. Is there a solution?

Here is my current code producing the tree:

library("ggtree")
library("ggplot2")
library("phytools")
tree2<-read.newick(text="(A,((B,((C,D),E)),(F,G)));")
tree_fig <- ggtree(tree2, branch.length = "none") +  geom_tiplab()
p <- plot(tree_fig)

I want to achieve roughly the following image (but with aligned labels and colors)

enter image description here

0

There are 0 best solutions below