Question: generating random newick tree
1
gravatar for Quak
3.5 years ago by
Quak290
United States
Quak290 wrote:

What are some smart ways of generating newick tree string randomly, say, with 128 leaf for example ...

 

R phylogeny • 1.9k views
ADD COMMENTlink modified 3.5 years ago by Pierre Lindenbaum118k • written 3.5 years ago by Quak290
2
gravatar for Brice Sarver
3.5 years ago by
Brice Sarver2.5k
United States
Brice Sarver2.5k wrote:

There are several ways to do this in R.

rtree() in the ape library will simulate a random tree.

The TreeSim library will allow you to simulate trees under various parameter combinations and constrain on the number of taxa, age, etc. I use it for simulations and when I need a quick dummy tree.

Save the objects in Newick format once you've got what you want.

ADD COMMENTlink written 3.5 years ago by Brice Sarver2.5k

thanks; The thing is I would like the tree to be equidistant !! I should have said that earlier in the question, It would be nice to know how can I constrain the simulation to make equidistance tree ...

ADD REPLYlink written 3.5 years ago by Quak290

Just to be clear, by 'equidistant' do you mean 'ultrametric?' TreeSim will produce ultrametric trees.

ADD REPLYlink written 3.5 years ago by Brice Sarver2.5k

sorry about the confusion; I have pasted an image under the other answer ... I hope that makes it clear :-)

ADD REPLYlink written 3.5 years ago by Quak290
2
gravatar for Pierre Lindenbaum
3.5 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum118k wrote:

A quick solution in C ?

 

 

 

ADD COMMENTlink written 3.5 years ago by Pierre Lindenbaum118k

great; I am trying to tweak it; basically, I would like to have a equidistance tree ... something like this, with 128 or more leafs ...

ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by Quak290

easy if you only specify the number of terminal nodes. Is it what you want ?
 

ADD REPLYlink written 3.5 years ago by Pierre Lindenbaum118k

exactly;

Given 7 number of nodes , ./a.out 7     It returns

(((id5:1.000000)id3:1.000000)id0:1.000000,(id2:1.000000)id1:1.000000,id4:1.000000)id6;

which does not look as I expect either.

ADD REPLYlink written 3.5 years ago by Quak290

in your example, there are  3 *terminal* nodes, not 7.

ADD REPLYlink written 3.5 years ago by Pierre Lindenbaum118k

yes, 7 is the total number of nodes; meaning 4 leafs, 2 parents and 1(origin).

ADD REPLYlink written 3.5 years ago by Quak290
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1076 users visited in the last hour