tim-x's picture
Upload README.md
b71b714 verified
metadata
pretty_name: OmniCellTOSG
dataset_name: omnicelltosg
dataset_summary: >
  OmniCellTOSG is a large-scale Text–Omic Signaling Graph (TOSG) dataset for
  single-cell learning.

  It integrates sharded expression matrices, graph topology (full/internal/PPI
  edges), and textual

  entity metadata (names, descriptions, sequences) with optional precomputed
  embeddings. It supports

  graph-aware pretraining and downstream tasks such as cell-type annotation,
  disease status, and gender classification.
annotations_creators:
  - no-annotation
language_creators:
  - found
language:
  - en
multilinguality:
  - monolingual
source_datasets:
  - original
  - external
size_categories:
  - '>1M'
task_categories:
  - other
task_ids:
  - multi-label-classification
  - explanation-generation
tags:
  - single-cell
  - transcriptomics
  - foundation-models
license: other
license_url:
  - https://cellxgene.cziscience.com/tos
  - https://doi.org/10.1038/s41591-024-03150-z
  - https://www.ncbi.nlm.nih.gov/geo/info/citations.html#third-party
homepage: https://github.com/FuhaiLiAiLab/OmniCellTOSG
repository: https://github.com/FuhaiLiAiLab/OmniCellTOSG
paper: https://arxiv.org/pdf/2504.02148
point_of_contact: Heming Zhang
dataset_type: multimodal-graph
configs:
  - config_name: default
    data_files: cell_metadata_with_mappings.csv
pretty_format: true

OmniCellTOSG

OmniCellTOSG Logo

🧭 Overview

OmniCellTOSG is a large-scale Text–Omic Signaling Graph (TOSG) resource for single-cell foundation model pretraining and omics analysis. It combines:

  • Expression matrices (sharded .npy for scalable IO)
  • Graph topology (full, internal, and PPI edges)
  • Textual metadata (entity names, descriptions, sequences) with precomputed embeddings

Supported tasks include graph–language foundation model pretraining, cell-type annotation, disease status and gender classification, plus core signaling inference.

Dataset Overview

📁 Dataset Structure

OmniCellTOSG_Dataset/
├── expression_matrix/
│ ├── braincellatlas_brain_part_0.npy
│ ├── braincellatlas_brain_part_1.npy
│ ├── cellxgene_blood_part_0.npy
│ ├── cellxgene_blood_part_1.npy
│ ├── cellxgene_lung_part_0.npy
│ ├── cellxgene_small_intestine_part_0.npy
│ └── ... (additional *.npy shards)
├── cell_metadata_with_mappings.csv
├── cell_metadata_with_mappings.parquet
├── edge_index.npy
├── internal_edge_index.npy
├── ppi_edge_index.npy
├── s_bio.csv
├── s_desc.csv
├── s_name.csv
├── x_bio_emb.npy
├── x_desc_emb.npy
└── x_name_emb.csv

Notes:

  • Files in expression_matrix/*.npy are sharded partitions of single-cell expression matrices; merge shards (concatenate/stack) to reconstruct the full matrix for a given source/organ.
  • cell_metadata_with_mappings.csv contains standardized per-cell annotations (e.g., tissue, disease, sex, cell type, ontology mappings).
  • edge_index.npy, s_bio.csv, s_name.csv, and s_desc.csv provide the graph topology (COO [2, E]) and entity metadata (biological sequences, names, descriptions).
  • x_bio_emb.npy, x_desc_emb.npy, and x_name_emb.csv are precomputed entity embeddings ([#entities × D], encoder-dependent) aligned to the CSVs—use these to skip on-the-fly embedding.

⚙️ Installation

If you only need dataset loading/extraction, download the standalone loader package from the Releases page.


🚀 Quick Start

from CellTOSG_Loader import CellTOSGDataLoader

conditions = {"tissue_general": "brain", "disease_name": "Alzheimer's Disease"}

ddataset = CellTOSGDataLoader(
    root=args.dataset_root,
    conditions=conditions,
    task=args.task,                          # "disease" | "gender" | "cell_type"
    label_column=args.label_column,          # "disease" | "gender" | "cell_type"
    sample_ratio=args.sample_ratio,          # mutually exclusive with sample_size
    sample_size=args.sample_size,
    shuffle=args.shuffle,
    stratified_balancing=args.stratified_balancing,
    extract_mode=args.extract_mode,          # "inference" | "train"
    random_state=args.random_state,
    train_text=args.train_text,
    train_bio=args.train_bio,
    correction_method=args.correction_method, # None | "combat_seq"
    output_dir=args.output_dir,
)

# --- Access outputs ---
if args.extract_mode == "inference":
    X = dataset.data                         # pandas.DataFrame (expression/features)
    y = dataset.labels                       # pandas.DataFrame
    metadata = dataset.metadata              # pandas.DataFrame (row-aligned metadata)
else:
    X = dataset.data                         # dict: {"train": X_train, "test": X_test}
    y = dataset.labels                       # dict: {"train": y_train, "test": y_test}
    metadata = dataset.metadata              # dict: {"train": meta_train, "test": meta_test}

all_edge_index = dataset.edge_index                   # full graph (COO [2, E])
internal_edge_index = dataset.internal_edge_index     # optional transcript–protein edges
ppi_edge_index = dataset.ppi_edge_index               # optional PPI edges     
x_name_emb, x_desc_emb, x_bio_emb = pre_embed_text(args, dataset, pretrain_model, device) # Prepare text and seq embeddings

Parameters (CellTOSGDataLoader)

  • root (str, required) — Filesystem path to the dataset root (e.g., ../OmniCellTOSG/CellTOSG_dataset_v2).
  • conditions (dict, required) — Metadata filters used to subset rows
    (e.g., {"tissue_general": "brain", "disease": "Alzheimer's disease"}).
  • task (str, required) — Downstream task type: "disease" | "gender" | "cell_type".
  • label_column (str, required) — Target label column (e.g., "disease", "gender", "cell_type").
  • extract_mode (str, required) — Extraction mode:
    • "inference": extract a single dataset for inference/analysis (no train/test split)
    • "train": extract a training-ready dataset and generate splits (e.g., train/test)
  • sample_ratio (float, optional) — Fraction of rows to sample (0–1). Mutually exclusive with sample_size.
  • sample_size (int, optional) — Absolute number of rows to sample. Mutually exclusive with sample_ratio.
  • shuffle (bool, default: False) — Shuffle rows during sampling/composition.
  • stratified_balancing (bool, default: False) — Enable stratified sampling / class balancing based on label_column.
  • random_state (int, default: 2025) — Random seed for reproducibility (sampling, shuffling, splitting).
  • train_text (bool, default: False) — Controls text feature output:
    • False: return precomputed text embeddings (if available)
    • True: return raw text fields for custom embedding
  • train_bio (bool, default: False) — Controls biological sequence feature output:
    • False: return precomputed sequence embeddings (if available)
    • True: return raw sequences for custom embedding
  • correction_method (str or None, default: None) — Correction method:
    • None: no correction
    • "combat_seq": apply ComBat-Seq
  • output_dir (str, optional) — Directory for loader outputs (extracted expression matrix, label,splits).

Returns:

  • extract_mode="inference":
    • dataset.data: pandas.DataFrame
    • dataset.labels: pandas.DataFrame
    • dataset.metadata: pandas.DataFrame
  • extract_mode="train":
    • dataset.data: dict ({"train": X_train, "test": X_test})
    • dataset.labels: dict ({"train": y_train, "test": y_test})
    • dataset.metadata: dict ({"train": meta_train, "test": meta_test})
  • edge_index, internal_edge_index, ppi_edge_index: graph topological information
  • Either raw text/sequence fields (s_name, s_desc, s_bio) or their precomputed embeddings (x_name_emb, x_desc_emb, x_bio_emb), returned according to the train_text/train_bio flags.

🧪 Pretraining

python pretrain.py

🏋️ Training Examples (CLI)

Disease status (AD, brain)

# Alzheimer's Disease (Take AD as an example)
python train.py \
  --downstream_task disease \
  --label_column disease \
  --tissue_general brain \
  --disease_name "Alzheimer's Disease" \
  --sample_ratio 0.1 \
  --train_base_layer gat \
  --train_lr 0.0005 \
  --train_batch_size 3 \
  --random_state 42 \
  --dataset_output_dir ./Data/train_ad_disease_0.1_42

Gender (AD, brain)

# Alzheimer's Disease (Take AD as an example)
python train.py \
  --downstream_task gender \
  --label_column gender \
  --tissue_general brain \
  --disease_name "Alzheimer's Disease" \
  --sample_ratio 0.1 \
  --train_base_layer gat \
  --train_lr 0.0005 \
  --train_batch_size 2 \
  --random_state 42 \
  --dataset_output_dir ./Data/train_ad_gender_0.1_42

Cell type annotation (LUAD, lung)

# Lung (LUAD) (Take LUAD as an example)
python train.py \
  --downstream_task cell_type \
  --label_column cell_type \
  --tissue_general "lung" \
  --disease_name "Lung Adenocarcinoma" \
  --sample_ratio 0.2 \
  --train_base_layer gat \
  --train_lr 0.0001 \
  --train_batch_size 3 \
  --random_state 42 \
  --dataset_output_dir ./Data/train_luad_celltype_0.2_42

Signaling inference

python analysis.py

⚖️ Licensing & Attribution

This dataset aggregates data from CellxGENE, the Brain Cell Atlas, GEO and HCA. Use of these resources is governed by their respective terms and citation policies:

Note: You are responsible for ensuring compliance with the licenses/terms and for providing appropriate attribution to each source in any publications or derived works.


📚 Citation

If you use OmniCellTOSG, please cite:

@misc{omnicelltosg2025,
  title  = {OmniCellTOSG: A Text–Omic Signaling Graph Dataset for Single-Cell Learning},
  author = {Zhang, Heming and Li, Fuhai and collaborators},
  year   = {2025},
  note   = {Dataset on Hugging Face},
  url    = {https://huggingface.co/FuhaiLiAiLab}
}