Hello,
I have three qualitative traits that I would to represent at the tip of a phylogenetic tree.
I've managed to figure out how each trait could be represented by a different shape, but I would also like to be able to select different color palettes for each trait, to make it easier to read the figure.
I suspect the answer lies somewhere with scale_color_manually, but so far I haven't been able to sort it out complete. It looks as if I have to manually specify each color.
Any help to tweak this code would be appreciated.
I've included a figure of the tree i've managed to produce so far, along with my R script, and a sample of the data I'm using.
Thanks in advance!
With best regards,
Edeline
#Import tree file, as well as trait data for tips of tree.
tree2 <-read.beast(file.choose())
dd <- read.csv(file.choose())
p <- ggtree(tree2, ladderize=TRUE) +
# Add posterior probability
geom_text2(aes(subset=!isTip, label=round(as.numeric(posterior),2)),size=1.5, hjust=-.3, vjust=-.5) +
# geom_text2(aes(subset=posterior<0.7, label=round(as.numeric(posterior),2)),size=1.5, hjust=-.3, vjust=-.5) +
# Adds tip labels
geom_tiplab(color="black",size=1.5, offset=3) +
#This ensures that there will be space in the plot.
xlim(0, 80)+
# Adds an axis
theme_tree2() +
# Add point where mezoneuron fossil is MRCA(tre3,mezo) = 324
geom_point2(aes(subset=(node ==324) ),size=2, shape=24, fill="steelblue")
p2 <- p %<+% dd +
geom_tippoint(aes(x=x+0.5,fill = factor(Biome)),shape=21,size=2) +
geom_tippoint(aes(x=x+1.5,fill = factor(Habit)),shape=23,size=2) +
geom_tippoint(aes(x=x+2.5,fill = factor(Geo)),shape=22,size=2)
#uncomment if you want to see the legend + theme(legend.position="right",legend.key.size = ) + scale_color_brewer(palette=2)
#suspect that this is where I would need to use scale_color_manually, but not sure how....
p2