Closed codingbutstillalive closed 5 years ago
Your current tree representation in your newick string is unrooted.
I have rearranged it to root it (arbitrarily)
(((((ICE_9:25.0)ICE:25.0,(RE8:25.0,RE5:25.0)RE:25.0,(IC_99:25.0)IC:25.0)DB:25.0)Bahn:25.0,(((Line_12:25.0)Flixbus_Shuttle:25.0,(Line_3P:25.0)Flixbus_Premium:25.0)Flixbus:25.0)Omnibus:25.0)Verkehrsmittel:13.636364,(((Golf_V:25.0,Golf_II:25.0)Golf:25.0,(Polo_III:25.0)Polo:25.0)Volkswagen:25.0,((Quadro:25.0)Audi_A8:25.0,(Quadro_XY:25.0)Audi_A7:25.0)Audi:25.0)Auto:11.363636);
> tr = readNewick("/tmp/test.tree", simplify=FALSE, spacesAsUnderscores=F)
Warning message:
In checkTree(object) : Tree contains singleton nodes.
> rootNode(tr)
<NA>
12
> MRCA(tr, c("Golf", "Polo"))
Volkswagen
24
Thanks a lot for your help. Could you please formally describe the differences of a rooted and unrooted tree in Newick format? I have difficulties to see the difference from the string representation, unfortunately.
Moverover, I do not understand why the rooted tree (as displayed by data.tree) becomes unrooted when I export it to the Newick format. In fact, the current work flow is as follows: read.csv -> data.table -> data.tree -> ToNewick -> readNewick. Thus, the data.tree displayed here is rooted, but its Newick export is suddenly not. That's odd. But I might be missing something important, as I am no expert for Newick format.
EDIT: I checked now the rules for the Newick format from here: http://evolution.genetics.washington.edu/phylip/newicktree.html
According to this, my tree has a proper formatting and it is rooted. To illustrate this, I write it a little bit differently to highlight its structure:
(
(((Golf_V:25,Golf_II:25)Golf:25,(Polo_III:25)Polo:25)Volkswagen:25,((Quadro:25)Audi_A8:25,(Quadro_XY:25)Audi_A7:25)Audi:25)Auto:25,
(((ICE_9:25)ICE:25,(RE8:25,RE5:25)RE:25,(IC_99:25)IC:25)DB:25)Bahn:25,
(((Line_12:25)Flixbus_Shuttle:25,(Line_3P:25)Flixbus_Premium:25)Flixbus:25)Omnibus:25
)Verkehrsmittel;
So, I really don't see why it is not recognized as a rooted tree!
Okay, I now fixed it myself. It seems that one more level was required, i.e. an extra pair of surrounding parantheses plus a branch length, like so:
((
(((Golf_V:20,Golf_II:20)Golf:20,(Polo_III:20)Polo:20)Volkswagen:20,((Quadro:20)Audi_A8:20,(Quadro_XY:20)Audi_A7:20)Audi:20)Auto:20,
(((ICE_9:20)ICE:20,(RE8:20,RE5:20)RE:20,(IC_99:20)IC:20)DB:20)Bahn:20,
(((Line_12:20)Flixbus_Shuttle:20,(Line_3P:20)Flixbus_Premium:20)Flixbus:20)Omnibus:20)
Verkehrsmittel:20);
Okay, at least I solved it.
I am processing a newick string that looks as follows:
((((Golf_V:25,Golf_II:25)Golf:25,(Polo_III:25)Polo:25)Volkswagen:25,((Quadro:25)Audi_A8:25,(Quadro_XY:25)Audi_A7:25)Audi:25)Auto:25,(((ICE_9:25)ICE:25,(RE8:25,RE5:25)RE:25,(IC_99:25)IC:25)DB:25)Bahn:25,(((Line_12:25)Flixbus_Shuttle:25,(Line_3P:25)Flixbus_Premium:25)Flixbus:25)Omnibus:25)Verkehrsmittel;
This corresponds to the following dummy taxonomy of transportation systems (in German: "Verkehrsmittel"):
As a data.tree structure, the tree looks like this:
My final goal is to process that newick string (stored in a file) like this:
So, for some reason, the resulting tree is not rooted. How can I fix this?