pyprego
Python implementation of the prego R package — a PWM Regression Optimizer for motif discovery in DNA sequences.
Installation
pip install -e .
Optional dependencies:
pip install pymisha # for genomic interval integration
pip install logomaker # for sequence logo plots
Quick Start
Continuous regression (find motifs correlated with a response)
import pyprego
# sequences: list of equal-length DNA strings
# response: 1D or 2D numpy array (one row per sequence)
result = pyprego.regress_pwm(sequences, response)
# Result contains:
result.pssm # PSSM DataFrame (pos, A, C, G, T)
result.spat # Spatial model DataFrame (bin, spat_factor)
result.pred # Predictions for each sequence
result.consensus # Consensus motif string
result.r2 # R-squared per response dimension
# Predict on new sequences
new_scores = result.predict(new_sequences)
Binary classification (find motifs that discriminate two classes)
result = pyprego.regress_pwm(
sequences, binary_response, # 0/1 vector
score_metric="ks"
)
result.ks # KS test statistic
result.pred # Predictions
Multiple motifs
result = pyprego.regress_pwm(sequences, response, motif_num=3)
result.models # List of individual motif models
result.multi_stats # Statistics for each motif
result.pred # Combined predictions
PWM scoring with known motif
scores = pyprego.compute_pwm(sequences, pssm, spat=spat_model, bidirect=True)
local_scores = pyprego.compute_local_pwm(sequences, pssm)
K-mer screening
kmers = pyprego.screen_kmers(sequences, response, kmer_len=8)
print(kmers.head()) # Top correlated k-mers
PSSM utilities
pyprego.pssm_cor(pssm1, pssm2) # Correlation between PSSMs
pyprego.pssm_match(pssm, motif_db) # Match against database
pyprego.bits_per_pos(pssm) # Information content
pyprego.consensus_from_pssm(pssm) # Consensus sequence
pyprego.pssm_rc(pssm) # Reverse complement
pyprego.pssm_trim(pssm) # Trim low-info edges
Model export/import
from pyprego.export import export_regression_model, load_regression_model
export_regression_model(result, "model.json")
loaded = load_regression_model("model.json")
new_scores = loaded.predict(new_sequences)
API Compatibility with R prego
pyprego implements the same functions as the R package:
| R function | Python function | Status |
|---|---|---|
regress_pwm() |
pyprego.regress_pwm() |
Complete |
regress_multiple_motifs() |
pyprego.regress_pwm(motif_num=N) |
Complete |
compute_pwm() |
pyprego.compute_pwm() |
Complete |
compute_local_pwm() |
pyprego.compute_local_pwm() |
Complete |
screen_kmers() |
pyprego.screen_kmers() |
Complete |
generate_kmers() |
pyprego.generate_kmers() |
Complete |
kmer_matrix() |
pyprego.kmer_matrix() |
Complete |
pssm_cor() / pssm_diff() |
pyprego.pssm_cor() / pyprego.pssm_diff() |
Complete |
pssm_match() |
pyprego.pssm_match() |
Complete |
pssm_trim() / pssm_rc() |
pyprego.pssm_trim() / pyprego.pssm_rc() |
Complete |
bits_per_pos() |
pyprego.bits_per_pos() |
Complete |
create_motif_db() |
pyprego.create_motif_db() |
Complete |
extract_pwm() |
pyprego.motif_db.extract_pwm() |
Complete |
plot_pssm_logo() |
pyprego.plot_pssm_logo() |
Complete |
intervals_to_seq() |
pyprego.intervals_to_seq() |
Complete (requires pymisha) |
gextract_pwm() |
pyprego.gextract_pwm() |
Complete (requires pymisha) |
Testing
# Fast tests (~6 seconds)
pytest tests/ --ignore=tests/test_high_level.py --ignore=tests/test_regression.py --ignore=tests/test_integration.py
# Full suite (includes slow regression tests)
pytest tests/
Architecture
- NumPy-based: All computation uses NumPy arrays (no GPU/PyTorch dependency)
- pandas DataFrames: PSSMs and spatial models use DataFrames matching R conventions
- Optional pymisha: Genomic functions work when pymisha is installed
- GPU-ready design: Clean array interfaces allow future torch tensor swap
License
MIT
Metadata
Release files for pyprego 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyprego-0.0.4.tar.gz | 1.9 MB | With provenance | Details for pyprego-0.0.4.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| pyprego-0.0.4-cp312-cp312-manylinux_2_28_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.28+ x86-64 | Details for pyprego-0.0.4-cp312-cp312-manylinux_2_28_x86_64.whl |
| pyprego-0.0.4-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details for pyprego-0.0.4-cp312-cp312-macosx_11_0_arm64.whl |
| pyprego-0.0.4-cp311-cp311-manylinux_2_28_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.28+ x86-64 | Details for pyprego-0.0.4-cp311-cp311-manylinux_2_28_x86_64.whl |
| pyprego-0.0.4-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details for pyprego-0.0.4-cp311-cp311-macosx_11_0_arm64.whl |
| pyprego-0.0.4-cp310-cp310-manylinux_2_28_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.28+ x86-64 | Details for pyprego-0.0.4-cp310-cp310-manylinux_2_28_x86_64.whl |
Total release size: 12.6 MB
Release files / pyprego-0.0.4.tar.gz
| Download URL | pyprego-0.0.4.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4491ab76fc244d9edf1eac47617874057cda8d8e8b949fea1e6c55a5362a890e
|
|
BLAKE2b-256 checksum How to use checksums |
9d0eb84be48f1b5f5f269501b30f0f6fb619e526c80604beaee52c216c40e600
|
| 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 2, 2026.
Transparency logRelease files / pyprego-0.0.4-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | pyprego-0.0.4-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a4aa41f7ea5a07d514059db45a777a2599413a0d61b849c7029c8386ca90c491
|
|
BLAKE2b-256 checksum How to use checksums |
63c3d66eb838e003f27a94f039eb0839c22a7a93995d07cd00d6cba1ec514a8b
|
| 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 2, 2026.
Transparency logRelease files / pyprego-0.0.4-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pyprego-0.0.4-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
841e8b68295d2a16fb83071362bd38fc019c54ba7659d126855f40858963439c
|
|
BLAKE2b-256 checksum How to use checksums |
81fd2f6258815d04c691a0b28f8a423caa7e7e4c7d4accc33f606c0043712eaa
|
| 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 2, 2026.
Transparency logRelease files / pyprego-0.0.4-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | pyprego-0.0.4-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
8ee4a30c604fae8b20360ba3076d53c41ac1a156e32a9ad499724fef87bb85ce
|
|
BLAKE2b-256 checksum How to use checksums |
7ae46eac53992a38f77c66525cab9616e3f60d3d248a9b994a5b6a3527530e3c
|
| 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 2, 2026.
Transparency logRelease files / pyprego-0.0.4-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pyprego-0.0.4-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7f56b40fbd0818e36e785949e97bff42b3f62d2d67f7e872712979f6ff96dc30
|
|
BLAKE2b-256 checksum How to use checksums |
2fdbbd46188971b5e890f463df5d1d107e60fd3a9ab9e64b586e1e46b6b7891d
|
| 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 2, 2026.
Transparency logRelease files / pyprego-0.0.4-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | pyprego-0.0.4-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
92e8a26affd6032002d6a90e43b1fd6fbb7139bb0ea5ee704da3c954c363bca4
|
|
BLAKE2b-256 checksum How to use checksums |
84cfd6fbee52186910e53ecb18f02cf19b62b1245810087d846a2d09db82c7e1
|
| 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 2, 2026.
Transparency logSecurity for pyprego 0.0.4
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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for pyprego-0.0.4.tar.gz
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 2, 2026.
Transparency logA 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.