# INDELible

## [TREE] block

These blocks are used to specify the trees used during simulation.

**User Defined Trees:**

User trees can be rooted or unrooted and may contain any number of spaces, tabs or new lines.
The tree name is used to refer to the tree in [PARTITIONS] blocks.
The 3 user trees (named t1, t2 and t3 below) will all be read as identical.
[TREE] t1 ((A:0.1,B:0.1):0.1,(C:0.1,D:0.1):0.1);
[TREE] t2 ( (A:0.1, B:0.1):0.1, (C:0.1, D:0.1):0.1 );
[TREE] t3
( // trees can span any number of lines
( // and include any amount of whitespace
A:0.1, // including new lines.
B:0.1
):0.1 , // comments within the tree will be ignored.
(C:0.1,D:0.1):0.1);

Any tree can also be rescaled to be a certain tree length. For example the two following trees are identical.
[TREE] T1 ((A:0.1,B:0.2):0.3,(C:0.4,D:0.5):0.6);
[treelength] 4.2
[TREE] T2 ((A:0.2,B:0.4):0.6,(C:0.8,D:1.0):1.2);

**Random Trees:**

Random trees can also be created by INDELible. A different tree will be generated for each replicate.
Random rooted and unrooted trees require the use of more commands:
[TREE] tree1
[unrooted] 10 2.4 1.1 0.2566 0.34 // ntaxa birth death sample mut
[TREE] tree2
[unrooted] 10 2.4 1.1 0.2566 0.34 // ntaxa birth death sample mut
[seed] 2381242
[TREE] tree3
[rooted] 15 6.7 2.5 0.234 0.31 // ntaxa birth death sample mut
[TREE] tree4
[rooted] 15 6.7 2.5 0.234 0.31 // ntaxa birth death sample mut
[treelength] 8
[TREE] tree5
[rooted] 15 6.7 2.5 0.234 0.31 // ntaxa birth death sample mut
[treedepth] 0.4

tree1 and tree2 will be unrooted random trees whilst
tree3 and tree4 will be rooted random trees.
Every time that INDELible is run tree2 will produce the same sequence of random trees beginning with the first replicate in
any [EVOLVE] block where it is used, until the number after
the [seed] command is changed. The other four (tree1, tree3, tree4 and
tree5) will always produce different trees.
Please note that the [seed] command overrules the use of [randomseed] in a
[SETTINGS] block. If [seed] is not used, then [randomseed] will generate
the same sequence of trees every time a control file is run.
tree4 will produce random trees that are always rescaled to have a tree length of 8, and
tree5 will produce random trees that are always rescaled to have a depth (root to tip) of 0.4, whilst the other three
(tree1, tree2 and tree3) will always produce random trees
with different tree lengths/depths. Tree Depth can only be set for random trees.
The numbers that come after the [unrooted] and [rooted] commands
are the same in both cases. The first number is the number of taxa (10 for tree1 and tree2, 15 for tree3 and tree4).
The next four are the parameters used in the birth-death process to create the random trees.
In order, from left to right, these are the birth-rate, death-rate,
sampling fraction and mutation rate. Further details on these
parameters can be found in this paper.

**Branch Lengths:**

For a given topology INDELible can also create branch lengths.
This is done by using the command [branchlengths]
[TREE] EQUAL-TREE
// No branch lengths need to be provided
((((A,B),(C,D)),((E,F),(G,H))),(((I,J),(K,L)),((M,N),(O,P))));
[branchlengths] EQUAL // All branch lengths will be equal
[treedepth] 0.1 // Root-to-longest-tip distance of 0.1
[TREE] EQUAL-TREE2
// If branch lengths are provided, they are ignored
((((A:0.2,B:0.1):0.4,(C:0.3,D:0.1):0.6):0.1,
((E:0.1,F:0.1):0.1,(G:0.2,H:0.1):0.1):0.3):0.1,
(((I:0.1,J:0.6):0.1,(K:0.1,L:0.1):0.1):0.1,
((M:0.4,N:0.1):0.1,(O:0.6,P:0.1):0.1):0.1):0.1);
[branchlengths] EQUAL // Again, all branch lengths will be equal
[treedepth] 0.1 // Root-to-longest-tip distance of 0.1
[TREE] ULTRAMETRIC-TREE
// No branch lengths need to be provided
((((A,B),(C,D)),((E,F),(G,H))),(((I,J),(K,L)),((M,N),(O,P))));
[branchlengths] ULTRAMETRIC // All branch lengths will be equal
[treedepth] 0.1 // Root-to-longest-tip distance of 0.1
[TREE] NON-ULTRAMETRIC-TREE
// No branch lengths need to be provided
((((A,B),(C,D)),((E,F),(G,H))),(((I,J),(K,L)),((M,N),(O,P))));
[branchlengths] NON-ULTRAMETRIC // All branch lengths will be equal
[maxdistance] 0.2 // maximum pairwise distance of 0.2

[treedepth] 0.1 rescales the tree to have a maximum root-to-tip distance of 0.1
After using the [branchlengths] command you should use [treelength] or [treedepth], or [maxdistance] to rescale your tree.
[branchlengths] EQUAL will make every branch on the tree equal to 0.1.
[branchlengths] NON-ULTRAMETRIC gives every branch a random length between 0 and 1.
[branchlengths] ULTRAMETRIC gives every branch a random length between 0 and 1, but will also extend the terminal branches so that the root-to-tip distance is the same for every tip.
If the [branchlengths] command is used then the tree toplogy can be specified with or without branch lengths. It does not matter. Any branch lengths will be ignored. i.e. the trees EQUAL-TREE and EQUAL-TREE2 will be identical.
Examples of the trees produced above can be seen here.
All trees in the image are rescaled to have a maximum tree-depth of 0.1. This means that the root-to-tip distance for taxon G is equal to 0.1 in all 3 trees.
N.B. For ultrametric trees [maxdistance] 0.2 is equivalent to [treedepth] 0.1. For the non-ultrametric tree they are not the same. [maxdistance] 0.2 on the non-ultrametric tree scales the tree such that the sum of the branch lengths in between (in this case) taxons G and N would be 0.2

Trees (random or user) that are used during the simulation will be output by INDELible in a file like this.