Collapsing Branches Of A Tree Which Are Closely Related And Has Support Values <0.5
1
1
Entering edit mode
10.7 years ago
Pappu ★ 2.1k

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.

biopython • 2.3k views
ADD COMMENT
0
Entering edit mode

what do you mean by "collapse"?

ADD REPLY
0
Entering edit mode

I mean hiding the branches will low topological support.

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

I would like to output nexus file. I don't understand ete2 properly.

ADD REPLY
2
Entering edit mode
10.7 years ago

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"
ADD COMMENT

Login before adding your answer.

Traffic: 1739 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