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

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

 

R phylogeny • 2.1k views
ADD COMMENTlink modified 4.1 years ago by Pierre Lindenbaum123k • written 4.1 years ago by Quak300
2
gravatar for Brice Sarver
4.1 years ago by
Brice Sarver3.1k
United States
Brice Sarver3.1k 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 4.1 years ago by Brice Sarver3.1k

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 4.1 years ago by Quak300

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

ADD REPLYlink written 4.1 years ago by Brice Sarver3.1k

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

ADD REPLYlink written 4.1 years ago by Quak300
2
gravatar for Pierre Lindenbaum
4.1 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum123k wrote:

A quick solution in C ?

 

 

 

ADD COMMENTlink written 4.1 years ago by Pierre Lindenbaum123k

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 4.1 years ago • written 4.1 years ago by Quak300

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

ADD REPLYlink written 4.1 years ago by Pierre Lindenbaum123k

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 4.1 years ago by Quak300

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

ADD REPLYlink written 4.1 years ago by Pierre Lindenbaum123k

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

ADD REPLYlink written 4.1 years ago by Quak300
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: 724 users visited in the last hour