A Python port of the MAGICAL hierarchical Bayesian Gibbs sampler for regulatory circuit inference.
Project description
pymagical
pymagical is a high-performance Python port of the MAGICAL (Multiome Accessibility Gene Integration Calling and Looping) algorithm. It provides a method for inferring functional regulatory circuits—triads of Transcription Factors (TFs), cis-regulatory elements (Peaks), and target Genes—from single-cell RNA-seq and ATAC-seq data.
The methodology is based on the framework described in:
Chen et al., "Mapping disease regulatory circuits at cell-type resolution from single-cell multiomics data," Nature Computational Science, 2023. (Available here)
Key Features
- Numba-Accelerated Sampling: Optional JIT-compiled kernels provide a ~30x speedup in Gibbs sampling compared to the original MATLAB implementation (averaged across large-scale benchmarks).
- IO Caching: Automatically caches large sparse matrices and genomic metadata into PyArrow-backed Parquet and NumPy formats for near-instant subsequent loads (~15x faster than MATLAB).
- Biological Directionality: Unlike the original version,
pymagicalautomatically classifies inferred circuits as activators (+) or repressors (-) by analyzing continuous regression weights.
Installation
The recommended way to install pymagical is via PyPI:
pip install pymagical
For interactive HTML reports and visualization features, install the viz extra:
pip install "pymagical[viz]"
Quick Start
1. Command Line Usage
Once installed, run the circuit inference directly from your terminal. Use --use-numba for maximum performance:
# Run with default data for 500 iterations using Numba
pymagical run --main-dir path/to/data --cell-dir astrocytes --iter 500 --use-numba --outdir results/
# Generate an interactive HTML visualization report (requires [viz] extra)
pymagical viz results/magical_py_500.txt
Run pymagical --help to see all available flags and subcommands.
2. Programmatic Usage
from pymagical import run_magical
run_magical(
cand_gene_file="genes.txt",
cand_peak_file="peaks.txt",
# ... other file paths ...
iteration_num=2000,
use_numba=True,
output_file="my_results.txt"
)
Citation
If you use MAGICAL in your research, please cite:
@article{chen_mapping_2023,
title = {Mapping disease regulatory circuits at cell-type resolution from single-cell multiomics data},
author = {Chen, Xi and Wang, Yuan and Cappuccio, Antonio and Cheng, Wan-Sze and Zamojski, Frederique Ruf and Nair, Venugopalan D. and Miller, Clare M. and Rubenstein, Aliza B. and Nudelman, German and Tadych, Alicja and Theesfeld, Chandra L. and Vornholt, Alexandria and George, Mary-Catherine and Ruffin, Felicia and Dagher, Michael and Chawla, Daniel G. and Soares-Schanoski, Alessandra and Spurbeck, Rachel R. and Ndhlovu, Lishomwa C. and Sebra, Robert and Kleinstein, Steven H. and Letizia, Andrew G. and Ramos, Irene and Fowler, Vance G. and Woods, Christopher W. and Zaslavsky, Elena and Troyanskaya, Olga G. and Sealfon, Stuart C.},
journal = {Nature Computational Science},
year = {2023},
month = jul,
doi = {10.1038/s43588-023-00476-5},
url = {https://www.nature.com/articles/s43588-023-00476-5},
}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymagical-1.2.0.tar.gz.
File metadata
- Download URL: pymagical-1.2.0.tar.gz
- Upload date:
- Size: 91.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a4e97ec7684e17cb8eb8e597cd49da6425a1d12922c38d660345025fadd4ea7
|
|
| MD5 |
405be7b2884bd55bcc36cf66da8f88ac
|
|
| BLAKE2b-256 |
98bb835ed8499b9228e53cad4d0812b2bf24ac535a91e5270f0d0e5799d4a0fe
|
Provenance
The following attestation bundles were made for pymagical-1.2.0.tar.gz:
Publisher:
python-publish.yml on csun0/pymagical
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymagical-1.2.0.tar.gz -
Subject digest:
6a4e97ec7684e17cb8eb8e597cd49da6425a1d12922c38d660345025fadd4ea7 - Sigstore transparency entry: 1030282791
- Sigstore integration time:
-
Permalink:
csun0/pymagical@45bef8d742f1492e58ac37bcccc15b45fd47cbc1 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/csun0
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@45bef8d742f1492e58ac37bcccc15b45fd47cbc1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymagical-1.2.0-py3-none-any.whl.
File metadata
- Download URL: pymagical-1.2.0-py3-none-any.whl
- Upload date:
- Size: 99.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d3612924ec266bfdce016f31352dadd1deb39db7f0a90cef5ab3a2563dfd5b3
|
|
| MD5 |
89612c7d724e7ad3789419266d42f9ac
|
|
| BLAKE2b-256 |
cdc31a0a1aeac425c7f73461a0bfb45da8562b8fb05fd6d67dbac9032404589e
|
Provenance
The following attestation bundles were made for pymagical-1.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on csun0/pymagical
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymagical-1.2.0-py3-none-any.whl -
Subject digest:
8d3612924ec266bfdce016f31352dadd1deb39db7f0a90cef5ab3a2563dfd5b3 - Sigstore transparency entry: 1030282845
- Sigstore integration time:
-
Permalink:
csun0/pymagical@45bef8d742f1492e58ac37bcccc15b45fd47cbc1 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/csun0
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@45bef8d742f1492e58ac37bcccc15b45fd47cbc1 -
Trigger Event:
release
-
Statement type: