Calculating tree diameter
1
0
Entering edit mode
5.8 years ago
Joe 21k

Hi all,

I'm hoping someone has a 'ready-to-go' one liner or tool suggestion for finding the 2 most distant tips of a binary/phylogenetic tree (a.k.a. its 'diameter')?

The algorithm itself seems straightforward, but I'm almost certain someone would have needed to do this before me.

alignment tree phylogenetics graph theory • 992 views
ADD COMMENT
1
Entering edit mode
5.8 years ago
Joe 21k

Got it :)

Install dendropy and get the max distances in a distance matrix.

import dendropy

tree = dendropy.Tree.get(path='mytree',schema='format')
pdm = tree.phylogenetic_distance_matrix()
m1, m2 = pdm.max_pairwise_distance_taxa()
m1
<Taxon 0x7f8350358c10 'Taxon 1'>
m2
<Taxon 0x7f8350358f90 'Taxon 2'>
ADD COMMENT

Login before adding your answer.

Traffic: 2668 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6