Question: Collapsing Branches Of A Tree Which Are Closely Related And Has Support Values <0.5
1
gravatar for Pappu
7.0 years ago by
Pappu1.9k
Pappu1.9k wrote:

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 • 1.7k views
ADD COMMENTlink modified 6.9 years ago by Biostar ♦♦ 20 • written 7.0 years ago by Pappu1.9k

what do you mean by "collapse"?

ADD REPLYlink written 7.0 years ago by Giovanni M Dall'Olio27k

I mean hiding the branches will low topological support.

ADD REPLYlink written 7.0 years ago by Pappu1.9k

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 REPLYlink written 7.0 years ago by Giovanni M Dall'Olio27k

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

ADD REPLYlink written 7.0 years ago by Pappu1.9k
2
gravatar for Giovanni M Dall'Olio
7.0 years ago by
London, UK
Giovanni M Dall'Olio27k wrote:

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 COMMENTlink written 7.0 years ago by Giovanni M Dall'Olio27k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1185 users visited in the last hour
_