简体   繁体   中英

How to plot trees with introgression using ggtree or Python's ETE toolkit?

I'm migrating a question I asked some days ago in ggtree's google forum . Since SO community is larger and, more importantly, since I have to move on with my project, I'm giving a shot that someone here might have an answer. I'm plotting a phylogenetic tree in which the colour of the branches corresponds to the species. My tree has introgression. That means: All the individuals of the same species may not be connected to a unique node in the tree, but are scattered all around it. To reflect this discrepancy, I want to colour branches grouping a set of individuals that belong to the same species (so call operational taxonomic units or OTUs) until a conflict is found.

For instance, in the following plot (without introgression), t3, t4 and t10 belong to "green" OTU, while t1, t2, t7 and t8 to "red" OTU. Once these differing OTUs hit the same node in the tree, the remaining branches are coloured black.

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")

没有渐渗的情节

This is the behaviour I want for well defined OTUs, unfortunately, once introgression is added to the equation, and individuals of different species are spread throughout the tree, ggtree seems to assign colours to conflicting branches based on some sort of majority consensus (plot to the left). In the following plot, f1, part of species "green", has introgressed with individuals in species "red". Since the node connecting t1 and t2 marks a discrepancy in the phylogeny, I would like colour black the remaining edges until the origin (plot to the 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")

用渐渗的情节 - 糟糕的颜色 具有渐渗的情节 - 正确的颜色

Having the edges after the conflict coloured black is not only awful. Is misleading from a scientific point of view. Is there a way to fix this problem and get the plot on the right?

EDIT -------

If you can do this using Python ETE Toolkit, I'm open to hear from you...

you should tag your post with #ggtree .

already answered in https://groups.google.com/forum/#!topic/bioc-ggtree/Q4LnwoTf1DM .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM