Question: Help with ggtree tip labeling in R
gravatar for tpaisie
17 months ago by
University of Florida
tpaisie70 wrote:

So I have a nexus tree file with the tips labeled by country. What I would like to do is label the tips of the tree with points color coded by country, like this:

Example photo of what I would like

So this data is in a different class than mine so the code for it won't work. So far I've been using ggtree and geom_tippoint in R to plot my tree and put dots at the tips of the tree, but i can't figure out how to color code them by country. Any help would be great!

ggtree ggplot2 phylogenetics R • 1.8k views
ADD COMMENTlink modified 17 months ago by Joseph Hughes2.6k • written 17 months ago by tpaisie70

Have a look the examples available here

ADD REPLYlink written 17 months ago by Sej Modha3.1k
gravatar for Joseph Hughes
17 months ago by
Joseph Hughes2.6k
Scotland, UK
Joseph Hughes2.6k wrote:

Something like this should work:

tree <- read.tree(text = "(((A,B),(C,D)),E);")
p <- ggtree(tree)

You need to create a data frame that contains the taxa name and the country:

dd <- data.frame(taxa  = LETTERS[1:5], country = c(rep("FRA", 2), rep("UK", 2), rep("USA", 1)))
row.names(dd) <- NULL

Then you associate the data frame with you ggtree object

p <- p %<+% dd + geom_tippoint(aes(color=country))
ADD COMMENTlink written 17 months ago by Joseph Hughes2.6k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1517 users visited in the last hour