Collapsing Branches Of A Tree Which Are Closely Related And Has Support Values <0.5
I would like to collapse the branches of a tree with topology support of <0.5 and also closely related branches by scripting. Could you tell me how it can be achieved. Here is an example.
(sp|P56726|SMO_MOUSE:0.00978,sp|P97698|SMO_RAT:0.00708,(sp|Q99835|SMO_HUMAN:0.03115,(sp|O42224|SMO_CHICK:0.13084,(sp|P91682|SMO_DROME:1.27659,(tr|Q90YY4|Q90YY4_DANRE:0.00055,tr|Q90X26|Q90X26_DANRE:0.00254)0.997:0.17060)0.982:0.11965)1.000:0.12313)0.990:0.03506);
Thank you.
• 2,678 views
•
link
1 answer
Maybe this example from the ete2 documentation may be useful to you:
from ete2 import Tree
t = Tree("((H:0.3,I:0.1):0.5, A:1, (B:0.4,(C:1,D:1):0.5):0.5);")
# Create a small function to filter your nodes
def conditional_function(node):
if node.dist > 0.3:
return True
else:
return False
# Use previous function to find matches. Note that we use the traverse
# method in the filter function. This will iterate over all nodes to
# assess if they meet our custom conditions and will return a list of
# matches.
matches = filter(conditional_function, t.traverse())
print len(matches), "nodes have ditance >0.3"
# depending on the complexity of your conditions you can do the same
# in just one line with the help of lambda functions:
matches = filter(lambda n: n.dist>0.3 and n.is_leaf(), t.traverse() )
print len(matches), "nodes have ditance >0.3 and are leaves"
• 158 views
•
link
Log in to answer this question.
what do you mean by "collapse"?
I mean hiding the branches will low topological support.
ok, but what is your output? Are you plotting it to a figure? Or printing to the terminal as ASCII characters? Or saving it to a file? Do you have some example code?
I would like to output nexus file. I don't understand ete2 properly.