Skip to main content

DemuxHMM

DemuxHMM is a highly performant demultiplexing method for scRNA-seq and other omics. Under the hood, it uses a Hidden Markov Model to capture structure on SNPs when individuals are created with a breeding scheme. DemuxHMM is most powerful with this structure, but it can also work on unstructured datasets. For fast computation, we leverage parallelization on GPU to achieve significantly faster performance than competing methods on large datasets. The manuscript for the method can be seen on bioRxiv. Please cite us if you use the code in your work.

Installation

We offer two installation paths, depending on whether you want to run the benchmarks presented in the paper or not. For simple installation, clone this repo and install it with pip:

git clone https://github.com/antonafana/DemuxHMM && cd DemuxHMM
pip install .

If you want to run benchmarks from the paper, install the optional dependencies with:

pip install .[paper]

Usage

As input, the method expects an array of single-cell variant call matrices A and D. Currently, these should be formatted as an array of length corresponding to the number of chromosomes. A[i] and D[i] should numpy matrices of shape (n_cells, n_snps_chromosome_i) containing allele counts and overall depth for each cell and snp position combination on chromosome i. Cells should already be quality controlled and cleaned of doublets. We suggest CellSNP-lite or similar for variant calling. The method also requires an upper bound on the number of individuals, and an estimate on the number of state changes per chromosome (ex. homozygous reference -> heterozygous). We suggest repeating inference multiple times and using the run with the best model probability. We give an example for a single initialization:

from demuxHMM import HMMModel
from demuxHMM.demuxHMM_utils import adata_to_HMM
import anndata

num_repeats = 30
tolerance = 1
num_individuals = 100 
mean_transitions = 10

# Cells x variants adata. X is variant calls, layers['depth'] is depth
adata = anndata.read_h5ad('variant_calls.h5ad')
A, D = adata_to_HMM(adata, adata.var['chromosome'].unique())

model = HMMModel(A, D, num_individuals, mean_transitions)
model.solve(tolerance)
best_model = model.get_output()

For more complex examples and practical applications, please see the "paper" directory.

Requirements and Future Changes

Currently, the model's GPU mode requires a CUDA capable GPU with multiple GB of VRAM (scaling depending on number of cells and SNPs). If you have suggestions for quality of life improvements please open an issue.

Metadata

Release files for demuxHMM 0.2.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 demuxHMM 0.2.0
File Size Uploaded Provenance Actions
demuxhmm-0.2.0.tar.gz 21.4 kB Without provenance Details for demuxhmm-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for demuxHMM 0.2.0
File Interpreter ABI Platform Actions
demuxhmm-0.2.0-py3-none-any.whl Python 3 none any Details for demuxhmm-0.2.0-py3-none-any.whl

Total release size: 41.7 kB

Release files / demuxhmm-0.2.0.tar.gz

Download URL demuxhmm-0.2.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7783f40b3fb08a023c41d5b1a4bb5af23ddff19157cfa38b12385ad80e821ceb
BLAKE2b-256 checksum
How to use checksums
26f3c5afb55be632d2cf9344c247b4ca5e27eee667dafddcba3b5c5e8330cca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / demuxhmm-0.2.0-py3-none-any.whl

Download URL demuxhmm-0.2.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf266bae58830d700cabb7247c11e42687f10df0bea9edc47692ec943ac055af
BLAKE2b-256 checksum
How to use checksums
a670d3cc3cb229a3694426331ddfe1fbb8284ea10b510fa0a0de72bccd731395
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for demuxHMM 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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