generating random newick tree
2
1
Entering edit mode
9.2 years ago
Quak ▴ 520

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

phylogeny R • 4.8k views
ADD COMMENT
2
Entering edit mode
9.2 years ago
Brice Sarver ★ 3.8k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
9.2 years ago

A quick solution in C?

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

In your example, there are 3 terminal nodes, not 7.

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1742 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6