Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to collapse low support branches #2

Closed
peterk87 opened this issue Jun 28, 2019 · 1 comment
Closed

Add option to collapse low support branches #2

peterk87 opened this issue Jun 28, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@peterk87
Copy link
Owner

With ete3, it is easy to delete/collapse internal branches based on support value:

from ete3 import Tree, TreeNode

tree = Tree()
A = tree.add_child(name='A', support=100)
A1 = A.add_child(name='A1')
A2 = A.add_child(name='A2')
B = tree.add_child(name='B', support=50)
C = B.add_child(name='C')
D = B.add_child(name='D')
print(tree.get_ascii(show_internal=True))

#       /-A1
#    /A|
#   |   \-A2
# --|
#   |   /-C
#    \B|
#       \-D

# traversing nodes to remove internal nodes with support less than 95
for node in tree.traverse():
    if not node.is_leaf() and not node.is_root():
        if node.support < 95:
            node.delete()
print(tree.get_ascii(show_internal=True))

#       /-A1
#    /A|
#   |   \-A2
# --|
#   |--C
#   |
#    \-D
@peterk87 peterk87 self-assigned this Jun 28, 2019
@peterk87 peterk87 added the enhancement New feature or request label Jun 28, 2019
peterk87 added a commit that referenced this issue Jun 28, 2019
peterk87 added a commit that referenced this issue Jun 28, 2019
…anches

Add feature #2, add option to collapse low support branches and to output modified Newick file
@peterk87
Copy link
Owner Author

Fixed in #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant