Re: [R-sig-phylo] getBtimes vs. branching.times

2016-01-14 Thread Yampolsky, Lev
Dear David and Santiago,

Thank you very much! Indeed, tree3$node.label<-tree2$node.label is pretty 
obvious once one figures out the structure of tree!



--
Lev

From: Santiago Sánchez 
<santiago.snc...@gmail.com<mailto:santiago.snc...@gmail.com>>
Date: Thu, 14 Jan 2016 09:48:16 -0700
To: "r-sig-phylo@r-project.org<mailto:r-sig-phylo@r-project.org>" 
<r-sig-phylo@r-project.org<mailto:r-sig-phylo@r-project.org>>, LY 
<yampo...@mail.etsu.edu<mailto:yampo...@mail.etsu.edu>>
Subject: Re: getBtimes vs. branching.times

Dear Lev,

I simple way to do what you request would be to follow this example with your 
data:

> library(ape)
# here I'm creating a random tree with branch lengths
> treeBL <- rtree(10)
> treeBL$edge.length
 [1] 0.59962263 0.76458987 0.48171189 0.26387301 0.76967429 0.42754456
 [7] 0.30173612 0.10535179 0.01769042 0.49671428 0.61575421 0.91297819
[13] 0.52992782 0.68690369 0.35537999 0.56974770 0.97019530 0.49849792
# this would be the tree with the same topology but without branch lengths
> treeNN <- treeBL
> treeNN$edge.length <- NULL
> treeNN

Phylogenetic tree with 10 tips and 9 internal nodes.

Tip labels:
t1, t9, t4, t3, t7, t10, ...

Rooted; no branch lengths.
# create node labels
> treeNN$Nnode
[1] 9
> treeNN$node.label <- paste("n",1:treeNN$Nnode,sep='')
> treeNN$node.label
[1] "n1" "n2" "n3" "n4" "n5" "n6" "n7" "n8" "n9"
> treeNN

Phylogenetic tree with 10 tips and 9 internal nodes.

Tip labels:
t1, t9, t4, t3, t7, t10, ...
Node labels:
n1, n2, n3, n4, n5, n6, ...

Rooted; no branch lengths.
# check if the internal structure of both trees is identical
> identical(treeNN$edge,treeBL$edge)
[1] TRUE
> if (identical(treeNN$edge,treeBL$edge)){
+ newtree <- treeBL
+ newtree$node.label <- treeNN$node.label
}
> newtree

Phylogenetic tree with 10 tips and 9 internal nodes.

Tip labels:
t1, t9, t4, t3, t7, t10, ...
Node labels:
n1, n2, n3, n4, n5, n6, ...

Rooted; includes branch lengths.

Hope this helps.

Cheers,
Santiago

--
Santiago Sánchez-Ramírez
Environmental Genomics Group
Max Planck Institute for Evolutionary Biology
August-Thienemann-Str. 2
24306 Plön
Germany
Website: https://sites.google.com/site/santiagosnchezrmirez/



Message: 1
Date: Wed, 13 Jan 2016 23:39:21 +
From: "Yampolsky, Lev" <yampo...@mail.etsu.edu<mailto:yampo...@mail.etsu.edu>>
To: Emmanuel Paradis <emmanuel.para...@ird.fr<mailto:emmanuel.para...@ird.fr>>, 
"Liam J. Revell"
<liam.rev...@umb.edu<mailto:liam.rev...@umb.edu>>, Dan Rabosky 
<drabo...@umich.edu<mailto:drabo...@umich.edu>>
Cc: "r-sig-phylo@r-project.org<mailto:r-sig-phylo@r-project.org>" 
<r-sig-phylo@r-project.org<mailto:r-sig-phylo@r-project.org>>
Subject: Re: [R-sig-phylo] getBtimes vs. branching.times
Message-ID: 
<d2bc4988.7376e%yampo...@mail.etsu.edu<mailto:d2bc4988.7376e%25yampo...@mail.etsu.edu>>
Content-Type: text/plain; charset="utf-8"

Dear Colleagues,

Thank you very much for your help, it?s all clear now. (I got way more
than I asked for, for example, my trees include only extant taxa). And
yes, branching.times() and getBtimes() return exact same numbers of
course, I just didn?t understand ow indexing works.

Next question, a very simple one again.

I have two newick trees, identical topology. In one I have branch lengths,
in the other I have node names. I would like a tree with both. How do I do
this?

Thanks in advance!

--
Lev Yampolsky

Professor
Department of Biological Sciences
East Tennessee State University
Box 70703
Johnson City TN 37614-1710
Cell 423-676-7489
Office/lab 423-439-4359
Fax423-439-5958

___
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] getBtimes vs. branching.times

2016-01-13 Thread Yampolsky, Lev
Dear Colleagues,

Thank you very much for your help, it’s all clear now. (I got way more
than I asked for, for example, my trees include only extant taxa). And
yes, branching.times() and getBtimes() return exact same numbers of
course, I just didn’t understand ow indexing works.

Next question, a very simple one again.

I have two newick trees, identical topology. In one I have branch lengths,
in the other I have node names. I would like a tree with both. How do I do
this?

Thanks in advance!

-- 
Lev Yampolsky

Professor 
Department of Biological Sciences
East Tennessee State University
Box 70703
Johnson City TN 37614-1710
Cell 423-676-7489
Office/lab 423-439-4359
Fax423-439-5958




On 1/13/16, 4:20 AM, "Emmanuel Paradis" <emmanuel.para...@ird.fr> wrote:

>To pile a little bit more after David's message, ape has the function
>ltt.plot.coords which does the same thing than phytools::ltt but with
>different options, including 'tol' which specifies the tolerance for
>considering a tree as ultrametric or not.
>
>Best,
>
>Emmanuel
>
>Le 13/01/2016 03:29, Liam J. Revell a écrit :
>> Hi Lev.
>>
>> You could also look at ltt in phytools. The object returned has the time
>> of all the events on the tree - including the end of lineages that go
>> extinct before the present. To access these, you can do:
>>
>> obj<-ltt(tree,plot=FALSE)
>> obj$times
>> obj$ltt
>>
>> & to see how these are associated with events, you can do:
>>
>> plot(obj,show.tree=TRUE)
>>
>> All the best, Liam
>>
>> Liam J. Revell, Associate 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 1/12/2016 10:22 PM, Dan Rabosky wrote:
>>>
>>> Dear Lev-
>>>
>>> I don't think branching.times can compute these for non-ultrametric
>>> trees.
>>>
>>> You can do this with package BAMMtools, but you need a "hidden"
>>> internal function. You can access it as
>>>
>>> "BAMMtools:::NU.branching.times"
>>>
>>> It returns branching times relative to the most recently-occurring tip
>>> in the tree. It's a R-based recursion that is a little slower that the
>>> ape function, so it's not recommended as a replacement for
>>> branching.times if you have an ultrametric tree.
>>>
>>> I'm not actively maintaining laser, but getBtimes returns the output
>>> of branching.times after sorting the times and stripping out the node
>>> names (this was useful for something many years ago!). If you plot
>>> sort(getBtimes(x)) and sort(branching.times(x)) they should be
>>>identical.
>>>
>>> ~Dan Rabosky
>>>
>>>
>>>
>>> On Jan 12, 2016, at 7:37 PM, Yampolsky, Lev <yampo...@mail.etsu.edu>
>>> wrote:
>>>
>>>> Dear Colleagues,
>>>>
>>>> Does anyone know what is the difference between ape�s
>>>> branching.times() and laser�s getBtimes()?
>>>> And why they may be giving rather different results, particularly for
>>>> internal branches? (From an ultrametric tree created by
>>>> chronotree <- chronos(tree, lambda = 1, model = "correlated", quiet =
>>>> FALSE, calibration = makeChronosCalib(tree), control =
>>>> chronos.control())
>>>>
>>>> Thank you very much in advance for your help!
>>>>
>>>> PS. A related but less important question: I am curious how does
>>>> branching.times() calculate branching times from a non-ultrametric
>>>>tree?
>>>>
>>>> --
>>>> Lev Yampolsky
>>>>
>>>> Professor
>>>> Department of Biological Sciences
>>>> East Tennessee State University
>>>> Box 70703
>>>> Johnson City TN 37614-1710
>>>> Cell 423-676-7489
>>>> Office/lab 423-439-4359
>>>> Fax423-439-5958
>>>>
>>>> ___
>>>> 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/
>>>
>>> _
>>> Dan Rabosky
>>> Assistant Professor & Curator of Herpetology
>>> Museum of Zoology &
>>> Department of Ecology and Evolutionary Biology
>>> University of Michigan
>>> Ann Arbor, MI 48109-1079 USA
>>>
>>> drabo...@umich.edu
>>> http://www-personal.umich.edu/~drabosky
>>> http://www.lsa.umich.edu/ummz/
>>>
>>>
>>>
>>> [[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/
>>>
>>
>> ___
>> 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/

[R-sig-phylo] extract parent-child from newick

2016-01-12 Thread Yampolsky, Lev
A very simple question: I have a tree with all tips and nodes labeled and I 
want parent-child pairs from it. Looking at tree$edge does not quite help, 
because these parent and child pairs are labeled by the internal index, not IDs 
from the newick file. Looking at tree$tip.label and tree$node.label does not 
help, because these two vectors index tips and nodes separately, so these 
indexes do not correspond to those in tree$edge.

Should be very very obvious how to do it!

Thanks!

--
Lev Yampolsky

Professor
Department of Biological Sciences
East Tennessee State University
Box 70703
Johnson City TN 37614-1710
Cell 423-676-7489
Office/lab 423-439-4359
Fax423-439-5958

___
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] getBtimes vs. branching.times

2016-01-12 Thread Yampolsky, Lev
Dear Colleagues,

Does anyone know what is the difference between ape’s  branching.times() and 
laser’s getBtimes()?
And why they may be giving rather different results, particularly for internal 
branches? (From an ultrametric tree created by
chronotree <- chronos(tree, lambda = 1, model = "correlated", quiet = FALSE, 
calibration = makeChronosCalib(tree), control = chronos.control())

Thank you very much in advance for your help!

PS. A related but less important question: I am curious how does 
branching.times() calculate branching times from a non-ultrametric tree?

--
Lev Yampolsky

Professor
Department of Biological Sciences
East Tennessee State University
Box 70703
Johnson City TN 37614-1710
Cell 423-676-7489
Office/lab 423-439-4359
Fax423-439-5958

___
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] phytools read.newick fails to read edge lengths

2015-02-17 Thread Yampolsky, Lev
Dear Colleagues,

I need to remove singleton nodes from a tree; trying to do it by this script:

require(phytools)
source(read.newick.R)
tree-read.newick(file=tree,tre)
tree-collapse.singles(tree)
plotTree(tree,type=fan)

(https://stat.ethz.ch/pipermail/r-sig-phylo/2013-June/002783.html)

read.newick.R returns warnings that look like this:
1: In getEdgeLength(text, i) : NAs introduced by coercion
(and then the same for every node).
And of course the resulting tree has 0 edge lengths.

Anyone has any idea why this may be happening?

Thank you very much in advance,

Lev Yampolsky

___
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/