NEWICK-formatted tree transformation

How to discard leaves from a NEWICK-formatted tree?

Let $tipfile be a text file containing one or several leaf name(s) to discard from the phylogenetic tree contained in the NEWICK-formatted file $treefile (with or without branch lengths and/or supports). The program gotree could be used to discard the specified leaf name(s) and write the resulting subtree into the NEWICK file $outtree with the following command line:

Alternatively, a similar command line could be used to discard leaves that are absent from an other phylogenetic tree contained in the NEWICK-formatted file $alttree:

Of note, in both cases, branch lengths are summed up and branch supports are transferred (if any).
[170312fl]

How to collapse short branches from a NEWICK-formatted tree?

The following command lines allow collapsing branch(es) of length lower than a specified value $cutoff within the tree contained in the NEWICK-formatted file $treefile and writes the resulting tree into the NEWICK file $outtree.

gotree

The program gotree could be used to collapse short branch(es) with the following command line:

[170312fl]

awk

The following awk one-liner allows collapsing short branch(es):

[1181223ac]

How to collapse branches with low support from a NEWICK-formatted tree?

The program gotree could be used to collapse the branch(es) with support lower than a specified value $cutoff. The following command line allows collapsing such branch(es) within the tree contained in the NEWICK-formatted file $treefile and writes the resulting tree into the NEWICK file $outtree:

[170312fl]

How to discard every branch length from a NEWICK-formatted tree?

The following command lines allows discarding every branch length from the NEWICK-formatted tree file $treefile. The resulting tree is written into the NEWICK file $outtree.

gotree

The program gotree could be used with the following command line:

[170312fl]

sed

The following sed one-liner discards every branch length from the input tree file:

[170522ac]

How to discard every branch support from a NEWICK-formatted tree?

The following command lines allows discarding every branch support from the NEWICK-formatted tree file $treefile. The resulting tree is written into the NEWICK file $outtree.

gotree

The program gotree could be used with the following command line:

[170312fl]

sed

The following sed one-liner discards every branch support from the input tree file:

[170522ac]

How to discard both branch length and support from a NEWICK-formatted tree?

The following command lines allows discarding every branch length and support from the NEWICK-formatted tree file $treefile. The resulting tree is written into the NEWICK file $outtree.

gotree

The program gotree could be used with the following command line:

[170312fl]

Shell

The following command line based on sed discards branch lengths and supports from the input tree file:

[170522ac]

How to rename every taxon name in a NEWICK-formatted tree?

Let $mapfile be a text file containing, for each line, a taxon name to be renamed by a new taxon name, both being separated by at least one blank space. The following command lines allows performing this renaming within the tree contained in the NEWICK-formatted file $treefile. The resulting tree is written into the NEWICK file $outtree.

gotree

The program gotree could be used with the following command line:

[170312fl]

awk

The following awk one-liner leads to the same result:

[181208ac]

How to rescale the branch lengths of a NEWICK-formatted tree?

The following command lines allows multiplying by the factor $scale every branch length of the tree contained in the NEWICK-formatted file $treefile. The resulting tree is written into the NEWICK file $outtree.

gotree

The program gotree could be used with the following command line:

awk

The following awk one-liner rescales the branch lengths of a phylogenetic tree ($prec is the number of decimal places):

[181225ac]