hi,
I am relatively new to coding in R and trying to make a phylogenetic tree using ggtree.
I am hoping to make a tree with it's branches color coded as per a variable FPR (it is false positive rate, 0-100) and tips color coded with date ("date") and shape (trait). Here is my code:
key <- read.table("data.txt")
tree <- read.tree("tree.nwk")
tree1 <-ggtree(tree, size=1, linetype="solid") %<+% key +
aes(color=FPR) +
scale_color_continuous(name="FPR", limits=c(0,100), low='green', high='red')+
geom_treescale(y= -1, width = 0.01, linesize = 1, color = "black", fontsize = 2, family = "sans")
plot(tree1)
tree1 <- tree1 %<+% key +
geom_tippoint(aes(color=date, shape=as.factor(trait)), position=position_nudge(x=0.006, y=0), size=9)+
scale_color_manual(values=c("#440154", "#481a6c", "#472f7d", "#414487", "#39568c", "#31688e", "#2a788e", "#23888e", "#1f988b", "#22a884", "#35b779", "#54c568", "#7ad151", "#a5db36", "#d2e21b", "#fde725", "#red", "#black", "#green", "#blue"))+
scale_shape_manual(values=c(16,18,1))
plot(tree1)
#######
Using the first part of the code, I managed to get the tree branches color coded according to the variable FPR values but I cannot figure out how to color code the tips using date and trait.
I searched online to see if I can figure out how to fix this, but I couldn't find a solution.
Some guidance on this would be appreciated!!