Thank you very much for posting, Brian. I will certainly have a look at
reorder.phylo(). Yet, I think it would be useful not only to me but to other users
having some feed-back on how tips are ordered and why the tips inserted are
listed last.

Cheers

Juan Antonio

> 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 <j.a.balbuena at uv.es>
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

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

Reply via email to