Hi April,
Very easily. In fact, it is one of the fundamental components of
DendroPy's architecture that allows trees to be decomposed into splits
that are comparableacross different trees, as long as they share the
same taxon namespace.
Unfortunately, the whole splits mechanism was very much an
"under-the-hood" thing in DendroPy 3. In other words, undocumented.
Which limited what users could do with it without some code inspection
or guidance.
In DendroPy 4, however, splits are very much part of publicly-exposed
datamodel, through the `Bipartition` class:
https://github.com/jeetsukumaran/DendroPy/blob/DendroPy4/doc/source/tutorial/bipartitions.rst
Basically, for what you want to do, once you run ``encode_splits``, the
tree should have a attribute ``split_edges``, which is a dictionary of
the splits in the tree mapped to edges on the tree. So you can just
dereference the node using ``tree.split_edges[split].head_node``. In
DendroPy 4, the previous *should* still work, but with lots of
deprecation warnings, and the preferred approach is
``tree.bipartition_edge_map[b].head_node``.
So, for example, the following code will create a dictionary with keys
being a particular split, and the values being the list of support
values as indicated by node labels from across all trees (CODE IS
UNTESTED --- might have some typos/bugs):
~~~
import collections
import dendropy
trees = dendropy.TreeList.get_from_path(
"trees_with_support_as_labels.nex",
"nexus")
bipartition_labels = collections.defaultdict(list)
for tree in trees:
tree.encode_bipartitions()
for bp in tree.bipartition_edge_map:
node = tree.bipartition_edge_map[bp].head_node
if node.label:
bipartition_labels[bp].append(float(node.label))
for bp, labels in bipartition_labels.items():
print("{:20}:
{}".format(bp.leafset_as_newick_string(trees.taxon_namespace), labels))
~~~
The above code is for DendroPy4 (which I highly recommend you switch
to!), but to you can get the number crunching part to work in DendroPy3
by changing out `encode_bipartitions` for `encode_splits` and
`bipartiton_edge_map` for `split_edges`. Getting the splits represented
as nifty NEWICK strings in DendroPy 3 is also possible, by going through
the TaxonSet function.
Let me know if this works out, or if you have any questions!
-- 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/
--------------------------------------