Hi Eliot & Juan.
There is also now an interactive mode for bind.tip. This allows you to
click on a plotted tree & bind a tip to that spot. It otherwise works
the same as the prior CRAN version of bind.tip. To get this
functionality, you need to pull down the latest version of phytools from
GitHub which can be done using the devtools package:
library(devtools)
install_github("liamrevell/phytools")
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 10/30/2015 3:42 PM, Eliot Miller wrote:
What I'm about to describe is essentially an elaborate wrapper for
Liam's bind.tip, so he deserves the credit for figuring this all out.
But if you are interested, I have a small package on GitHub that will
automate this for you. It probably doesn't make much difference with so
few taxa you need to add. If you do want to do it, you would create a
data frame with the first column "species", where you'd list all taxa,
both those in the original tree and those that you want to add. The
second column would be "group". In your case you could just do something
like give the species that are in the tree and those you want to bind to
them the same group name, e.g. "H1". All other species you never wanted
to get a tip bound to them could get some other name, e.g. "nothere".
There are a few options for branch lengths. It looks like you want to
sample from a uniform distribution of min=0 and max=the branch in
question. That is an option on there now too. The package has examples
to explain more. But again, with so few tips you probably want to just
iterate over it like Liam said.
Cheers,
Eliot
On Fri, Oct 30, 2015 at 1:16 PM, Liam J. Revell <liam.rev...@umb.edu
<mailto:liam.rev...@umb.edu>> wrote:
Hola Juan.
position is distance below the specified node (or tip) so it has to
be less than the the length of the edge to which the tip is being
added or else you will get an error. You could modify as follows:
node<-which(tree$tip.label==tip.name <http://tip.name>)
tree<-bind.tip(tree,where=node,position=
runif(n=1)*tree$edge.length[which(tree$edge[,2]==node)])
and iterate it over the tips you want to add.
- Liam
Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>
blog: http://blog.phytools.org
On 10/30/2015 1:03 PM, Juan Antonio Balbuena wrote:
Hello
I need to add branches to a tree at different, predefined tips. For
instance:
th <- rtree(10)
I have an object HP_sim$nameH with the taxa names:
HP_sim$nameH
[1] "H1" "H2" "H3" "H4" "H5" "H6" "H7" "H8" "H9" "H10"
then
th$tip.label <- HP_sim$nameH
In a second object, I have the tips where the branches should be
added:
HP_sim$fai
[1] 1 4 7 9 10
(That is at H1, H4, H7, H9 and H10)
Now I wrote this syntax (where n.fai = 5):
for (i in 1:n.fai) th <- bind.tip(th, HP_sim$nameH[HP_sim$fai[i]],
where =
which(th$tip.label==HP_sim$nameH[HP_sim$fai[i]]), edge.length=
runif(1),
position=runif(1))
However, it doesn't work and get this error:
Error in bind.tree(tree, tip, where = where, position = pp) :
'position'
is larger than the branch length
Any help would be very much appreciated.
Thank you very much for your attention
Juan A. Balbuena
--
Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
University of Valencia http://www.uv.es/~balbuena
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085
<http://www.uv.es/cavanilles/zoomarin/index.htm>http://www.uv.es/cophylpaco
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>
<mailto:j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>>tel. +34
963 543
658 fax +34 963 543 733 <tel:%2B34%20963%20543%20733>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*NOTE!*For shipments by EXPRESS COURIER use the following street
address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto: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
<mailto: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/