Get all Taxa of internal nodes

34 views
Skip to first unread message

Angela

unread,
Feb 12, 2016, 9:29:57 AM2/12/16
to DendroPy Users
Hi there,

since two days I try to figure out how to

1) print node ages and their 95% confidence intervals and
2) how to print all tip taxa labels assigned to internal nodes.

So far, I could solve the first problem after "downgrading" my DendroPy version but unfortunately, I cannot find any solution to print (not plot!) all taxa assigned to any internal node.

E.g.:

human---------
                     |-------
chimp----------        |
                              |-----------
                              |             |
gorilla-----------------              |-------
                                            |
orang------------------------------


So far, there are no node labels, why DendroPy prints ugly names, like "d4454426256, d4454426260, d4454426298".
Now, I would like to print instead this names, something like: "d4454426256: human, chimp; d4454426260: human, chimp, gorilla; d4454426298: human, chimp, gorilla, orang"

Maybe, someone of you has a solution for me?! I would be very happy :)

Many thanks in advance,
Angela

Jeet Sukumaran

unread,
Feb 16, 2016, 10:36:16 AM2/16/16
to dendrop...@googlegroups.com
It is a shame that you downgraded your DendroPy version.

And a little puzzling, because both (1) and (2) are not only supported
in DendroPy 4, but actually a lot easier to do than in DendroPy 3.

For (2), in DendroPy 4, there are so many ways to skin the cat, so to
speak, depending on what you want, all making using the
DendroPy4-specific nifty and handy "Bipartition" class.

~~~
#! /usr/bin/env python

import dendropy

tree = dendropy.Tree.get(
path="pythonidae.mle.nex",
schema="nexus")
tree.encode_bipartitions()

## Get all taxa as Taxon objects
for nd in tree:

print(nd.bipartition.leafset_taxa(taxon_namespace=tree.taxon_namespace))

## Print taxa names
for nd in tree:
print(", ".join(t.label for t in
nd.bipartition.leafset_taxa(taxon_namespace=tree.taxon_namespace)))

## Print as newick string
for nd in tree:

print(nd.bipartition.leafset_as_newick_string(taxon_namespace=tree.taxon_namespace))
~~~

-- 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