Calculating tree diameter
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.
• 1,432 views
•
link
1 answer
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'>
• 1 views
•
link
Log in to answer this question.