Hi there,
Not sure if this is the right channel. I wish to draw a splitstree network with both coloured tippoints and coloured labels. The code below managed to color the labels according to latitude values correctly but I just could not figure out how to make geom_tippoint assign colours correctly. Can you please help?
Nnet <- read.nexus.networx("C:/Users/yaps/Desktop/test_SPLITSTREE_test.nex")
metada <- data.frame(name = Nnet$tip.label,
lat=c(-38,-36,-32,-28,-25), #labels to be coloured by latitude
bins=c(rep(1, 3), rep(2,2)), #tippoints based on this, to simplify metada$colour shows the colours for the tippoints
colour=c("orange","orange","
orange ","purple","
purple"))
metada2 <- metada[order(metada$name),]
library(RColorBrewer)
pal = colorRampPalette(c("blue", "red"))
metada2$order = findInterval(metada2$lat, sort(metada2$lat))
p <- ggsplitnet(Nnet) +
geom_tiplab2(aes(col=label), hjust=-.1)+
scale_color_manual(values=pal(nrow(metada2))[metada2$order]) + #this is to colour the tip labels
theme(legend.position="none")
###using this, the labels are not coloured correctly (Rplot.png vs the correct one)
p +
geom_tippoint(col=metada2$colour, size=3)
###I tried grepl too, but the error says not enough colours
p +
geom_tippoint(aes(col=grepl("AA",metada2$name)))