Skip to main content

Efficient storage and access for large single-cell RNA datasets (supports Zarr and H5AD formats)

Project description

zdata

Efficient sparse matrix storage and retrieval for large-scale transcriptomics datasets using seekable Zstandard compression.


What is zdata?

zdata is a Python library designed for bioinformaticians working with large single-cell RNA-seq datasets. It allows you to:

  • Store large datasets efficiently using block-based compression
  • Query specific cells or genes quickly without loading entire matrices into memory
  • Convert existing datasets from Zarr or H5AD (AnnData) into a fast, queryable format

Think of zdata as a compressed, random-access backend for single-cell expression data.


Overview

zdata uses a custom on-disk format optimized for sparse single-cell data:

  • Block-compressed CSR layout
    Expression data are grouped into small row blocks (e.g. 16 cells per block) for fast access.

  • Seekable Zstandard compression
    Enables random access without decompressing entire files.

  • Chunked storage
    Large datasets are split into multiple chunk files (e.g. 8192 cells per file), enabling scalability to millions of cells.

This design provides excellent compression ratios while maintaining fast random access.


Features

  • Fast random access to individual cells
  • Efficient disk compression
  • Scales to millions of cells and genes
  • Simple Python API
  • Supports Zarr and H5AD (AnnData) inputs
  • Automatic detection of mixed input formats
  • Optional column-major (gene-based) queries

Installation

Recommended: Install from PyPI

zdata can be installed directly from PyPI and does not require manual compilation of ZSTD.

pip install zdata-py

📦 PyPI package: http://pypi.org/project/zdata-py/


Installing from source (developers only)

git clone <repository-url>
cd zdata
pip install -e .

Quick Start Guide

Building a zdata Dataset

zdata builds a compressed dataset from a directory containing:

  • Zarr directories (*.zarr/)
  • H5AD / HDF5 files (*.h5, *.hdf5, *.h5ad)

Mixed formats are supported.

Validate input data

python -m zdata.build_zdata.check_directory /path/to/data

Build the dataset

from zdata import build_zdata_from_zarr

zdata_dir = build_zdata_from_zarr(
    zarr_dir="/path/to/data",
    output_name="my_dataset.zdata",
    block_rows=16,
    max_rows=8192,
    obs_join_strategy="outer"
)

Opening a Dataset

from zdata import ZData

reader = ZData("my_dataset.zdata")
print(reader.shape)

Querying Data

Row-based (cells)

adata = reader[0:100]
adata = reader[[0, 10, 20]]

Raw sparse matrix:

csr = reader.read_rows_csr([0, 100, 200])

Column-based (genes)

Requires column-major (X_CM) support.

matrix = reader["GAPDH"]
matrix = reader[["GAPDH", "PCNA"]]

Memory Estimation

estimate = reader.estimate_memory_requirements(row_indices=[0, 1, 2])
print(estimate["estimated_memory_gb"])

Command-Line Tools

Convert MTX to zdata:

./ctools/mtx_to_zdata matrix.mtx output_name

Read rows:

./ctools/zdata_read --binary output_name.zdata/0.bin "100,200,300"

Project Structure

zdata/
├── core/
├── build_zdata/
├── ctools/
├── files/
└── tests/

Testing

pytest tests/

Performance

Optimized for random-access cell queries, compression efficiency, and scalability to millions of cells.


License

See the LICENSE file for details.

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

zdata_py-0.1.6.tar.gz (519.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zdata_py-0.1.6-py3-none-any.whl (518.7 kB view details)

Uploaded Python 3

File details

Details for the file zdata_py-0.1.6.tar.gz.

File metadata

  • Download URL: zdata_py-0.1.6.tar.gz
  • Upload date:
  • Size: 519.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for zdata_py-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1992597a59d7f820b5d880d74c811b40eaefadd93a6f94727a789cdcd7f007d4
MD5 a917087b4f86da9c08b478d839a9f5e5
BLAKE2b-256 8293224b9138295d88b61f33253eeae7050146bb574ed0ed02c6f864dca0f724

See more details on using hashes here.

File details

Details for the file zdata_py-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: zdata_py-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 518.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for zdata_py-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 946f16c0a9f3497e7ca1532e6b5f82cf2b834a8e71fe388b76cc26dddabaece3
MD5 d9936b2f63f5d024e6e863223512f7e4
BLAKE2b-256 5550a8c7ac72c4c19e52743af8b30f30d52cbbf9a95ddfd96610ab8d8efb8847

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page