evolbioinfo / gotree

Gotree is a set of command line tools and an API to manipulate phylogenetic trees. It is implemented in Go language.
GNU General Public License v2.0
120 stars 15 forks source link

gotree collpase length not working? #12

Open tseemann opened 3 years ago

tseemann commented 3 years ago
cat foo.nwk
((A:0.1,B:0.1),C:0.1);

 gotree collapse length -l 0.2  < foo.nwk
((A:0.1,B:0.1),C:0.1);

I was expecting to see (A:0,B:0,C:0) ?

fredericlemoine commented 3 years ago

I see. First of all, gotree collapse length removes internal branches that are shorter than a given threshold. For example:

$ echo "((A:0.2,B:0.2):0.1,C:0.2,D:0.2);" | gotree collapse length -l 0.2
(C:0.2,D:0.2,A:0.2,B:0.2);
C --0.2-- +       +--0.2-- A     C --0.2-- +  +--0.2-- A
           \     /                          \/
            -0.1-             =>            /\            
           /     \                D --0.2--+  +--0.2-- B
D --0.2--+        +--0.2-- B     

It currently does not remove branches that are connected to the root for rooted tree (root node having degree > 2), because when the root is a polytomy we tend to consider it as unrooted. It is possible to change this behavior though, but will need testing.

fredericlemoine commented 3 years ago

I added options --rootand -tips to collapse brlength, you can have a look at the command documentation. This pre-release implements it. Let me know if it solves your issue.