Skip to main content

Unified Hierarchical Annotation Framework for Single-cell Data

Project description

uHAF: a unified hierarchical annotation framework for cell type standardization and harmonization

uHAF is a Python library developed to address the challenges of inconsistent cell type annotations in single-cell transcriptomics, such as varied naming conventions and hierarchical granularity. It integrates organ-specific hierarchical cell type trees (uHAF-T) and a mapping tool (uHAF-Agent) powered by large language models to provide a standardized framework for annotation. By enabling consistent label unification, hierarchical analysis, and integration of diverse datasets, uHAF enhances machine learning applications and facilitates biologically meaningful evaluations. This library is an essential resource for the single-cell research community, fostering collaborative refinement and standardization of cell type annotations.

Explore Online

Installation

Install uHAF via pip:

pip install uhaf

Getting Started

Building uHAF

Start by building a uHAF object for your dataset:

import uhaf as uhaflib

uhaf = uhaflib.build_uhaf(latest=True)
print(len(uhaf.df_uhafs))

This generates a uHAF instance containing annotations for all organs. The example above initializes the uHAF2.2.0 dataset.

Tracing Cell Types

Trace the hierarchical ancestry of a target cell type:

ancestors = uhaf.track_cell_from_uHAF(sheet_name='Lung', cell_type_target='CD8 T cell')
print(ancestors)

Output:

['Cell', 'Lymphocyte', 'T cell', 'CD8 T cell']

Annotation Levels

Retrieve hierarchical annotation levels for cell types. Specify the desired level (e.g., main, middle, or fine).

example_cell_types = ['Pericyte', 'Macrophage', 'Monocyte-derived macrophage', 'Monocyte', 'Dendritic cell']
annotation_level = 2  # Middle cell type level
annotations = uhaf.set_annotation_level(example_cell_types, sheet_name='Heart', annotation_level=annotation_level)
print(annotations)

Example Output:

{'Pericyte': 'Pericyte', 'Macrophage': 'Macrophage', 'Monocyte-derived macrophage': 'Macrophage', 'Monocyte': 'Monocyte', 'Dendritic cell': 'Dendritic cell'}

Mapping Custom Labels

To map custom cell type labels to uHAF:

  1. Prepare unique cell type labels from your dataset:

    original_labels = ['V-CM', 'LA-CM', 'RA-CM', 'Capillary-EC', 'Lymphatic-EC']
    
  2. Generate uHAF-Agent prompts:

    print(uhaf.generate_uhaf_Agent_prompts('Heart', original_labels))
    

    Copy the output and use it on the uHAF-Agent Mapping Website to get the mapped labels.

  3. Use the mapping dictionary to transform your labels:

    mapping_results = {"V-CM": "Ventricle cardiomyocyte cell", "LA-CM": "Atrial cardiomyocyte cell"}
    transformed_labels = [mapping_results[label] for label in original_labels]
    print(transformed_labels)
    

Generating Nested JSON

Export the uHAF tree for a specific organ in nested JSON format:

print(uhaf.dict_uhafs['Heart'])

Contribution

We welcome contributions to improve and expand the uHAF library. For more details, please refer to our contribution guidelines.

License

This project is licensed under the MIT 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

uhaf-0.1.8.tar.gz (428.4 kB view details)

Uploaded Source

Built Distribution

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

uhaf-0.1.8-py3-none-any.whl (426.1 kB view details)

Uploaded Python 3

File details

Details for the file uhaf-0.1.8.tar.gz.

File metadata

  • Download URL: uhaf-0.1.8.tar.gz
  • Upload date:
  • Size: 428.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for uhaf-0.1.8.tar.gz
Algorithm Hash digest
SHA256 873090fde21a569956e5672f49ac4d5b13e66a3ae2e4628cdd01e8be7b15a75c
MD5 a0018cbe34be2fd0e914f60978745480
BLAKE2b-256 bdb7252e5abc804c2719a30212d6a1c3ca909477b6a0ba928fa8cc22d74d29f6

See more details on using hashes here.

File details

Details for the file uhaf-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: uhaf-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 426.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for uhaf-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1b5b491dcd22ee42d2826c03d29c7ace9d2ee77dd24bd6c2070a205b0bb3d1cf
MD5 252d5c2343a6c9e3eb874eb551b5f992
BLAKE2b-256 b440b63354cc6fc2d01e0170922906369644f1d4edb65e1ccfdb8c5ba112715d

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