PierreBarrat / TreeTools.jl

Tools for handling rooted phylogenetic or genealogic trees with Julia.
https://pierrebarrat.github.io/TreeTools.jl/
MIT License
6 stars 1 forks source link

Sort nodes in alphabetical order if same rank in mcc #29

Closed anna-parker closed 2 years ago

anna-parker commented 2 years ago

This is more just a pet-peeve and not that important. Currently, the ladderize! command will change the order of leaves in mcc clades if they have the same rank in the tree, which is quite confusing. For example: nwk_1 = "(A,(B,C,D,E))" will become nwk_1_ladderize_output= "(A,(E,D,C,B))" after calling ladderize! on the tree.

I found this quite confusing. I initially just wanted nodes to stay the same as in input order but think it might be even nicer if we are anyways sorting them to sort the nodes of same rank in a polytomy by alphabetical order.

I have added a small test. Additionally, I tested it on the NY data set in TreeKnit to make sure this works on large trees.