CellPack
Compact single-cell storage. Fast random access. Ready for AnnData.
Website · Issues · MIT License
CellPack stores expression matrices as compact, independently decodable cell records. Read individual cells or shuffled batches without decoding their neighbours, work with datasets larger than memory, and keep your AnnData annotations alongside the compressed matrices.
The storage engine and loader are written in Rust. pycellpack brings them
to Python, with NumPy, SciPy, AnnData and PyTorch integrations.
What you can do
- Compress without losing values. Shared statistical models capture sparse matrix structure while each cell remains independently decodable.
- Read just the cells and genes you need. Lazy matrix views support slicing, masks and reordered selections; materialize the selected data as dense or CSR.
- Keep annotated datasets together. H5CP embeds CellPack matrices in one HDF5 file alongside AnnData annotations, layers, embeddings and metadata.
- Load shuffled data beyond RAM. Asynchronous I/O overlaps reads and decoding; bounded buffers deliver batches in the requested sampling order.
- Make reuse count. A planner uses the supplied access sequence to allocate a cache budget between compressed pages and decoded rows.
- Feed model inputs directly. Align genes across datasets, apply native preprocessing and deliver PyTorch batches on CPU or CUDA. Presets cover scGPT, Geneformer, UCE and STATE SE.
AnnData, with compressed matrices
Start with an ordinary AnnData object, including one from an existing Scanpy workflow. Write it once, then select cells and genes before decoding:
import anndata as ad
import numpy as np
import pycellpack as cp
adata = ad.AnnData(X=np.array([[0, 2, 0], [1, 0, 3]], dtype=np.float32))
adata.obs_names = ["cell-a", "cell-b"]
adata.var_names = ["ACTB", "GAPDH", "CD3D"]
adata.layers["counts"] = adata.X.copy()
# One portable file: compressed matrices and their annotations.
cp.write_h5cp("cells.h5cp", adata, encode=True)
cells = cp.read_h5("cells.h5cp", lazy=True)
# AnnData slicing keeps the embedded matrices lazy.
subset = cells[["cell-b"], ["CD3D", "ACTB"]]
small = subset.to_memory()
print(small.X) # [[3. 1.]]
# Export an ordinary H5AD for downstream tools.
cp.write_h5ad("subset.h5ad", small)
encode=True compresses numeric matrix slots; lazy=True keeps embedded
matrices on disk while annotations are loaded into memory. Decode a subset
with to_memory() before passing it to tools that expect NumPy or SciPy
matrices. H5CP is read through pycellpack; write_h5ad() exports standard H5AD.
For training, ScDataset.from_anndata(cells, ids=gene_ids) connects a lazy
matrix to ScDataLoader. Supply one vocabulary ID per gene and your own sample
order; the loader handles alignment, preprocessing and batch delivery.
Performance
The figures below are newly drawn from frozen experimental results. They describe the experimental implementation used for the technical report, rather than benchmarks of the current commit.
Compact storage
CellPack reaches 5.89× compression while retaining per-cell decoding. Ratios are means across raw and normalized matrix blocks: 734 for CellPack and 724 for the other codecs. These are corpus summaries, not a paired-input comparison or a ranking of decoding speed.
Random-order loading
On one NVMe SSD with 16 workers, the report gives 1.165M cells/s for CellPack without a data cache. Baselines use a 20 GB cache and their best variant, averaged over three seeds. CellPack's point is the report's author-selected value for a 5 s post-warm-up check, without a variance estimate; baselines use 60 s measurement windows. CellPack emits a fixed 2,048-gene panel; baselines use their sample-output paths. Only global random-order methods are shown.
The figure data and provenance record the exact
values and source hashes. Both figures can be regenerated with
uv run scripts/plot_readme.py.
Install
From a repository checkout, with a Rust toolchain installed:
# Python 3.12+ for AnnData integration (pinned to AnnData 0.13.4).
uv add '/path/to/CellPack[anndata]'
# Or install the matrix storage and loader core (Python 3.10–3.15).
uv add /path/to/CellPack
CellPack targets Linux. The default loader uses io_uring; a pread backend
is available where io_uring is disabled. Install PyTorch separately for
ScDataLoader, choosing the build appropriate for your device.
License
MIT.
Metadata
Release files for pycellpack 0.1.0
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 |
|---|---|---|---|---|
| pycellpack-0.1.0.tar.gz | 794.5 kB | Without provenance | Details for pycellpack-0.1.0.tar.gz |
Built distributions (wheels)
Total release size: 104.2 MB
Release files / pycellpack-0.1.0.tar.gz
| Download URL | pycellpack-0.1.0.tar.gz |
|---|---|
| Size | 794.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
298bf5cb589e21d0e58c40c0695baca7ff4a25421c8f5c07ce3d12babaadc1be
|
|
BLAKE2b-256 checksum How to use checksums |
19da06a32d7083ee4f547cefe10b0d578907d34934409a14695dd6e5caf2b4fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp315-cp315-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp315-cp315-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
49df3414358fc2e7f76e776fa6ab5d714b1563f74e6bd3e452e3494aa420d684
|
|
BLAKE2b-256 checksum How to use checksums |
b982ed10bc53296316cfe24336bb2f7ed0037039f8d7038252d31553857b2b7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp315-cp315-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp315-cp315-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
137d161ebc5835697856cbf435b8d0adac25666961a12be418675b7dd37be438
|
|
BLAKE2b-256 checksum How to use checksums |
4fe57965ed4e14777007cdf0b7ac8ad33ef2192becec5ee780cbf054df8a1b75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp314-cp314-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp314-cp314-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d431198283bdf68ca7010e23b81765ee844261ebe99dfe3e4cd4fbd288fc27dc
|
|
BLAKE2b-256 checksum How to use checksums |
1c3779eddd7e4ed4e920bd7621a957860aa18209ada1d4974b99f49fbffa8ad8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp314-cp314-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp314-cp314-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
b382c201ce82240224da44029c86e3ff1fa06cfe5712167a3c198043af0799e5
|
|
BLAKE2b-256 checksum How to use checksums |
5a1d2bd33e521d0e83703b4a8ca2a9144dbc0e858a8e00ac43cab169f3c7eeae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
9650631fefe9c0936e16c70f0d17f6623b7c4ea1ec34571389d28ce53b7c8f75
|
|
BLAKE2b-256 checksum How to use checksums |
95b746d7cd857f09c9f0cb318a4f0aa266b32fc6dd40dab58ff78ad1aa727961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
1f0cecf249b88edd1590817cbf75ffd39945d729b697edcdcff6e9234f3e5676
|
|
BLAKE2b-256 checksum How to use checksums |
3d9b19ccb8c2ce708e6e25df0c8aac75dbd413ad915e8e8f7d5adc8e03acc6e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
00b1f855e97649f192b77f1cf99cd9731893747d1409d5448d30912b35dc3efd
|
|
BLAKE2b-256 checksum How to use checksums |
1343d03a529a146dee0ac03617206c5b23eab86b3ea4df0407ba3851c866dba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
5f89623f74c3d1cfa0579f6e1e12f8b2aa55e776b247a208dacd10f6c1a79e1c
|
|
BLAKE2b-256 checksum How to use checksums |
89a11f187dcb887072c6fdd3f28c1508936b04a29a2d8df7965f342f67fd619e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f293b22196a733aeec442d8e5a0cab78c1f7658c4dab5a5c90b5a5f120d8896d
|
|
BLAKE2b-256 checksum How to use checksums |
c30e51abc352161cecfff117cfe29b79a6ebe65b627c5a5e70abac9afc8bba61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp311-cp311-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp311-cp311-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
c1330a03ed92e6538474e7c4e006d562640f2306b4bda7d619d5398c5d61f2ff
|
|
BLAKE2b-256 checksum How to use checksums |
0891fc1302d662b65367247897bd79e691572f8de5aa1312a2101789353cb816
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | pycellpack-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
72f70269072d81e35bea76ecf978cf2ca94199669b8a681cd12a0870c4301ed2
|
|
BLAKE2b-256 checksum How to use checksums |
8cbaafaa0465c45c3a0cca9a21335cdf87b54d3c0f53f38fb5bcbd4a88d2bbed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / pycellpack-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl
| Download URL | pycellpack-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 8.4 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
7671f309da1d50abbf364c58e4d8e03daec0718a08780d31f301ba76c1915eb7
|
|
BLAKE2b-256 checksum How to use checksums |
9df6f8da38a7cdfe9a9d7aca670226483df39cc7310ee5b3f4660ec86f876755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for pycellpack 0.1.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.