This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Prevent Neighbour-Joining Resulted Negative Branch Length For Phylogenetic Tree Drawing?

Hi, I was using rapidNJ to perform neighbour-joining but it gave me a couple of nodes with negative branch length. Is there any way I can fix it? If rapidNJ won't do it, do you have any recommended program to do a better job? Thanks.

phylogenetics

1 answer

Negative branch lengths are possible in theory and might occur in the output of other programs (e.g. FastTree) as well. See the short section on negative branch lengths here for example. If your downstream analysis requires non-negative branch-lengths, a quick hack is to replace negative entries with zero (even though in theory you should add the difference to the adjacent branch length). The following should do (untested!):

sed -e 's,:-[0-9\.]\+,:0.0,g' in.tree > out.tree

Andreas

Correct answer, but no upvote?

this answer gave me confidence on my results. But no better alternative solution and the sed command doesn't add the difference to the adjacent branch length. sorry for my strictness. ;P

You had a problem and I gave you an answer plus a solution. Not a really encouraging reply.

Log in to answer this question.