One can sample from all possible rooted labeled histories by randomly
bifurcating lineages, and at the end assigning the names randomly to the
tips.  Note that a "labeled history" is not the same as a tree topology.

One can sample randomly from all topologies of rooted bifurcating trees
with labeled tips by adding the species one by one to a one-species tree,
each time choosing to split them off from one of the branches.  The
enumeration of all such trees is based on counting all possible ways of
doing this, so choosing one such sequence should choose one of them at
random. Jim Rohlf has a paper with an algorithm equivalent to this in (I
think) Systematic Zoology but I cannot locate it at the moment.

For rooted multifurcating trees a similar method could be used.  In my 1978
paper in Systematic Zoology I showed that each such tree corresponded to
way adding the species 1 to n in order, where at each step we choose
equiprobably from among all branches and all interior nodes (so that if
there are 13 branches and 6 interior nodes we split off one of these 19 at
random). The enumeration algorithm for which this is based is also
discussed in detail in Chapter 3 of my book.

Joe


On Mon, Dec 23, 2013 at 8:57 PM, Eduardo Ascarrunz <ear...@gmail.com> wrote:

> Hi Liam,
>
> Thank you! That looks clever. How does this method bias the sampling? I
> think it could be useful for test running my code anyway.
>
> Looking forward your findings, and all the best,
>
> E.
> On 24 Dec 2013 04:49, "Liam J. Revell" <liam.rev...@umb.edu> wrote:
>
> > Hi Eduardo.
> >
> > You could try something like this:
> >
> > randomFurcTrees<-function(n,N=1){
> >   foo<-function(n){
> >     t<-di2multi(rtree(n,br=sample(c(0,1),
> >       size=2*(n-2),replace=TRUE),rooted=FALSE))
> >     t$edge.length<-NULL
> >     t
> >   }
> >   trees<-if(N>1) replicate(N,foo(12),simplify=FALSE) else foo(n)
> >   if(N>1) class(trees)<-"multiPhylo"
> >   return(trees)
> > }
> >
> > What this does is it generates random bifurcating topologies (using rtree
> > in ape) with branch lengths that can be 0 or 1; then it collapses all
> zero
> > length branches to polytomies. This is (demonstrably) *not* the same as
> > picking trees at random from the set of all bi- and multifurcating
> > topologies. It's not immediately obvious how you could do that, but I'll
> > think about it.
> >
> > All the best, Liam
> >
> > Liam J. Revell, Assistant 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 12/23/2013 10:15 PM, Eduardo Ascarrunz wrote:
> >
> >> Hello everyone,
> >>
> >> Newbie here. I'm looking for a way to generate random trees of N tips,
> >> allowing multifurcations. My N would be >12, so it wouldn't be practical
> >> (nor possible) to work with all the possible trees (cf. allFurcTrees).
> I'd
> >> be happy with a set of 1000 trees, sampled equiprobably. I'd much
> >> appreciate any help.
> >>
> >> Best to all,
> >>
> >> E.
> >>
> >>         [[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-ph...@r-project.org/
> >>
> >>
>
>         [[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/
>



-- 
----
Joe Felsenstein         j...@gs.washington.edu
 Department of Genome Sciences and Department of Biology,
 University of Washington, Box 355065, Seattle, WA 98195-5065 USA

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

Reply via email to