Gotree: toolkit and api for phylogenetic tree manipulation

May 23, 2022 ยท View on GitHub

Commands

stats

This commands display informations about trees, edges, nodes or tips. Several subcommands:

  • gotree stats Without subcommand: Display informations about input trees, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. Number of nodes (including tips)
    3. Number of tips
    4. Number of edges
    5. Average branch length
    6. Sum of all branch lengths
    7. Average bootstrap support
    8. Median bootstrap support
    9. Rooted: true/false
  • gotree stats edges : Display informations about edges of input trees, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. Branch id (newick parsing order)
    3. Branch length
    4. Branch support if any
    5. Terminal branch or not : true/false
    6. Depth 1: length of the shortest path to a tip
    7. Depth 2: number of tips on the lightest side of the branch
    8. Name of the node on the right (tip name if it is a terminal branch)
  • gotree stats nodes : Display informations about nodes of input trees, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. Node id (newick parsing order)
    3. Number of neighbors of the node (3 if internal node without multifurcation, 1 if a tip)
    4. Name of the node (Tip name if tip, Internal node name if any)
    5. Depth of the node: length of the shortest path to a tip
    6. Comments associated to tree nodes (in the form (1,2,3)[comment] in Newick format)
    7. Names of parent node (for unrooted tree, depend on the way the tree is written)
    8. Names of children nodes (for unrooted tree, depend on the way the tree is written)
  • gotree stats rooted : Tells if each input tree is rooted or not, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. rooted : true/false
  • gotree stats splits : Displays each branches of input trees in binary vector format, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. binary vector
  • gotree stats tips : Displays informations about tips of input trees, in tab delimited format, with columns:

    1. Tree id (input file order)
    2. tip id (same as its node id in gotree stats nodes)
    3. Number of neighbors (always 1...)
    4. Name of the tip
    5. Length of the external branch leading to the tip
    6. Sum of branch lengths from the root to the tip
  • gotree stats monophyletic : Tells wether a set of tips form a monophyletic clade in the given trees. Output is in tab delimited format, with columns:

    1. Tree id (input file order)
    2. Monophyletic (true/false)

Usage

General command

Usage:
  gotree stats [flags]
  gotree stats [command]

Available Commands:
  edges        Displays statistics on edges of input tree
  monophyletic Tells wether input tips form a monophyletic group in each of the input trees
  nodes        Displays statistics on nodes of input tree
  rooted       Tells wether the tree is rooted or unrooted
  splits       Prints all the splits from an input tree
  tips         Displays statistics on tips of input tree

Flags:
  -i, --input string    Input tree (default "stdin")
  -o, --output string   Output file (default "stdout")

Examples

  • Generate a random tree and display informations about it
gotree generate yuletree --seed 10 | gotree stats
gotree generate yuletree --seed 10 | gotree stats edges

Should give

treenodestipsedgesmeanbrlensumbrlenmeansupportmediansupportrooted
01810170.104861381.78264354N/AN/Aunrooted

and

treebridlengthsupportterminaldepthtopodepthrootdepthrightname
000.0912341925030609N/Afalse13-1
010.020616211789029896N/Atrue01-1Tip4
020.12939642466438622N/Afalse12-1
030.09740195047110385N/Atrue01-1Tip7
040.015450672710905129N/Atrue01-1Tip2
050.12959932895259058N/Atrue01-1Tip0
060.022969404523534506N/Afalse14-1
070.09604804621401375N/Afalse13-1
080.027845992087631298N/Atrue01-1Tip8
090.005132906169455565N/Afalse12-1
0100.13492605122032592N/Atrue01-1Tip9
0110.10309294031874587N/Atrue01-1Tip3
0120.15075207292513051N/Afalse13-1
0130.029087690784364996N/Afalse12-1
0140.3779897840448691N/Atrue01-1Tip6
0150.1120177846434196N/Atrue01-1Tip5
0160.239082088939295N/Atrue01-1Tip1

As the tree is unrooted, rootdepth is set to -1. However, with a rooted tree:

gotree generate yuletree -r --seed 10 | gotree stats edges
treebridlengthsupportterminaldepthtopodepthrootdepthrightnamecommentsleftnamerightcommentleftcomment
000.054743875470795914N/Afalse221[][][]
010.13492605122032592N/Afalse122[][][]
020.10309294031874587N/Atrue013Tip9[][][]
030.03707446096764306N/Atrue013Tip2[][][]
040.13604994737755394N/Afalse142[][][]
050.19852695409349608N/Atrue013Tip3[][][]
060.020616211789029896N/Afalse153[][][]
070.08184535681853511N/Afalse144[][][]
080.3779897840448691N/Afalse135[][][]
090.027845992087631298N/Afalse126[][][]
0100.0440885662122905N/Atrue017Tip8[][][]
0110.14809735366802398N/Atrue017Tip6[][][]
0120.18347097513974125N/Atrue016Tip5[][][]
0130.03199874235185574N/Atrue015Tip4[][][]
0140.10033210749794116N/Atrue014Tip1[][][]
0150.09740195047110385N/Afalse121[][][]
0160.015450672710905129N/Atrue012Tip7[][][]
0170.17182241382980687N/Atrue012Tip0[][][]

Here rootdepth gives the number of branches from the current branch (included) to the root.

  • Check wether a set of tips form a monophyletic clade

tips.txt:

T1
T2
T3

tree.nw

((T1,T2),(T3,T4),(T5,T6,(T7,T8)));

Then

> gotree stats monophyletic -i tree.nw -l tips.txt
Tree	Monophyletic
0	false

Or

> echo "((T1,T2),(T3,T4),(T5,T6,(T7,T8)));" | gotree stats monophyletic T5 T6 T7 T8
Tree	Monophyletic
0	true