Skip to main content

Release bioRxiv License: MIT CI codecov

Perseus: refining Kraken2 taxonomic classifications of long reads and contigs

logo

Perseus is a post-processing framework for refining Kraken2 taxonomic classifications, with a focus on long-read metagenomics (PacBio HiFi, ONT). While Kraken2’s exact k-mer matching enables fast and sensitive classification, it can produce overconfident fine-rank calls when evidence is sparse, conserved, or partially novel. Perseus addresses this limitation by distinguishing trustworthy from spurious taxonomic predictions using structured k-mer evidence already present in the Kraken2 output. Perseus is designed to reduce false positive fine-rank calls arising from conserved regions, sparse k-mer support, and reference database incompleteness—failure modes that are common in long-read and high-novelty metagenomes.

Perseus assigns confidence probabilities to each Kraken2 classification at every canonical taxonomic rank, enabling informed decisions to confirm assignments, back off to higher, lineage-consistent ranks, or convert predictions to unclassified.

Perseus is built on a multi-headed 1D convolutional neural network that operates directly on features derived from Kraken2 output. The workflow constructs a lineage-aware feature matrix from a standard Kraken2 output file, then performs inference to produce a Kraken2-compatible output augmented with per-rank confidence probabilities for each assignment. Perseus operates strictly as a downstream confidence filter and does not perform reclassification, alignment, or novel taxon discovery.


Installation

Perseus is available through conda. We recommend creating a new environment:

conda create -n perseus -c matnguyen -c conda-forge -c pytorch perseus
conda activate perseus

pip installation

Perseus is available on PyPi and can be installed through pip. There may be issues with installing ETE3 and PyTorch through pip, so we recommend using a new conda or virtual environment:

conda create -n perseus ete3 pytorch
pip install perseus-metagenomics

Getting started

Setup taxonomy database

Perseus will download an ETE3 taxonomy database.

perseus setup <db_path>

Feature extraction

Perseus will perform feature extraction on a Kraken2 output file and output a directory of sharded parquets containing the features.

perseus extract <kraken_file> <output_shards_directory> <db_path>

Filtering

Perseus takes in the directory of sharded parquets and the Kraken2 output file for filtering.

perseus filter <shards_directory> <kraken_file> <output_path> <db_path>

The output file will be similar to the Kraken2 output file, but without the string of k-mer matches, and with the following additional columns:

  1. perseus_taxid - the taxonomic ID assigned by Perseus
  2. perseus_taxonomy - the taxonomic name assigned by Perseus
  3. chosen_rank - the final chosen rank assigned by Perseus
  4. chosen_prob_at_rank - the probability at the final chosen rank
  5. prob_{rank} - the assignment probability at a canonical {rank}

Testing Data

We provide some data for testing Perseus. They can be found under tests/test_data. The Kraken2 output file is tests/test_data/test_kraken, the shards are in tests/test_data/test_shards, and the expected Perseus output file is tests/test_data/filtered.txt.

Testing the Installation

Quick Example

Run Perseus on the included test data:

perseus setup ete3_db
perseus extract tests/test_data/test_kraken.txt example_extract ete3_db
perseus filter example_extract tests/test_data/test_kraken.txt example_filtered.txt ete3_db

This should produce an output file example_filtered.txt.

Because Perseus uses floating-point operations (PyTorch), small numerical differences may occur across platforms. Therefore, the output may not match the reference file exactly with a simple diff.

To compare the output with the expected results using a numerical tolerance:

python scripts/compare_outputs.py example_filtered.txt tests/test_data/filtered.txt

Running the Full Test Suite (optional)

For a full reproducibility check, run the included test suite.

Install the testing dependency:

pip install pytest

Then run:

pytest -q

This runs unit tests and end-to-end pipeline tests used during development.

Citing Perseus

Our preprint can be found here: https://www.biorxiv.org/content/10.64898/2026.03.06.710148v1

Data Generation Scripts

Scripts for generating the inclusion/exclusion simulated data are found here: https://github.com/matnguyen/perseus-scripts

Metadata

Release files for perseus-metagenomics 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perseus-metagenomics 1.1.2
File Size Uploaded Provenance Actions
perseus_metagenomics-1.1.2.tar.gz 1.7 MB Without provenance Details for perseus_metagenomics-1.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for perseus-metagenomics 1.1.2
File Interpreter ABI Platform Actions
perseus_metagenomics-1.1.2-py3-none-any.whl Python 3 none any Details for perseus_metagenomics-1.1.2-py3-none-any.whl

Total release size: 3.4 MB

Release files / perseus_metagenomics-1.1.2.tar.gz

Download URL perseus_metagenomics-1.1.2.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
72668947c40864529dfc81486498ddf853cd3ada5fd64ae8cee20c5d6689e0a4
BLAKE2b-256 checksum
How to use checksums
c4a11f0e858809589c19393cdaad7344de047b843c46d1eed5c2d6f711a7f213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / perseus_metagenomics-1.1.2-py3-none-any.whl

Download URL perseus_metagenomics-1.1.2-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ef586802d03b663b4924481e37da7e4eca952a1ee14fd4e163be86140d13b839
BLAKE2b-256 checksum
How to use checksums
63ae9071e337febaffb84cb975f0c824697cb61fcef92cfb0b37f7d9c546e05b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for perseus-metagenomics 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page