tjunier / newick_utils

shell tools for processing phylogenetic trees
Other
101 stars 31 forks source link

can node labels be parsed as support values for tree rooting purposes? #15

Open jhcepas opened 8 years ago

jhcepas commented 8 years ago

Hi there, I have recently expanded the analysis by Czech and Stamatakis regarding branch support mapping after tree rooting in tree viewers, and found that some phyloinformatics toolkits might also miss an option to interpret node labels as branch support values. This is problematic when using toolkits to reroot trees produced by common software such as raxml, phyml, fasttree, iqtree, etc...

@lczech, @stamatak and I are now working on reporting/confirming this in different toolkits. Current tests are here: https://github.com/jhcepas/test_branch_support_after_tree_rerooting

does nw-utils have an option to parse node labels as branch supports, so they are correctly remapped to relevant branches after tree rooting? thanks!

tjunier commented 8 years ago

Yes, it's option -s to nw_reroot. Actually I must thank you for asking this question, because I had completely forgotten I had implemented this feature (I also forgot to document it in the manual :-( ); had I not checked in the code to be sure, I'd had answered, incorrectly, no.

To see it, let's show support values in the edges (since support is basically for a bipartition, hence more a property of an edge than of a node). Taking the tree you use in the tests, before rerooting:

$ nw_topology - <<< "((C:1.0,D:1.0)10:0.001,(A:1.0, (B:1.0,X:1.0)30:0.01)20:0.1,E:1.0)0:0.0;" | nw_display -I m -           
                          /--------------------------------------------------+ C
 /------------10----------+                                                     
 |                        \--------------------------------------------------+ D
 |                                                                              
 |                        /--------------------------------------------------+ A
 |                        |                                                     
=+-0----------20----------+                         /------------------------+ B
 |                        \------------30-----------+                           
 |                                                  \------------------------+ X
 |                                                                              
 \---------------------------------------------------------------------------+ E

We see e.g. that the edge that connects the (B,X) node to the rest of the tree has a support value of 30. Now, if we reroot "naively", we get:

$ nw_reroot - <<< "((C:1.0,D:1.0)10:0.001,(A:1.0, (B:1.0,X:1.0)30:0.01)20:0.1,E:1.0)0:0.0;" X | nw_topology - | nw_display -I m -   
 /---------------------------------------------------------------------------+ X
 |                                                                              
=+              /------------------------------------------------------------+ B
 |              |                                                               
 \-------30-----+              /---------------------------------------------+ A
                |              |                                                
                \-------20-----+                              /--------------+ C
                               |               /------10------+                 
                               \-------0-------+              \--------------+ D
                                               |                                
                                               \-----------------------------+ E

which is wrong, because the edge that connects (B,X) to the rest of the tree now has a support value of 20 (because the support values stayed with the nodes). However, with option -s, we obtain this:

$ nw_reroot -s - <<< "((C:1.0,D:1.0)10:0.001,(A:1.0, (B:1.0,X:1.0)30:0.01)20:0.1,E:1.0)0:0.0;" X | nw_topology - | nw_display -I m -
 /---------------------------------------------------------------------------+ X
 |                                                                              
=+              /------------------------------------------------------------+ B
 |              |                                                               
 \--------------+              /---------------------------------------------+ A
                |              |                                                
                \-------30-----+                              /--------------+ C
                               |               /------10------+                 
                               \-------20------+              \--------------+ D
                                               |                                
                                               \-----------------------------+ E

which I'd argue is more correct since we again have a support value of 30 for the edge that connects (B,X) to the rest of the tree.

Thomas

lczech commented 8 years ago

Thanks @tjunier for checking!

You are right, support values are properties of the branches/bipartitions, so the second way of re-rooting is correct. Nice to see that nw-tools treats this correctly!

jhcepas commented 8 years ago

great! Thanks @tjunier, we will update our tests and manuscript to mention that this is now possible.

mayaschroedl commented 4 years ago

Hi! Is the "-s" option still available for nw_reroot? I cannot find it in the newest version.