Question: generating random newick tree
1
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
modified 4.1 years ago by Pierre Lindenbaum123k • written 4.1 years ago by Quak300
2
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.

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 ...

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

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

2
4.1 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum123k wrote:

A quick solution in C ?

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

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

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.

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