Question: Unrooting Trees Help
2
gravatar for dani.boobyer
6.1 years ago by
dani.boobyer40
St Andrews
dani.boobyer40 wrote:

Hi,

I need to unroot trees which are in Newick format (saved as .txt files). What's the easiest way to do this please? Ideally a method which makes it easy to unroot a large number of tree files.

Thanks for your help, Dani.

phylogeny tree • 6.2k views
ADD COMMENTlink modified 6.0 years ago by aidan-budd1.9k • written 6.1 years ago by dani.boobyer40
6
gravatar for David W
6.1 years ago by
David W4.7k
New Zealand
David W4.7k wrote:

In R, using the library ape

tr <- read.tree("tree.txt")
unrooted_tr <- unroot(tr)
write.tree("tree_unrooted.txt")

If you have a lot of trees in a list, your can use lapply to unroot them all at once:

write.tree(lapply(trees, unroot), "trees_unrooted.tr")

There is also a function, is.rooted to check everything has worked as expected.

ADD COMMENTlink written 6.1 years ago by David W4.7k

typo? write.tree(unrooted_tr, "tree_unrooted.txt")

ADD REPLYlink written 11 months ago by al-ash100
6
gravatar for aidan-budd
6.0 years ago by
aidan-budd1.9k
Germany
aidan-budd1.9k wrote:

Note that NEWICK format intrinsically describes trees as rooted, see the links to a description of the NEWICK format described in an answer to this post Are there multiple ways to write the same unrooted tree using Newick format?

Thus (a,b,c) could be considered as describing a rooted tree which has a trifurcation at its root.

However, many software packages use a convention which says something like "if the root of the tree, as specified in the NEWICK format, is trifurcating, and all the other nodes in the tree are bifurcating, the tree string is assumed to described an unrooted bifurcating tree"

RETREE from the PHYLIP package can be used (I'm fairly sure... haven't done this in a while) to script the conversion to unrooted trees.

ADD COMMENTlink modified 6.0 years ago • written 6.0 years ago by aidan-budd1.9k
2

Good point - apeuses the tri-furcating convention when it writes unrooted trees, but it's worth remembering it's only a convention and might lead to unexpected behavior in some software

ADD REPLYlink modified 6.0 years ago • written 6.0 years ago by David W4.7k
1

I always use retree in my scripts to re-root/unroot trees for analysis. It's quick and easy to do programatically. And yes, NEWICK does intrinsically write unrooted trees as rooted with a random/quasi-random trifurcation at the root which is important to keep in mind.

ADD REPLYlink written 6.0 years ago by Dan Gaston7.1k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1334 users visited in the last hour