Skip to content

cmoyer-x/DissimilarTrees

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

ANI-Based Phylogenetic Tree Pipeline

Reconstructs a genome phylogeny from pairwise Average Nucleotide Identity (ANI) using an all-vs-all FastANI comparison. The similarity matrix is converted to a distance matrix, a neighbor-joining tree is inferred with QuickTree, and the result is previewed as ASCII via gotree.


Repository Structure

.
├── data/                          # Input genome FASTA files (*.fasta)
├── results/                       # Output files (created at runtime)
├── run_ani_pipeline.sh            # Main pipeline script
├── convert_ani_to_distance.py     # FastANI matrix → Newick converter
└── README.md

Dependencies

Command-line tools

Tool Purpose Install
fastANI All-vs-all ANI computation GitHub
quicktree Neighbor-joining tree inference GitHub
gotree ASCII tree preview GitHub

Python packages

Requires Python 3.7+.

pip install pandas scikit-bio

Usage

1. Prepare inputs

Place all genome FASTA files (.fasta) in a single directory, e.g. data/.

2. Run the pipeline

bash Run_ani.sh <genome_dir> [threads] [output_prefix]
Argument Required Default Description
genome_dir Yes Directory containing *.fasta genome files
threads No 16 Number of CPU threads for FastANI
output_prefix No fastani_output Prefix for output file names

Example:

bash run_ani_pipeline.sh data/ 8 my_genomes

3. Convert matrix directly (optional)

convert_ani_to_distance.py can also be run independently if you already have a FastANI .matrix file:

python3 ANI_Newick.py -i fastani_output.txt.matrix -o ani_tree.nwk
Flag Required Default Description
-i / --input Yes FastANI .matrix file
-o / --output No fastani_tree.nwk Output Newick file

Pipeline Steps

Step 1 — Build genome list

Enumerates all *.fasta files in the input directory and writes paths to genome_list.txt. Exits early if fewer than 2 genomes are found.

Step 2 — FastANI all-vs-all

Runs FastANI in all-vs-all mode using --matrix to produce both a pairwise table and a triangular similarity matrix.

Step 3 — ANI → distance matrix

convert_ani_to_distance.py parses the FastANI lower-triangular matrix, repairs any merged decimal numbers (a known FastANI output artifact), and converts ANI similarity to distance:

distance = 1 − (ANI / 100)

Missing values (NA) are treated as 0.0. The diagonal is set to 100.0 (self-identity). The result is written as a PHYLIP-format distance matrix.

Step 4 — Neighbor-joining tree

QuickTree reads the PHYLIP distance matrix and infers a neighbor-joining tree, written in Newick format.

Step 5 — ASCII preview

gotree renders the tree as ASCII to the terminal for a quick sanity check.


Outputs

File Description
<prefix>.txt Raw FastANI pairwise ANI values
<prefix>.txt.matrix FastANI lower-triangular similarity matrix
distance_matrix.phy PHYLIP distance matrix (QuickTree input)
ani_tree.nwk Final neighbor-joining tree (Newick format)

Biological Notes

ANI measures nucleotide-level sequence identity between two genomes across shared genomic regions. Common interpretation thresholds:

ANI Interpretation
≥ 95% Generally accepted species boundary
80–95% Genus-level divergence (approximate)
< 80% Deeper divergence; ANI less informative

The NJ tree produced here reflects overall genomic similarity, not a formal phylogenomic reconstruction. For publication-quality phylogenies, consider corroborating with core-genome or marker-gene approaches.

About

Building an ANI Based Phylogenetic Tree

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors