Collapsing clades to a single branch

27 views
Skip to first unread message

Yan Wong

unread,
Aug 19, 2015, 4:52:53 AM8/19/15
to DendroPy Users
Hi,

I feel this should be trivial, but oddly I can't work out how to do it (or indeed find any GUI software that will do this, hence turning to dendropy).

With a tree with named nodes, say ((A,B)C,(D,E)F); I simply want to collapse a selected clade (e.g. C) so that it becomes (C,(D,E)F). It's easy to find node C, but how do I prune its children and turn C into the new (named) leaf?

Cheers

Yan

Jeet Sukumaran

unread,
Aug 19, 2015, 11:42:19 AM8/19/15
to dendrop...@googlegroups.com

``Node.clear_child_nodes()`` simply clears the contain of child nodes
belong to a node. No other operations are performed.

As far as naming, you will need to create a new Taxon object with the
label "C" and associate it with the node. Alternatively, if you just
want a label, you can assigned "C" to the label property. But note that
this is semantically distinct from having a taxon of that label
associated with the node, which is presumably what you have in the other
leaves.

Note that no edge length adjustment will be performed (so, if the tree
was originally ultrametric, it will no longer be so after this
operation: C will maintain its original internal node height). For logic
to add this, see ``Node.remove_child(x)``. I can see a need for adding
the edge length adjustment as an option to ``clear_child_nodes()``. Will
add it to the library.

-- jeet
> --
> You received this message because you are subscribed to the Google
> Groups "DendroPy Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dendropy-user...@googlegroups.com
> <mailto:dendropy-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--



--------------------------------------
Jeet Sukumaran
--------------------------------------
jeetsu...@gmail.com
--------------------------------------
Blog/Personal Pages:
http://jeetworks.org/
GitHub Repositories:
http://github.com/jeetsukumaran
Photographs (as stream):
http://www.flickr.com/photos/jeetsukumaran/
Photographs (by galleries):
http://www.flickr.com/photos/jeetsukumaran/sets/
--------------------------------------

Reply all
Reply to author
Forward
0 new messages