Look at reorder.phylo() in ape and reorder() in phylo4: your desired tip
order may be there.

Best,
Brian

_______________________________________
Brian O'Meara
Assistant Professor
Dept. of Ecology & Evolutionary Biology
U. of Tennessee, Knoxville
http://www.brianomeara.info

Postdoc collaborators wanted: http://nimbios.org/postdocs/
Calendar: http://www.brianomeara.info/calendars/omeara

On Wed, Oct 8, 2014 at 4:45 AM, Juan Antonio Balbuena <[email protected]>
wrote:

>  Hello
> I am working on a simulation that requires adding a number of random tips
> to multiple phylogenies:
>
> treeP <- read.nexus(file= "my file.tre") # 5K trees used to build a
> consensus tree (treeP is thus a multiPhylo object)
> NT = 30 # number of taxa in phylogeny
> N.dup = 3 # number of tips (duplications) I want to add to the trees
> sites <- sort(sample(1:NT, N.dup), decreasing=TRUE) # Random tips to
> duplicate
> dup.labels <- treeP[[1]]$tip.label[sites]
> treeP <- .uncompressTipLabel(treeP)
> #
> # Add duplicates to branches following a Liam Revell recipe published in
> his blog:
> #
> for (n in 1:length(treeP)) {
>   for (i in 1:N.dup ) {
>     pos <- runif(n=1)*
> treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
>     edl <- runif(n=1)*
> treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
>     treeP[[n]] <- bind.tip(treeP[[n]], tip.label=paste(dup.labels[i], 1,
> sep="."),
>                            edge.length=edl, where=sites[i], position=pos)
>   }
> }
> #
> treeP<- .compressTipLabel(treeP)
> # Check tip labels:
> treeP$tip.label
> $tip.label
>  [1] "S24"   "S25"   "S9"    "S15"   "S3"    "S21"   "S12"   "S17"
> "S19"   "S30"   "S22"   "S4"    "S16"   "S27"   "S10"   "S23"   "S1"
> "S2"    "S14"
> [20] "S6"    "S8"    "S26"   "S29"   "S13"   "S20"   "S7"    "S28"
> "S18"   "S5"    "S11"   "S18.1" "S20.1" "S16.1"
>
> When I plot any tree in treeP, S18.1, S20.1 and S16.1 appear together with
> S18, S20 and S16, as intended. So why are they at the end of the array
> above? This behaviour makes makes my life difficult because it forces me to
> rearrange a number of matrices to make them match this tip label order. I
> would appreciate if a kind soul can explain why it is that way and whether
> is possible to reorder the tip labels, placing each added tip together with
> its respective counterpart?
>
> Thanks in advance for your help.
>
> Juan Antonio
> --
>
> Dr. Juan A. Balbuena
> Cavanilles Institute of Biodiversity and Evolutionary Biology
> University of Valencia
> http://www.uv.es/~balbuena
> P.O. Box 22085
> http://www.uv.es/cophylpaco
> <http://www.uv.es/cavanilles/zoomarin/index.htm>
> 46071 Valencia, Spain
> e-mail: [email protected]    tel. +34 963 543 658    fax +34 963 543 733
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> *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 - [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/[email protected]/
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to