# How to extract clusters from a phylogenetic tree?

I am using Biopython Phylo and RDkit Cluster to obtain a UPGMA tree from a distance matrix of 5k x 5k entries. How can I extract clustered entry names given a number of clusters?

For example, Bio.Phylo can return plain-text representation of a tree, so I think I can parse it by the number of tabs:

Phylogeny()
...


or, ASCII format:

          _____________ A
_______|
_|       |_______________________________ B
|
|_______________________________________________________ C


Which, I think is more difficult to parse but possible. Either way, those are not established methods for this kind of task, so I would use a hint.

• Use R (ape etc..) or ETE3 (python), thats the hint
– M__
Dec 15 '20 at 14:31