Skip to main content

Unified Hierarchical Annotation Framework for Single-cell Data

Project description

uHAF: Unified Hierarchical Annotation Framework for Single-cell Data

Introduction

The surge in single-cell transcriptomics has led to vast datasets but also to inconsistencies in cell type annotations across studies. Different researchers may label the same cell type with varying names or levels of detail—for example, "cardiomyocyte," "CM," or "heart muscle cell." These discrepancies hinder the comparability of cell labels, affecting machine learning training, evaluation, and data integration.

While efforts like the Cell Ontology aim to standardize nomenclature, limitations exist, such as lack of organ-specific details and user-friendly mapping tools. To tackle these challenges, we introduce uHAF, a unified hierarchical annotation framework providing organ-specific cell type hierarchies. With accompanying Python packages, uHAF allows users to unify cell type annotations to consistent granularity or navigate between different hierarchical levels.

Additionally, we developed uHAF-GPT, leveraging large language models to map various cell type aliases to uHAF nodes, facilitating rapid unification of labels from diverse datasets. This makes cell type labels comparable across studies, enhancing data integration, machine learning applications, and downstream analyses. We also offer evaluation metrics based on uHAF, enabling fair and biologically meaningful assessment of cell type annotations.

Features

  • Hierarchical Cell Type Trees: Provides organ-specific hierarchical structures of cell types.
  • Python Integration: Includes Python classes and functions for easy manipulation and mapping of cell types.
  • uHAF-GPT Integration: Utilizes large language models to map diverse cell type names to standardized uHAF nodes.
  • Customizable Granularity: Allows users to unify annotations to specific hierarchical levels or trace back to broader categories.
  • Evaluation Metrics: Offers a set of metrics for assessing cell type annotations based on hierarchical relationships.
  • User-Friendly: Designed to be accessible for researchers with varying levels of computational expertise.

Installation

Prerequisites

  • Python 3.6 or higher
  • Required Python packages:
    • pandas
    • numpy
    • tqdm
    • openpyxl (for reading Excel files)

Installation Steps

  1. Clone the Repository
git clone https://github.com/yourusername/uHAF.git
  1. Navigate to the Directory
cd uHAF
  1. Install Required Packages

Install the required Python packages using pip:

pip install pandas numpy tqdm openpyxl

Usage

Loading uHAF

To start using uHAF, you need to load the uHAF Excel file and initialize the uHAF class.

import os
import pandas as pd
from yourmodule import uHAF, build_uhaf
# Specify the version of the uHAF Excel file
uhaf_xlsx_version = 'uHAF_v1'
# Build the uHAF object
uhaf = build_uhaf(uhaf_xlsx_version)

Accessing Organ-Specific Hierarchies

You can generate uHAF for specific organs by specifying the sheet names:

target_sheetnames = ['Heart', 'Lung']
uhaf = build_uhaf(uhaf_xlsx_version, target_sheetnames)

Mapping Cell Types

To map custom cell types to the uHAF framework:

sheet_name = 'Heart'
custom_cell_types = ['CM', 'cardiomyocyte', 'heart muscle cell']
# Generate GPT prompts for mapping
prompts = uhaf.generate_uhaf_GPTs_prompts(sheet_name, custom_cell_types)
print(prompts)

Navigating Hierarchical Levels

To unify cell type annotations to a specific hierarchical level:

query_cell_types = ['Ventricular Cardiomyocyte', 'Atrial Cardiomyocyte']
annotation_level = 2  # Specify the desired level
# Get the mapping to the specified level
annotation_level_map = uhaf.set_annotation_level(query_cell_types, sheet_name, annotation_level)
print(annotation_level_map)

Tracing Cell Lineage

To trace the hierarchical path from a specific cell type back to the root:

cell_type_target = 'Ventricular Cardiomyocyte'
trace = uhaf.track_cell_from_uHAF(sheet_name, cell_type_target)
print(" -> ".join(trace))

Example

Here's a complete example demonstrating how to unify custom cell type annotations:

import os
import pandas as pd
from yourmodule import uHAF, build_uhaf
# Build uHAF for the 'Heart' organ
uhaf = build_uhaf('uHAF_v1', target_sheetnames=['Heart'])
# Custom cell types to map
custom_cell_types = ['CM', 'cardiomyocyte', 'heart muscle cell']
# Generate GPT prompts
prompts = uhaf.generate_uhaf_GPTs_prompts('Heart', custom_cell_types)
print(prompts)
# Set annotation level
annotation_level_map = uhaf.set_annotation_level(custom_cell_types, 'Heart', annotation_level=2)
print(annotation_level_map)

Contributing

We welcome contributions from the community. If you have suggestions for improvements or new features,please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

We would like to thank all contributors and the wider scientific community for their support andcollaboration.

Contact

For questions or inquiries, please contact your.email@example.com.

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.1.tar.gz (9.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.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uhaf-0.1.1.tar.gz
  • Upload date:
  • Size: 9.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.1.tar.gz
Algorithm Hash digest
SHA256 285b1ab72621cc39bea83b5e80a9cdc6dd2fd2e9d2636454ca8059dfa2c15dba
MD5 091b1756e279da0944a94104c769e6de
BLAKE2b-256 7d99c712b4904469640fc84e569dd5ec54e0ce02c0e5cc48a1ad6f2f3a9a483d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: uhaf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 624e5b450cf533a13544c63b46d127a885a62fe45e6a7e657aeaaca38a4dbe20
MD5 88407c3e04e27f38d8dd5e921b6a3286
BLAKE2b-256 66ae05db68cd56509211ce267ffa956734267cbca14c566bac983fa7b2aad812

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