Re: [R-sig-phylo] Rooting on a node with resolve.root = TRUE

2015-04-07 Thread Emmanuel Paradis

Hi all,

There is indeed a bug in root(), but there seems to be an ambiguity 
which needs to be solved: I think Luiz's command should give an error 
for the reason I try to explain below.


As written in the help page, the option 'node' is an alternative to 
'outgroup':


node: alternatively, a node number where to root the tree (this
  should give the MRCA of the ingroup).

If the tree is unrooted, then at least 3 clades are connected to a 
node (reminder: the tree is eventually unrooted before being 
re-rooted) and thus there are several ways to define the in- and 
outgroups (this is clear when plotting the tree with type = "u"). In 
practice, this is not a problem since the action of root() is, by 
default, to rearrange the edges in order to move 'node' at the base of 
the tree when plotted by default.


If resolve.root = TRUE, then the in- and outgroups must be identified 
more clearly:


 If ‘resolve.root = TRUE’, ‘root’ adds a zero-length branch below
 the MRCA of the ingroup.

So when the tree is plotted, the ingroup and the outgroup are 
effectively sister-clades.


If 'node' is not the current root of the tree, the ambiguity is solved 
arbitrarily by considering the clade on the right of 'node' (when the 
tree is plotted by default) as the ingroup. So these (using Luiz's 
tree) work:


 root(t5, node = 7, resolve.root = TRUE)
 root(t5, node = 8, resolve.root = TRUE)

Thus, I propose the following changes:

1)
 root(phy, node = Ntip(phy) + 1, resolve.root = TRUE)

should return an explicit error.

2) The other cases of root(phy, node = ..., resolve.root = TRUE) may 
still be allowed and the help page should be explicit about this.


I'm not certain about 2): to be consistent this should also return an 
error, but maybe some users use this kind of commands (though I don't 
think this is very common).


All comments welcome!

Best,

Emmanuel

Thu, 19 Mar 2015 15:37:47 -0400 "Liam J. Revell" 
:
Maybe this is obvious, but even though your tree is unrooted, node 6 
is the "root" of the edge matrix for the tree  (i.e., it has the node 
number equal to Ntip(tree)+1) - thus:


t5<-multi2di(t5)

will give you a resolved tree rooted at this node.

There seems to be a bug in root when you try to root an unrooted 
tree at the "root" node (i.e., the node with node number 
Ntip(tree)+1).


All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 3/19/2015 3:12 PM, Luiz Max Carvalho wrote:

Dear phylofolks,

I'm trying to root a tree on an internal (rather than a terminal) 
branch.

Here is a small example:

library(ape)
t5 <- rmtree(N = 1, n = 5, rooted = FALSE)[[1]]
root(t5, node = 6, resolve.root = TRUE)

output:  Error in if (i != N) { : argument is of length zero

root(t5, node = 7, resolve.root = TRUE)

output: Phylogenetic tree with 5 tips and 4 internal nodes.

Tip labels:
[1] "t4" "t3" "t2" "t5" "t1"

Rooted; includes branch lengths.


I don't understand why rooting at node 6 throws an error, while 
using node

7 is fine. What am I missing?

Cheers,

Luiz



___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at 
http://www.mail-archive.com/r-sig-phylo@r-project.org/







___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

Re: [R-sig-phylo] Rooting on a node with resolve.root = TRUE

2015-03-19 Thread Liam J. Revell
Maybe this is obvious, but even though your tree is unrooted, node 6 is 
the "root" of the edge matrix for the tree  (i.e., it has the node 
number equal to Ntip(tree)+1) - thus:


t5<-multi2di(t5)

will give you a resolved tree rooted at this node.

There seems to be a bug in root when you try to root an unrooted tree at 
the "root" node (i.e., the node with node number Ntip(tree)+1).


All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 3/19/2015 3:12 PM, Luiz Max Carvalho wrote:

Dear phylofolks,

I'm trying to root a tree on an internal (rather than a terminal) branch.
Here is a small example:

library(ape)
t5 <- rmtree(N = 1, n = 5, rooted = FALSE)[[1]]
root(t5, node = 6, resolve.root = TRUE)

output:  Error in if (i != N) { : argument is of length zero

root(t5, node = 7, resolve.root = TRUE)

output: Phylogenetic tree with 5 tips and 4 internal nodes.

Tip labels:
[1] "t4" "t3" "t2" "t5" "t1"

Rooted; includes branch lengths.


I don't understand why rooting at node 6 throws an error, while using node
7 is fine. What am I missing?

Cheers,

Luiz



___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] Rooting on a node with resolve.root = TRUE

2015-03-19 Thread Luiz Max Carvalho
Dear phylofolks,

I'm trying to root a tree on an internal (rather than a terminal) branch.
Here is a small example:

library(ape)
t5 <- rmtree(N = 1, n = 5, rooted = FALSE)[[1]]
root(t5, node = 6, resolve.root = TRUE)

output:  Error in if (i != N) { : argument is of length zero

root(t5, node = 7, resolve.root = TRUE)

output: Phylogenetic tree with 5 tips and 4 internal nodes.

Tip labels:
[1] "t4" "t3" "t2" "t5" "t1"

Rooted; includes branch lengths.


I don't understand why rooting at node 6 throws an error, while using node
7 is fine. What am I missing?

Cheers,

Luiz

-- 
Luiz Max Fagundes de Carvalho
PhD student, Institute of Evolutionary Biology,  School of Biological
Sciences,
Ashworth Laboratories, Ash 2, office 123
University of Edinburgh, United Kingdom.
http://br.linkedin.com/pub/luiz-max-carvalho/49/687/283

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/