Hi there,
I am having trouble coloring tiplabels for a splitstree network. Can you help?
my example uses data from phangorn. My script below allows coloring of the network but only if the label is changed (see attached picture). How do I use the original labels that are coloured in the network:
[1] "No305" "No1114S" "No306" "No304" "No0913S" "No1202S" "No0910S" "No0906S" "No1206S"
[10] "No0908S" "No1208S" "No0912S" "No1103S" "No1007S" "No0909S"
Help would be greatly appreciated. I tried contacting Klaus Schliep who wrote the scripts for ggnetworkx, but have not heard back from him yet.
cheers,
Sam Yap
####################################################################
library(ggplot2)
library(ggtree)
library(phangorn)
library(ape)
#scripts from ggnetworx
source("C:/Users/yaps/Downloads/ggnetworx/R/ggnetworx.R")
fdir <- system.file("extdata/trees", package = "phangorn")
Nnet <- read.nexus.networx(file.path(fdir,"woodmouse.nxs"))
df <- data.frame(s=Nnet$translate$label, reg=c(rep("wood",3),rep("mouse",3),rep("wood",3),rep("mouse",3),rep("wood",3)))
Nnet$translate$label <- df$reg
###script here generates the network with color but label is not right
ggplot(Nnet, aes(x, y)) + geom_splitnet() + theme_tree()+
geom_tiplab2(size=1.5) +
scale_color_manual(values=rainbow(2)) +
geom_tiplab2(aes(label=label, color=label))+
theme(legend.position="none")
ggplot(Nnet, aes(x, y)) + geom_splitnet() + theme_tree()+
scale_color_manual(values=rainbow(2)) +
geom_tiplab2(aes(label=label, color=label))+
theme(legend.position="none")
--
1. G Yu*. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics. 2020, 69:e96. https://doi.org/10.1002/cpbi.96
2. LG Wang, TTY Lam, S Xu, Z Dai, L Zhou, T Feng, P Guo, CW Dunn, BR Jones, T Bradley, H Zhu, Y Guan, Y Jiang, G Yu*. treeio: an R package for phylogenetic tree input and output with richly annotated and associated data. Molecular Biology and Evolution. 2020, 37(2):599-603. http://dx.doi.org/10.1093/molbev/msz240
3. G Yu*, TTY Lam, H Zhu, Y Guan*. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution, 2018, 35(2):3041-3043. https://doi.org/10.1093/molbev/msy194
4. G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. https://doi.org/10.1111/2041-210X.12628
5. Book: https://yulab-smu.github.io/treedata-book/
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/3b1ee49e-6fd5-486f-8a02-825706523c42o%40googlegroups.com.