Trimming trees with TreeBeST
Posted: 2020-01-18 Filed under: academic | Tags: ensembl, phylogenetic tree, subtree, TimeTree, tree, treebest Leave a commentI needed a program that can easily trim branches from a phylogenetic tree and came across TreeBeST (Tree Building guided by Species Tree). TreeBeST is a neat and versatile program that builds, manipulates and displays phylogenetic trees and seems to be perfect for the job.
TreeBeST with Ensembl Compara modifications is available at SBo and requires only fltk. The SlackBuild installs the command line treebest
and its graphical front-end fltreebest
. Let’s say we have a list of species, for which I have obtained a phylogenetic tree from TreeTime:
The program can save trees in *.nhx
format with line breaks:
(Danio_rerio:435.324, (Xenopus_tropicalis:351.758, ((Anolis_carolinensis:279.657, (((Gallus_gallus:79.9554, Anas_platyrhynchos:79.9554 )'14':18.0875, Geospiza_fortis:98.0429 )'13':155.691, Chelonia_mydas:253.734 )'11':25.9228 )'10':32.2469, (((((Orcinus_orca:55.9599, Bos_taurus:55.9599 )'19':6.00614, Sus_scrofa:61.966 )'9':34.4964, ((Cavia_porcellus:72.8767, (Rattus_norvegicus:20.8874, Mus_musculus:20.8874 )'22':51.9893 )'8':16.9465, (Gorilla_gorilla:9.0631, (Pan_troglodytes:6.6509, Homo_sapiens:6.6509 )'6':2.41219 )'30':80.7601 )'29':6.6392 )'27':8.99739, Loxodonta_africana:105.46 )'35':71.4677, Ornithorhynchus_anatinus:176.927 )'43':134.976 )'42':39.8546 )'40':83.5656 );
If I want to remove the sea mammal Orcinus orca (killer whale), I can use the command line treebest
. First, prepare an updated species list, where O. orca is removed:
Anolis_carolinensis Cavia_porcellus Danio_rerio Gallus_gallus Homo_sapiens Loxodonta_africana Mus_musculus Ornithorhynchus_anatinus Pan_troglodytes Rattus_norvegicus Sus_scrofa Xenopus_tropicalis Gorilla_gorilla Anas_platyrhynchos Geospiza_fortis Bos_taurus Chelonia_mydas
Then run treebest
with the subtree
option, pointing the input tree (species.nhx
) and the list of trimmed species (species-trim.txt
):
treebest subtree species.nhx species-trim.txt > trimmedTree.nhx
This outputs the subtree file trimmedTree.nhx
with node ’19’ gone:
(Danio_rerio:435.324, (Xenopus_tropicalis:351.758, ((Anolis_carolinensis:279.657, (((Gallus_gallus:79.9554, Anas_platyrhynchos:79.9554 )'14':18.0875, Geospiza_fortis:98.0429 )'13':155.691, Chelonia_mydas:253.734 )'11':25.9228 )'10':32.2469, ((((Bos_taurus:61.966, Sus_scrofa:61.966 )'9':34.4964, ((Cavia_porcellus:72.8767, (Rattus_norvegicus:20.8874, Mus_musculus:20.8874 )'22':51.9893 )'8':16.9465, (Gorilla_gorilla:9.0631, (Pan_troglodytes:6.6509, Homo_sapiens:6.6509 )'6':2.41219 )'30':80.7601 )'29':6.6392 )'27':8.99739, Loxodonta_africana:105.46 )'35':71.4677, Ornithorhynchus_anatinus:176.927 )'43':134.976 )'42':39.8546 )'40':83.5656 );