The following code generates a phylo tree, which you can see here:
,
But I have no idea why the tree can't display the color.
coul <- brewer.pal(4, "PuOr");coul
ReSo<-metadata %>% select(c("id","region","source" ));ReSo
colR <- colorRampPalette(coul)(length(unique (metadata_campy$region)));colR
regionCol <- data.frame(colR,ord = unique (metadata_campy$region));regionCol
ReSo$region<-factor(ReSo$region, levels = regionCol$ord);ReSo$region
colorTreeTip = function(tree,metadata_campy,var) {
if(var %in% c("region")){
t<-tree %<+% ReSo + geom_tippoint(mapping =
aes(color = region), size=5, alpha=0.35) +
scale_color_manual(values=regionCol$colR,
drop=FALSE,na.translate = FALSE)+
geom_tiplab(linetype = "dashed",align = TRUE) +
theme(legend.justification = c("right", "bottom"))
;t
}
t + ggexpand(0.3, side = "h")
}
And give the following warning:
Warning: Removed 18 rows containing missing
values(
geom_point_g_gtree()).
Thanks for your help to understand what is wrong.