Simulating non-ultrametric trees

6 views
Skip to first unread message

sophie....@googlemail.com

unread,
Oct 26, 2018, 6:22:21 AM10/26/18
to DendroPy Users
I'm trying to use dendropy to "build a tree programmatically" as described in (https://dendropy.org/primer/trees.html#building-a-tree-programmatically). This is my current toy example:

import dendropy

taxon_namespace = dendropy.TaxonNamespace(["1","2"])
tree = dendropy.Tree(taxon_namespace=taxon_namespace)
tree.seed_node.location = None
tree.seed_node.annotations.add_bound_attribute("location")
tree.seed_node.location = 1

ch1 = dendropy.Node(edge_length=0.5)
ch1.location = None
ch1.annotations.add_bound_attribute("location")
ch1.location = 1
tree.seed_node.add_child(ch1)
ch1.taxon = taxon_namespace.get_taxon('1')

ch2 = dendropy.Node(node_age=1.5)
ch2.location = None
ch2.annotations.add_bound_attribute("location")
ch2.location = 0
tree.seed_node.add_child(ch2)
#ch2.taxon = taxon_namespace.get_taxon('2')

ch3 = dendropy.Node(node_age=1.5)
ch3.location = None
ch3.annotations.add_bound_attribute("location")
ch3.location = 0
ch2.add_child(ch3)
ch3.taxon = taxon_namespace.get_taxon('2')

print(tree.as_ascii_plot())

I get an ultrametric tree, even though the height of leaf 1 should be 0.5 and leaf2's height should be 3.

How could I change this behaviour, s.t. I can output nexus trees, which are non-ultrametric?











Reply all
Reply to author
Forward
0 new messages