Colored Background Of A Phylogenetic Tree
0
3
Entering edit mode
11.9 years ago
Pappu ★ 2.1k

I am trying to color the backgroud of a bubble tree using ETE2 in python. However I am not sure how to color the background like this: http://ete.cgenomics.org/ I can color the background by iterating over each node using traverse() and assigning a random color. I am wondering how to assign a common color to a set of nodes originating from the same branch. Any suggestion will be appreciated.

python • 4.0k views
ADD COMMENT
1
Entering edit mode

While this is fairly easy to do in some other tree editors like Figtree, I'm not sure how exactly to do this in ETE. What have you tried? Could you post the problematic python code here? Have you tried the ETE google groups forum first?

ADD REPLY
0
Entering edit mode
ADD REPLY
1
Entering edit mode

I have already seen it. But the problem is that how can I select a common branch of an input tree to iterate over them? For example, t = Tree("((((a1,a2),a3), ((b1,b2),(b3,b4))), ((c1,c2),c3));") n1 = t.getcommonancestor("a1", "a2", "a3") t[0] or something like that does not work.

ADD REPLY
1
Entering edit mode

I don't know if I'm understanding you correctly, but to iterate over the nodes under the "common branch" you can use the same tools as for the whole tree:
common = t.getcommonancestor("a1", "a2", "a3"); nodesinbranch = [node for node in common.traverse()]

ADD REPLY
1
Entering edit mode

Thanks for your comments. I manged to do it by iterating over t.children several times. I should have read the manual more carefully before posting.

ADD REPLY

Login before adding your answer.

Traffic: 1750 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6