Skip to main content

Human Neural Organoid Cell Atlas Toolbox

Project description

PyPI version Python version Black

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",
)

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

hnoca-0.1.1.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

hnoca-0.1.1-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file hnoca-0.1.1.tar.gz.

File metadata

  • Download URL: hnoca-0.1.1.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for hnoca-0.1.1.tar.gz
Algorithm Hash digest
SHA256 970062b766ee5f9efd8c0db9fef4455c0ee761f6381f0bb2f7cd9f2ef84e0971
MD5 c6e90dc5eea49827b8ac33a65320e1a0
BLAKE2b-256 995c5a7c23950ec3957256a8e8ac009e96e7a89fdd0b41da1a5a018768dc419e

See more details on using hashes here.

File details

Details for the file hnoca-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hnoca-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for hnoca-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8894c5cc3e1d5cacbaad640021e773e4694abea9a2bf6707b28101911d9d56ef
MD5 acb9045c2d86339796b52ebb4fa53eb5
BLAKE2b-256 7d6e79b9df61611f70e1ba70dc05d88dae45ca1cdfb53dcaf5e5561a1d4caa48

See more details on using hashes here.

Supported by

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