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.
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?
You have an example here: http://ete.cgenomics.org/doc/2.1/tutorial/tutorial_drawing.html#node-backgrounds
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.
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()]
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.