Skip to main content

phylotypy

PyPI version Python 3.11+ License: MIT

A Naive Bayesian Classifier for 16S rRNA gene sequences, inspired by the phylotypr R package by Riffomonas. Designed for classifying amplicon sequence variants (ASVs) from DADA2, QIIME2, or raw FASTA files against a reference database of 16S rRNA sequences. PhylotyPY was built to run on a laptop with modest hardware. The project is memory opitmized and takes advantage of a computer's mutiple cpus.

DADA2's assignTaxonomy has no option to save and reuse a classifier. And large reference fasta files like Silva can tie up a computer for an extended time period. QIIME2 requires conda installation and produces artifact files needing to be inter-converted.

Phylotypy was created to be a drop-in replacement for DADA2 and QIIME2's classifcation steps. Phylotypy takes fasta files and csv/tsv file as input options. The output is a tsv file with columns containing several lineage formats and separate taxonomic levels:

# lineage with percent confidence scrores
Bacteria(100);Pseudomonadota(95);Deltaproteobacteria(92);Desulfovibrionales(92);Desulfovibrionaceae(90);Desulfovibrio(80)

# semicolon separate lineage
Bacteria;Pseudomonadota;Deltaproteobacteria;Desulfovibrionales;Desulfovibrionaceae;Desulfovibrio

# qiime formated lineage
k__Bacteria;p__Pseudomonadota;c__Deltaproteobacteria;o__Desulfovibrionales;f__Desulfovibrionaceae;g__Desulfovibrio
Kingdom Phylum Class Order Family Genus
Bacteria Pseudomonadota Deltaproteobacteria Desulfovibrionales Desulfovibrionaceae Desulfovibrio

Phylotypy was written from the ground up but using methods presented in Riffamonas's CodeClub series. I want to thank P. Schloss and Riffomonas for the inspiration to write phylotypy. Check out the videos on his YouTube channel.


Performance

The full RDP reference database takes ~7.5 seconds and the full Silva reference database (genus level) takes ~19 seconds on a 2020 Apple Intel MacBook Pro with 16Gb of RAM. Newer systems should see a substantial increase in performance.


How to Install

Using pip:

pip install phylotypy

Using uv (recommended — how to install uv):

uv pip install phylotypy

Note: Intel Mac (x86_64) users are limited to numba 0.62.1, which is pinned in this package. Apple Silicon (M-series) users are not affected.


Quickstart

Download the RDP reference training set and an example dataset (see Training Data for details and download links), then classify from the command line:

phylotypy classify --input dna_moving_pictures.fasta \
                   --db rdp_16S_v19.dada2.fasta \
                   --out classified_seqs.tsv \
                   --save-db rdp_classifer.pickle \
                   --terminal-report \
                   --verbose

--save-db pickles the built classifier so later runs against the same reference skip rebuilding it. --terminal-report prints a bar-chart summary of the results straight to the terminal:

Phylum-level summary  770 sequences · 20 taxa (19 named)
────────────────────────────────────────────────────────────────────────────────
Bacillota              ████████████████████████████████████████████  277  36.0%
Pseudomonadota         ███████████████████████▉                      150  19.5%
Bacteroidota           █████████████████████▊                        137  17.8%
Bacteria_unclassified  ██████████▋                                    67   8.7%
Actinomycetota         ██████████                                     63   8.2%
...
────────────────────────────────────────────────────────────────────────────────
resolved at phylum: 703/770 (91.3%) · mean confidence 98.4

You can also regenerate that same chart later from a results file, without re-classifying, using phylotypy report:

phylotypy report --input classified_seqs.tsv

See docs/cli-reference.md for reusing a saved database, the terminal report's rank/top options, the report subcommand, and full --help output for build, classify, and report.

Using the API instead

The same steps from a Python script or notebook:

from phylotypy import classifier, results, read_fasta

rdp = read_fasta.read_taxa_fasta("rdp_16S_v19.dada2.fasta")
moving_pics = read_fasta.read_taxa_fasta("dna_moving_pictures.fasta")

database = classifier.make_classifier(rdp)
classified = classifier.classify_sequences(moving_pics, database)
classified = results.summarize_predictions(classified)

classified.to_csv("classified_results.csv")

See docs/api-guide.md for the full walkthrough, including formatting/export options and example output.


Documentation

  • docs/training-data.md — downloading reference data, required FASTA header format, and fixing "ragged" (inconsistent-depth) taxonomy strings
  • docs/cli-reference.md — full CLI usage: building/reusing a database, the terminal report, and --help output for every subcommand
  • docs/api-guide.md — step-by-step API usage and a complete code example
  • benchmarks/ — speed comparisons against other 16S classification tools

Working with Your Own Data

phylotypy works with FASTA files from DADA2, QIIME2, or any standard pipeline. See read_fasta.py for utilities to load and convert sequence data into the required format.

A complete walkthrough is available in vignette.py.


Requirements

Dependencies are installed automatically via pip. See pyproject.toml for the full list.


Citation

If you use phylotypy in your research, please cite:

  • Wang, Q., Garrity, G.M., Tiedje, J.M., Cole, J.R. (2007) Naive Bayesian Classifier for Rapid Assignment of rRNA Sequences into the New Bacterial Taxonomy. Applied and Environmental Microbiology, 73(16), 5261–5267.
  • Schloss PD.2025.phylotypr: an R package for classifying DNA sequences. Microbiol Resour Announc14:e01144-24.https://doi.org/10.1128/mra.01144-24
  • Saltikov, C. (2024) phylotypy: Python implementation of a Naive Bayesian 16S rRNA classifier. https://github.com/csaltikov/phylotypy

AI Assistance

Portions of this project (code and documentation) were developed with the assistance of Anthropic's Claude.

Release files for phylotypy 0.9.0

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

Source distribution (sdist)

Source distribution for phylotypy 0.9.0
File Size Uploaded
phylotypy-0.9.0.tar.gz 322.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for phylotypy 0.9.0
File
phylotypy-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
phylotypy-0.9.0-cp313-cp313-macosx_10_13_universal2.whl CPython 3.13 CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) Details
phylotypy-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
phylotypy-0.9.0-cp312-cp312-macosx_10_13_universal2.whl CPython 3.12 CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) Details
phylotypy-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
phylotypy-0.9.0-cp311-cp311-macosx_10_9_universal2.whl CPython 3.11 CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 5.2 MB

Release files / phylotypy-0.9.0.tar.gz

Download URL phylotypy-0.9.0.tar.gz
Size 322.2 kB
Tags Source
SHA-256 checksum
How to use checksums
77671ba7fee45c29348d770ad72e93584105b6a4bab9f17ebc4b02c1277f68e0
BLAKE2b-256 checksum
How to use checksums
434a4fe39f93867ecf0f5e3364886d4d45c16b4a9dc4075261c5d537c32915af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL phylotypy-0.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4895aaaf9e07c7ec7b590b0e2961c524516c4af8deee625c89c27529c260bcd3
BLAKE2b-256 checksum
How to use checksums
3f6f748c3d71d129cabe3537306de929503b2db4832c81049513353c58ad6f13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp313-cp313-macosx_10_13_universal2.whl

Download URL phylotypy-0.9.0-cp313-cp313-macosx_10_13_universal2.whl
Size 556.3 kB
Tags CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
decad91210c712359984abe84595ba613738b6a18d41562f29fc3ea588f82548
BLAKE2b-256 checksum
How to use checksums
a38c35a7b0dbc77311fdb6d28e4ff23d3673bb6863e078200c8be3600002d868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL phylotypy-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2bff3a6c0ad97c68f56dbf90a1caaac366afc3e90d44d8b9c740181301659aeb
BLAKE2b-256 checksum
How to use checksums
acdaebb9d78e39a5441edcb054389543a67a4663e5ed09e61ac3a675a013ef99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp312-cp312-macosx_10_13_universal2.whl

Download URL phylotypy-0.9.0-cp312-cp312-macosx_10_13_universal2.whl
Size 557.0 kB
Tags CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
36baaf30557d51b508e31847bdcf8d76352a50612b1981af86169442ee06e8be
BLAKE2b-256 checksum
How to use checksums
ed050a539c52730712335c386a6a74f050ad4900d7f806f157eda20cfbcc4ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL phylotypy-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
adec69ebaf11528d42b815f90d69e20ad79c7f0162698d1a4f2ac6f486457fb9
BLAKE2b-256 checksum
How to use checksums
fc96d358ed2995b833292a5f84902849737f66ddbe3551441ac708822a2eb717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / phylotypy-0.9.0-cp311-cp311-macosx_10_9_universal2.whl

Download URL phylotypy-0.9.0-cp311-cp311-macosx_10_9_universal2.whl
Size 554.1 kB
Tags CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
0138f244a59cfede39a8af51d49e63cf244f10b6b90d691ad7a81be8967e468b
BLAKE2b-256 checksum
How to use checksums
1d2cfc4a72e5b128c1ab7d52e8126045b0740b333d732c9bdee1269a89ce26d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.1

7 release files

This release

0.9.0 This release

7 release files

0.7.5

7 release files

0.6.0

7 release files

0.5.0

7 release files

0.4.0

7 release files

0.3.4

7 release files

0.3.2

10 release files

0.3.1

1 release file

0.3.0

4 release files

0.2.7

4 release files

0.2.6

4 release files

0.2.5

4 release files

0.2.4

3 release files

0.2.3

3 release files

0.2.2

3 release files

0.2.0

2 release files

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