Skip to main content

HiData


Build License Read the Docs Test PyPI pre-commit

HiData – hierarchical data

Installation | API | Specification | Design | Changelog

In the same vein as AnnData is designed to represent annotated data and MuData multimodal data, HiData represents hierarchical single-cell data: cells within optional subgroups within groups. A group is any unit that groups cells, such as a donor, a patient, the target gene of a CRISPR screen or a compound, and a subgroup splits it further, such as a sample, a time point, a guide or a dose.

HiData overview

Data structure

HiData
  .G             groups, one row per group (a DataFrame of group labels, or AnnData, MuData, EHRData)
  .S             subgroups, one row per subgroup, optional (DataFrame, AnnData or EHRData)
  .C             cells (AnnData or MuData)
  .obsm          matrices aligned to the groups, such as embeddings or pseudobulk profiles
  .obsp          group by group matrices, such as distances
  .uns           unstructured annotations

C.obs[group_id] names the group of every cell. With a subgroup level, C.obs[subgroup_id] names the subgroup of every cell and S[group_id] the group of every subgroup. Selecting units at one level selects the matching units at the other levels, and matrices in obsm and obsp are subset with them.

Overview

Input

The most common input is an AnnData of cells whose obs repeats labels of their group, such as the disease or age of a patient, on every cell. from_anndata moves the columns that are constant within groups into a group table, so G is a DataFrame with one row per group and C.obs keeps the cell-level columns:

from hidata import HiData

hd = HiData.from_anndata(adata, group_id="patient")
hd.G

A group table can also be passed directly. G is an AnnData only when groups have measurements of their own, such as the genotypes of donors that cellink analyses:

hd = HiData(G=patients, C=adata, group_id="patient")

With several samples per patient, subgroup_id adds the subgroup table S:

hd = HiData.from_anndata(adata, group_id="patient", subgroup_id="sample")

Selection and aggregation

hd = hd.filter_groups("age > 60")
hd = hd.filter_groups_by_cells(20, groupby="cell_type", level="subgroup")
hd.get_df(["age", "timepoint", "CD14"], level="cell")
hd.composition("cell_type", level="subgroup")
profiles = hd.pseudobulk(groupby="cell_type", layer="counts", level="subgroup")
train, test = hd.train_test_split(0.2, stratify="disease")

I/O with .hd.h5 and .hd.zarr files

HiData objects are written to an HDF5 file or a Zarr store with one AnnData or MuData group per level, which can also be read with anndata alone. Files and stores written by donordata are read as well.

import hidata

hd.write_hd("cohort.hd.zarr")
hd = hidata.io.read_hd("cohort.hd.zarr")

Installation

pip install hidata

See the installation guide for optional dependencies.

Tutorials

The tutorials cover a first object, a patient cohort, a CRISPR screen, electronic health records and multiple instance learning on the cells of each patient.

Packages using HiData

cellink holds the genotypes of donors in G and runs single-cell genetics on them, from eQTL mapping and rare variant tests to colocalization and LD score regression. patpy computes representations of patients or samples from their cells and compares them across a cohort.

Citation

If you use HiData, please cite it as described in CITATION.cff.

Metadata

Release files for hidata 0.1.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 hidata 0.1.0
File Size Uploaded Provenance Actions
hidata-0.1.0.tar.gz 2.0 MB With provenance Details for hidata-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.1 MB

Release files / hidata-0.1.0.tar.gz

Download URL hidata-0.1.0.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
b30e128874eec47662f991fb261171f67f5cdef408aefc61c992dbdaed48dce1
BLAKE2b-256 checksum
How to use checksums
2493e2ed542ab501cb067c728a201820a7ba09b784172cbfbb88fb000d04abdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / hidata-0.1.0-py3-none-any.whl

Download URL hidata-0.1.0-py3-none-any.whl
Size 64.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d317c5cb140f3a072c5667a622e4c6cb112b1a990c8526c51264bb105a42a2d
BLAKE2b-256 checksum
How to use checksums
c5e7fd15c44af22f818c2cf7cbd0bcac2fa8f71b1102fb50af12f62bfa80de31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for hidata 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hidata-0.1.0.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 Nov 24, 2026.

Transparency log

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.1.0 This release

2 release files Full 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