PoonLab / clmp

Genetic clustering with Markov-modulated Poisson processes
https://shiny.filogeneti.ca/clmp/
GNU General Public License v3.0
1 stars 2 forks source link

ape thinks RAxML trees are rooted #45

Open ArtPoon opened 5 years ago

ArtPoon commented 5 years ago
> t1 <- read.tree('RAxML_bestTree.fastTrans_9.raxml')
> is.rooted(t1)
[1] TRUE

but BioPython disagrees:

>>> from Bio import Phylo
>>> t = Phylo.read('RAxML_bestTree.fastTrans_9.raxml', 'newick')
>>> t.rooted
False
ArtPoon commented 5 years ago

This is a problem with the ape package, but I'm noting it here for future reference.
We can't simply work around the is.rooted function:

.is.rooted_ape <- function(phy, ntips)
{
    if (!is.null(phy$root.edge)) return(TRUE)
    if (tabulate(phy$edge[, 1])[ntips + 1] > 2) FALSE else TRUE
}

because the root.edge attribute is set by read.tree.

ArtPoon commented 5 years ago

Minimal example:

> t1 <- read.tree(text="((A:1,B:1):1,C:1,D:1);")
> t1

Phylogenetic tree with 4 tips and 2 internal nodes.

Tip labels:
[1] "A" "B" "C" "D"

Unrooted; includes branch lengths.
> t1 <- read.tree(text="((A:1,B:1):1,C:1,D:1):0;")
> t1

Phylogenetic tree with 4 tips and 2 internal nodes.

Tip labels:
[1] "A" "B" "C" "D"

Rooted; includes branch lengths.
ArtPoon commented 5 years ago

See also this thread: https://groups.google.com/forum/#!topic/raxml/tybTbgZmazk

ArtPoon commented 5 years ago

I don’t think this is a problem with ape - RAxML seems to be sticking an extra branch of length zero as a suffix on the tree string