Skip to main content

Build plasmid phylogenetic trees from dotplot, pangenome presence/absence, and k-mer methods, with cluster detection.

Project description

PlasTree

A tree-based pipeline for clustering complete bacterial plasmids from long-read assemblies, combining structural, k-mer, and gene-content similarity into a single weighted consensus tree.

PlasTree overview

Overview

PlasTree integrates three complementary similarity methods, DotPloTree (pairwise dotplot-based structural similarity), KmerTree (ranked k-mer frequency similarity), and PanGTree (pangenome presence/absence similarity), and combines them into a single weighted consensus tree. Plasmids are then automatically grouped into clusters based on branch length and cluster size thresholds. PlasTree is intended for complete plasmid assemblies from long-read sequencing (e.g. Oxford Nanopore Technologies), where rearrangements, recombination, and accessory gene turnover can obscure relationships found by a single similarity measure.

Content

Key Features

  • Three independent tree-building methods: DotPloTree (structural), KmerTree (nucleotide composition), and PanGTree (gene content, Roary or Panaroo format)
  • Weighted consensus tree (3:2:1 DotPloTree:PanGTree:KmerTree) when two or more methods are combined
  • Automatic clustering of plasmids by branch length, with support for multiple thresholds computed in a single run
  • Installable as a standard Python package, exposing a single plastree command
  • Optional PNG rendering of pairwise dotplots and the final cluster-colored consensus tree

Requirements

  • Python 3.10+
  • All other dependencies (Biopython, NumPy, Pandas, SciPy, Matplotlib) are installed automatically with the package.

Installation

First create an isolated environment named plastree (pick one option below), then install PlasTree into it.

Option A: venv

python3 -m venv plastree
source plastree/bin/activate
pip install --upgrade pip

Option B: conda / miniforge

conda create -n plastree python=3.12
conda activate plastree

With the environment active, install PlasTree from PyPI:

pip install plastree

Or, install directly from GitHub (e.g. to get unreleased changes):

pip install git+https://github.com/BioSys-BUT/PlasTree.git

Or, if you want a local copy of the source:

git clone https://github.com/BioSys-BUT/PlasTree.git
cd PlasTree
pip install .

Verify the install:

plastree --help

Usage

plastree --fasta <fasta_path> [--pang_format {roary,panaroo}] [--pang_csv <csv_path>] [--methods dotplot kmer pang] [--outdir <out_dir>] [--max_cluster_size <int>] [--max_branch_length <float> [<float> ...]] [--dotplot_window {19,22}] [--dotplot_threads <int>] [--dotplot_png] [--result_tree_png]

Parameters

  • --fasta: Path to a single FASTA file containing all plasmid sequences (one record per plasmid). Required.
  • --pang_format {roary,panaroo}: Format of the pangenome CSV. Required when using --methods pang.
  • --pang_csv: Path to the pangenome presence/absence CSV file. Required when using --methods pang.
  • --methods [dotplot pang kmer ...]: Tree construction methods to apply. Default: dotplot only.
  • --outdir: Directory to store output files. Default: output.
  • --max_cluster_size: Maximum number of plasmid sequences per cluster. Default: half the number of input sequences.
  • --max_branch_length: Maximum allowed branch length within a cluster (0-1). Accepts one or more values (e.g. 0.1 0.2 0.05); one cluster-assignment table is produced per value. Default: 0.2.
  • --dotplot_window {19,22}: Sliding window size for dotplot comparison. Default: 22.
  • --dotplot_threads: Number of parallel worker processes for dotplot pairwise distance computation. Default: 1.
  • --dotplot_png: Save pairwise dotplots as PNGs. Only for <=20 sequences. Default: off.
  • --result_tree_png: Save the consensus tree as a PNG with node support and cluster coloring. Default: off.

Example

plastree \
  --fasta sequences.fasta \
  --methods dotplot kmer pang \
  --pang_format panaroo \
  --pang_csv gene_presence_absence.csv \
  --dotplot_window 22 \
  --dotplot_threads 8 \
  --max_cluster_size 30 \
  --max_branch_length 0.05 0.1 0.2 0.4 \
  --result_tree_png \
  --outdir output

with example data (8 small real plasmids from Enterococcus faecium, included in examples/):

plastree \
  --fasta examples/plasmids.fasta \
  --methods dotplot kmer pang \
  --pang_format panaroo \
  --pang_csv examples/gene_presence_absence.csv \
  --result_tree_png \
  --outdir examples/output

Output

All output files are written to --outdir.

File Description
dotplot_tree.newick DotPloTree structural similarity tree (--methods dotplot)
dotplot_distmat.tsv DotPloTree distance matrix
kmer_tree.newick KmerTree nucleotide composition tree (--methods kmer)
kmer_distmat.tsv KmerTree distance matrix
pang_tree.newick PanGTree gene content tree (--methods pang)
pang_distmat.tsv PanGTree distance matrix
consensus_tree.newick weighted consensus tree (only when 2+ methods are used)
plasmid_clusters.tsv cluster assignment per plasmid (cluster 0 = outlier)
cluster_tree.png consensus tree rendered with clusters color-coded (only with --result_tree_png)

If multiple --max_branch_length values are given, plasmid_clusters.tsv and cluster_tree.png are produced once per threshold, suffixed with the value (dots replaced by underscores), e.g. plasmid_clusters_bl0_2.tsv and cluster_tree_0_2.png for threshold 0.2.

Generating pangenome input (Bakta + Roary/Panaroo)

The --pang_csv file used by --methods pang is not produced by PlasTree itself. It comes from annotating the same plasmid FASTA files and clustering the predicted genes into orthologous groups, using external tools:

  1. Annotate each plasmid with Bakta (or another tool that outputs GFF3 annotations), producing one GFF3 file per plasmid.
  2. Collect all resulting GFF3 files into one directory.
  3. Run Roary and/or Panaroo on the collected GFF3 files:
roary *.gff3 -f roary_out
panaroo -i *.gff3 --clean-mode sensitive -o panaroo_out

Both produce a gene_presence_absence.csv. Pass this file as --pang_csv, together with the matching --pang_format roary or --pang_format panaroo. See each tool's own documentation for annotation database setup, threading, and other options. Bakta, Roary, and Panaroo have their own, sometimes conflicting, dependencies, so it is common to install them into separate environments (e.g. separate conda environments).

License

See LICENSE for details (MIT).

Citation

The manuscript describing PlasTree is currently in submission. Until it is published, if you use PlasTree in your research, please cite this repository:

@software{plastree2026,
  title={PlasTree},
  author={Vitkova, Helena and Jakubickova, Marketa and Bezdicek, Matej and Holubova, Ema and Lengerova, Martina},
  year={2026},
  url={https://github.com/BioSys-BUT/PlasTree}
}

Contact

For questions and feedback, please open an issue on GitHub or contact us via email at jakubickova@vut.cz.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plastree-0.1.3.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plastree-0.1.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file plastree-0.1.3.tar.gz.

File metadata

  • Download URL: plastree-0.1.3.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for plastree-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1ec3b4bf6ee53cf9235b675faa7ee73fe5776b206245cb45c5746f65b38d2f3a
MD5 e3d2e202734cbe442a1cfec6f9663940
BLAKE2b-256 20bbd1276fcdad7d6e33d0ddf519864be2013a5e30da0d6a68b7e70fcf665500

See more details on using hashes here.

File details

Details for the file plastree-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: plastree-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for plastree-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45ea9322b92e86a43ee52404029f29c7eefd49f8dab6c541f0a01a5da8523ebb
MD5 a84186877b31959439ccd9574990dc0d
BLAKE2b-256 960062646a2db53c4c752f3879d1ca50bb13d14c0a1d1cdc16d7a327850c97db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page