k-Nearest Common Leaves: overlapping phylogenetic tree completion
kncl.py is a Python script designed to complete 2 phylogenetic trees defined on different but mutually overlapping sets of taxa on the union of their taxa sets. The script processes trees in Newick format by pairwise comparing them. It outputs the completed versions of these trees.
- Biologically meaningful datasets of partially overlapping phylogenetic trees with branch lengths are available here.
- Biological datasets and scripts used in the evaluation part of the k-NCL algorithm are located here.
- The data construction pipeline is available here.
- Python 3.x
ete3Python package (with its required dependencies)
Ensure Python 3 and ete3 are installed. You can install ete3 via pip if it's not already installed:
pip install ete3Run the script using the command:
python kncl.py -i <input> <k> -o <output>-
<input>: File containing two or more trees in Newick format, each tree on a separate line. -
<k>: Integer value of k for the k-nearest common leaves algorithm (k must be between 2 and the number of common leaves). If omitted, defaults to$k=\lfloor\frac{N_{cl}+2}{2}\rfloor$ per tree pair. -
<output>: File where the output will be saved.
Given an input file example.newick with the following content:
((((Hylobates:4.711,Nomascus:4.711):7.489,Pongo:12.100):5.946,Macaca:18.050):9.590,(Ateles:10.699,Alouatta:10.699):17.037);
((((Hylobates:5.420,Nomascus:5.420):6.377,((Pan:4.945,Gorilla:4.945):4.227,Pongo:9.172):2.624):7.520,Macaca:19.317):8.377,Ateles:27.693);
Run the script as:
python kncl.py -i example.newick 3 -o output.txtThe output.txt file will contain:
- Completed versions of each tree pair.
- Ensure the input Newick file is correctly formatted.
The description of the k-Nearest Common Leaves algorithm can be found here.
Please email us at: Nadia.Tahiri@USherbrooke.ca for any questions or feedback.