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


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

2016-01-12 Thread Klaus Schliep
Dear Lev,

I hope this little example explains it:

tree <- read.tree(text = "((t3:1,t2:1)b:1,t1:2)a;")
par(mfrow = c(1,2))
plot(tree, show.node.label=TRUE)
plot(tree, show.tip.label=FALSE)
nodelabels()
tiplabels()
tree$tip.label
tree$node.label

The tree$tip.label correspond to 1 to the number of tip labels and
tree$node.label to (number of tip labels +1) to (number of nodes) in the
tree$edge matrix.

Regards,
Klaus

On Tue, Jan 12, 2016 at 7:54 PM, Yampolsky, Lev 
wrote:

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



-- 
Klaus Schliep
Postdoctoral Fellow
Revell Lab, University of Massachusetts Boston

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