Question: Help with ggtree tip labeling in R
1
gravatar for tpaisie
22 months ago by
tpaisie70
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.5k views
ADD COMMENTlink modified 22 months ago by Joseph Hughes2.6k • written 22 months ago by tpaisie70
3

Have a look the examples available here

ADD REPLYlink written 22 months ago by Sej Modha3.8k
2
gravatar for Joseph Hughes
22 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
print(dd)

Then you associate the data frame with you ggtree object

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

Help
Access

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