Question: Help with ggtree tip labeling in R
gravatar for tpaisie
2.1 years 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 • 2.9k views
ADD COMMENTlink modified 2.1 years ago by Joseph Hughes2.7k • written 2.1 years ago by tpaisie70

Have a look the examples available here

ADD REPLYlink written 2.1 years ago by Sej Modha4.0k
gravatar for Joseph Hughes
2.1 years ago by
Joseph Hughes2.7k
Scotland, UK
Joseph Hughes2.7k 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 2.1 years ago by Joseph Hughes2.7k
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: 1943 users visited in the last hour