Skip to content

c. Module tree

jaclew edited this page Mar 31, 2025 · 1 revision

The tree-module is used to de-branch and collapse phylogenetic trees. De-branching can be done based on distance and metadata. Branch-nodes with >2 leaf-nodes can be collapsed based on distance and can use metadata to avoid collapsing leaf-nodes that have different classifications. Disclaimer: the input tree below was generated using mash-tree, providing a rough phylogeny with limited accuracy.

De-branch and collapse based on distance

  • De-branch tree based on distance:
tree.py --input test_genomes.dnd --debranch 0.05
  • De-branch tree based on distance and collapse nodes:
tree.py --input test_genomes.dnd --debranch 0.05 --collapse

image
Phylogenetic trees showing the raw tree (left), the de-branched tree (middle), and collapsed tree (right)

De-branch and collapse based on metadata

In this example, metadata will be used to de-branch and collapse the tree. The accession nodes will be annotated using assign to help visualisation.

  • Display the raw tree as family_genus_species_accession-number:
tree.py --input test_genomes.dnd | assign.py --input - --metadata_file metadata.tsv --columns "#family_#genus_#species_#accession"
  • De-branch tree based on genus
tree.py --input test_genomes.dnd --metadata_file metadata.tsv --column genus | assign.py --input - --metadata_file metadata.tsv --columns "#family_#genus_#species_#accession"

  • Collapse tree
tree.py --input test_genomes.dnd --metadata_file metadata.tsv --column genus --collapse | assign.py --input - --metadata_file metadata.tsv --columns "#family_#genus_#species_#accession"

image
Phylogenetic trees showing raw (left) and de-branched tree (right)

image
The final collapsed tree

Clone this wiki locally