Gotree: toolkit and api for phylogenetic tree manipulation

March 26, 2026 ยท View on GitHub

Github repository

Gotree github repository.

Introduction

Gotree is a set of command line tools to manipulate phylogenetic trees. It is implemented in Go language.

Gotree handles phylogenetic trees in Newick, Nexus, PhyloXML and Nextstrain/Augur v2 format, through several basic commands. Each command may print result (a tree for example) in the standard output, and thus can be piped to the standard input of the next gotree command.

Installation

Binaries

You can download already compiled binaries for the latest release in the release section. Binaries are available for MacOS, Linux, and Windows (32 and 64 bits).

Once downloaded, you can just run the executable without any other downloads.

From sources

In order to compile gotree, you must first download and install Go on your system.

Then you just have to type :

go get github.com/evolbioinfo/gotree/

This will download GoTree sources from github, and all its dependencies.

You can then build it with:

cd $GOPATH/src/github.com/evolbioinfo/gotree/
make

The gotree executable should be located in the $GOPATH/bin folder.

Commands

Here is the list of all commands, with the link to the full description, and a link to a snippet that does it in GO.

CommandSubcommandDescription
annotate (api)Annotates internal nodes of a tree with given data
brlen (api)Modifies branch lengths
--clearClear lengths from input trees
--cutCut branches whose length is greater than or equal to the given length
--roundRounds branch lengths from input trees with a given precision
--scaleScales branch lengths from input trees by a given factor
--setminSets a min branch length to all branches with length < cutoff
--setrandAssigns a random length to edges of input trees
--setAssigns a given length to edges of input trees
collapse (api)Collapses/Removes branches of input trees
--cladeCollapses a clade and replace it ith a tip
--depthCollapses/Removes branches of input trees having a given depth
--lengthCollapses/Removes short branches of input trees
--singleCollapses/Removes branches that connect single internal nodes (linear paths)
--supportCollapses/Removes lowly supported branches of input trees
comment (api)Modifies branch/node comments
--clearClears branch/node comments from input trees
--transferTransfers node names to comments
compare (api)Compares full trees, edges, or tips
--edgesIndividually compares edges of the reference tree to a compared tree
--neighborhoodCompares tip neighborhoods between a reference tree and compared trees
--tipsCompares the set of tips of the reference tree to a compared tree
--treesCompare 2 trees in terms of common and specific branches
completionGenerates auto-completion commands for bash or zsh
compute (api)Computations such as consensus and supports
--bipartitiontreeBuilds one tree with only one given bipartition
--consensusComputes the consensus from a set of input trees
--edgetreesWrites one output tree per branch of the input tree, with only one branch
--support classicalComputes classical bootstrap supports
--support boosterComputes booster bootstrap supports
cutdateCut the tree into specific time windows trees (if dated tree)
divideDivides an input tree file into several tree files
download (api)Downloads trees from a server
--itolDownloads a tree image from iTOL, with given image options
--ncbitaxDownloads the full ncbi taxonomy from NCBI ftp server and cinverts it in Newick
--pantherDownloads a tree from Panther database (http://pantherdb.org/)
draw (api)Draws tree(s) with different layouts
--textDraws tree(s) in text/ascii format
--pngDraws tree(s) in png format
--svgDraws tree(s) in svg format
--cyjsDraws tree(s) in a html file, using cytoscape js
generate (api)Generates random trees, branch lengths are simply drawn from an expontential(0.1) law
--balancedtreeRandomly generates perfectly balanced trees
--caterpillartreeRandomly generates perfectly caterpillar trees
--startreeGenerates a star tree (no internal branches)
--topologiesGenerates all possible tree topologies
--uniformtreeRandomly generates uniform trees
--yuletreeRandomly generates Yule-Harding trees
graft (api)Graft a tree on an input tree
labelsLists labels of tree tips
lttDraws a lineage through time plot
matrix (api)Prints distance matrix associated to the input tree
merge (api)Merges two rooted trees
nni (api)Generates all NNI neighbors from a given tree
prune (api)Removes tips of input trees
reformat (api)Reformats input file
--newickReformats input file (nexus, newick, phyloxml) into newick
--nexusReformats input file (nexus, newick, phyloxml) into nexus
--phyloxmlReformats input file (nexus, newick, phyloxml) into phyloxml
rename (api)Renames tips/nodes of the input tree
repopulate (api)Re populate the tree with identical tips (having the exact same sequence)
reroot (api)Reroots trees using an outgroup or at midpoint
--midpointReroots trees at midpoint position
--outgroupReroots trees using a given outgroup
rotate (api)Reorders neighbors of internal nodes. Does not change the topology, but just traversal order.
--sortSort neighbors of internal nodes by ascending number of tips
--randRandomly reorders neighbors of internal nodes
resolve (api)Resolves multifurcations by adding 0 length branches
--namedResolves internal named nodes as new tips with 0 length branches
sampleSamples trees from a set of input trees
shuffletips (api)Shuffles tip names of an input tree
subtree (api)Extracts a subtree starting at a given node
support (api)Modifies branch supports
--clearClears branch supports from input trees
--roundRounds branch supports from input trees with a given precision
--scaleScales branch supports from input trees by a given factor
--setrandAssigns a random support to edges of input trees
stats (api)Prints statistics about the tree, its edges, its nodes, if it is rooted, and its tips
--edgesPrints informations about all the edges
--monophyleticTells wether input tips form a monophyletic group in input trees
--nodesPrints informations about all the nodes
--rootedTells if the tree is rooted or not
--tipsPrints informations about all the tips
--splitsPrints all the splits/bipartitions of the tree (bit vectors)
unroot (api)Unroots input tree(s)
upload (api)Uploads trees to a given server
--itolUploads trees to itol, with given annotations
versionPrints gotree version