In that case you used a list to define the OTU. Unfortunately my dataset is to big too to create the list manually and all the members of a species are not connected to the same most common ancestor (due to introgression). For instance, in the previous plot, L,K,J and I could be part of the same species as A,B,C,D,E (an henceforth should be coloured pink), despite G, F and H, a different species, being in the middle.
For now, I'm able to colour my branches (see a closeup of my tree below), but something alike to a majority consensus is applied to resolve conflicting nodes. I'm using the following code to:
groupInfo <- split(tree, data$species)
tree <- groupOTU(tree,groupInfo)
p = ggtree(tree,aes(color=group))
p <- p +
scale_color_manual(values=c("black","chocolate3","darkorange","cadetblue","darkblue","darkgreen","aquamarine","yellow","gray","brown","darkolivegreen4"))
Is is possible to automatize the detection of OTUs in this cases and get black edges when conflicting nodes are found? How?
Thanks!
library(ggtree)
set.seed(123)
tree <- rtree(10)
cls <- list(c1=c("t1", "t2","t8","t7"),
c2=c("t3", "t4", "t10"),
c3=c( "t9","t6","t5"))
tree <- groupOTU(tree, cls)
ggtree(tree, aes(color=group)) + geom_text(aes(label=label)) +
scale_color_manual(values=c("black", "red","green","blue")) + theme(legend.position="right")
library(ggtree)
set.seed(123)
tree <- rtree(10)
cls <- list(c1=c( "t2","t8","t7"),
c2=c("t3", "t4", "t10","t1"),
c3=c( "t9","t6","t5"))
tree <- groupOTU(tree, cls)
ggtree(tree, aes(color=group)) + geom_text(aes(label=label)) +
scale_color_manual(values=c("black", "red","green","blue")) + theme(legend.position="right")
library(ggtree)set.seed(123)tree <- rtree(14)
cls <- list(c1=c("t14","t9","t4"), c2=c("t1","t11","t2"))
tree <- groupOTU(tree, cls)ggtree(tree, aes(color=group)) + geom_text(aes(label=label)) +
scale_color_manual(values=c("black", "red","green")) + theme(legend.position="right")
library(ggtree)set.seed(123)tree <- rtree(14)
cls <- list(c1=c("t14","t9","t4"), c2=c("t1","t11","t2"))
tree <- groupOTU(tree, cls)ggtree(tree, aes(color=group)) + geom_text(aes(label=label)) +
scale_color_manual(values=c("black", "red","green")) + theme(legend.position="right")
library(ggtree)set.seed(123)tree <- rtree(14)
cls <- list(c1=c("t14","t9","t4"),
c2=c("t1","t11"), c3=c("t2","t3"), c4=c("t5","t10"))
tree <- groupOTU(tree, cls)ggtree(tree, aes(color=group)) + geom_text(aes(label=label)) +
scale_color_manual(values=c("black", "red","green","blue","yellow")) + theme(legend.position="right")
The overlap
was introduced to solve conflict issue. For your last plot, there is no conflict exists and groupOTU
do the right thing to traceback from t2 and t3 to their mrca.
In next release, I will introduce another parameter connect = FALSE
(by default) to not trace back t2 and t3 to mrca in the situation we presented in your last plot that the induced graph contains only nodes with degree = 1. If setting connect = TRUE
, it will always trace back to mrca.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/d77fc1ab-8775-49cb-81e7-2db8dcb5941d%40googlegroups.com.--
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+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
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/d77fc1ab-8775-49cb-81e7-2db8dcb5941d%40googlegroups.com.
----~--~---------~--~----~------------~-------~--~----~Guangchuang Yu PhDPostdoc researcher
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong KongHong Kong SAR, China-~----------~----~----~----~------~----~------~--~---
--
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. doi:10.1111/2041-210X.12628
Homepage: https://guangchuangyu.github.io/software/ggtree
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/0313d571-98f5-48e0-8790-0a13718cbcc6%40googlegroups.com.
Hello,
I am encountering the problem of traceback to mrca despite setting "overlap='abandon'" and "connect = F".
You can see some of the branches labeled green that should be labeled gray in the attached snapshot of the tree.
groupInfo <- split(TREE2$tip.label, substr(TREE2$tip.label, start = 1, stop = 4))
TREE3 <- groupOTU(TREE2, groupInfo, overlap='abandon', connect=F)
ggtree(TREE3, aes(color=group), layout='circular', size=0.75) + geom_treescale(x=5.5,y=1,fontsize = 6,color="gray87",linesize=1,offset=5) + theme(panel.background=element_rect(fill="gray20")) + geom_tiplab(size=2,aes(angle=angle),align=T,linesize=0.5,offset=1) + scale_color_manual(values=c("gray87","red", "yellow", "magenta", "green"))
yes
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-...@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/0313d571-98f5-48e0-8790-0a13718cbcc6%40googlegroups.com.