Skip to main content

Tests Pre-commit.ci PyPI Docs Build Downloads

Human Neural Organoid Cell Atlas Toolbox

🛠️ The Swiss Army Knive of the Single Cell Cartographer

This package provides a set of tools we used to generate and analyze the Human Neural Organoid Cell Atlas. Among other things, it provides functions to:

  • Rapidly annotate cell types based on marker genes
  • Map query data to the reference atlas
  • Transfer annotations between datasets
  • Compute 'presence scores' for query data based on the reference atlas
  • Perform differential expression analysis

Installation

The latest release of HNOCA-tools can be installed with pip

pip install hnoca

Quick start

🖋️ Annotation

We developed snapseed to rapidly annotate the HNOCA. It annotates cells based on manually defined sets of marker genes for individual cell types or cell type hierarchies. It is fast (i.e. GPU-accelerated) and simple to enable annotation of very large datasets.

import hnoca.snapseed as snap
from hnoca.snapseed.utils import read_yaml

# Read in the marker genes
marker_genes = read_yaml("marker_genes.yaml")

# Annotate anndata objects
snap.annotate(
    adata,
    marker_genes,
    group_name="clusters",
    layer="lognorm",
)

# Or for more complex hierarchies
snap.annotate_hierarchy(
    adata,
    marker_genes,
    group_name="clusters",
    layer="lognorm",
)

🗺️ Mapping

For reference mapping, we mostly rely on scPoli and scANVI. Based on pretrained models, we here provide a simple interface to map query data to the reference atlas.

import scvi
import hnoca.map as mapping

# Load the reference model
ref_model = scvi.model.SCANVI.load(
    os.path.join("model.pt"),
    adata=ref_adata,
)

# Map query data
mapper = mapping.AtlasMapper(ref_model)
mapper.map_query(query_adata, retrain="partial", max_epochs=100, batch_size=1024)

Now that the query dataset is mapped, we can perform kNN-based label transfer and presence score calculation.

# Compute the weighted kNN
mapper.compute_wknn(k=100)

# Transfer labels
celltype_transfer = mapper.transfer_labels(label_key="cell_type")
presence_scores = mapper.get_presence_scores(split_by="batch")

📊 Differential expression

We have used ANOVA for DE analysis between the HNOCA and the reference atlas. Here, this is implemented as the test_de() function.

import hnoca.stats as stats

# Perform DE analysis
de_df = stats.test_de(
    joint_adata,
    group_key="origin",
    return_coef_group="organoid",
    adjust_method="holm",
)

In addition to DE testing on the atlas itself, we found it useful to treat the atlas as a universal "control" and test for DE w.r.t query datasets. For this, we first compute the matched expression profile for each cell in the query dataset and then test for DE using an F-test.

# Compute matched expression profiles based on mapped data
matched_adata = mapper.get_matched_expression()

# Perform DE analysis
de_df = stats.test_de_paired(
    query_adata,
    matched_adata,
    adjust_method="holm",
)

Metadata

Release files for hnoca 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hnoca 0.2.1
File Size Uploaded
hnoca-0.2.1.tar.gz 24.6 MB Details

Built distribution (wheel)

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

Total release size: 24.7 MB

Release files / hnoca-0.2.1.tar.gz

Download URL hnoca-0.2.1.tar.gz
Size 24.6 MB
Tags Source
SHA-256 checksum
How to use checksums
ef711fa55cf35f7648a91ee6c97a66c5d3b0e5afbeea3a3032209a6b402aea00
BLAKE2b-256 checksum
How to use checksums
6ab1de6e98be4bbc73cfe7db645ec9ac641eb3d9b81000c1a66c3010bf8627c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 2, 2025.

Transparency log

Release files / hnoca-0.2.1-py3-none-any.whl

Download URL hnoca-0.2.1-py3-none-any.whl
Size 49.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
922162bccc02328b7c4cc40175c89996fb166da387b2b6acba29e933665130f1
BLAKE2b-256 checksum
How to use checksums
e6d774eb44fc2a2d050e1bd735c918bb1dea761639c190e21d053574a1b5d297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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 Apr 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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