File size: 12,515 Bytes
8ed72b9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
---
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.
# 🏷️ Taxonomy (use standard HF enums where possible)
annotations_creators: [no-annotation]
language_creators: [found]
language: [en]
multilinguality: [monolingual]
source_datasets: [original, external]
size_categories: [">1M"] # change if needed: n<1K | 1K<n<10K | 10K<n<100K | 100K<n<1M | >1M
# 📚 Tasks (use “other” if your task isn’t in HF’s standard list)
task_categories: [other]
task_ids:
- multi-label-classification
- explanation-generation
# 🔖 Tags (free-form keywords)
tags:
- single-cell
- transcriptomics
- foundation-models
# 📄 Licensing & attribution
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
# 🔗 Project links (optional but recommended)
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 structure hints (optional)
dataset_type: multimodal-graph
configs:
- config_name: default
data_files: cell_metadata_with_mappings.csv
# ✅ Maintenance
pretty_format: true
---
# OmniCellTOSG
<!-- markdownlint-disable first-line-h1 -->
<!-- markdownlint-disable html -->
<!-- markdownlint-disable no-duplicate-header -->
<div align="center">
<img src="https://github.com/FuhaiLiAiLab/OmniCellTOSG/blob/main/Figures/OmniCell-logo.png?raw=true" width="55%" alt="OmniCellTOSG Logo" />
</div>
<div align="center">
<a href="https://github.com/FuhaiLiAiLab/OmniCellTOSG">
<img alt="GitHub" src="https://img.shields.io/badge/GitHub-OmniCellTOSG-181717?logo=github">
</a>
<a href="https://huggingface.co/FuhaiLiAiLab">
<img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-FuhaiLiAiLab-ffcc00?color=ffcc00&logoColor=white">
</a>
<a href="https://arxiv.org/pdf/2504.02148" target="_blank">
<img alt="Paper" src="https://img.shields.io/badge/arXiv-2504.02148-b31b1b?logo=arxiv&logoColor=white">
</a>
</div>
---
## 🧭 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**.
<div align="center">
<img src="https://github.com/FuhaiLiAiLab/OmniCellTOSG/blob/main/Figures/Figure2.png?raw=true" alt="Dataset Overview" />
</div>
---
## 📁 Dataset Structure
```text
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](https://github.com/FuhaiLiAiLab/OmniCellTOSG/releases/tag/v2.1.0) page.
---
## 🚀 Quick Start
```python
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
```bash
python pretrain.py
```
---
## 🏋️ Training Examples (CLI)
**Disease status (AD, brain)**
```bash
# 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)**
```bash
# 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)**
```bash
# 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**
```bash
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:
- **CellxGENE Terms of Service** — Follow the platform’s ToS for data access, reuse, and sharing.
🔗 https://cellxgene.cziscience.com/tos
- **Brain Cell Atlas (citation required)**
*Cite:*
Xinyue Chen#, Yin Huang#, Liangfeng Huang#, Ziliang Huang#, Zhao-Zhe Hao#, Lahong Xu, Nana Xu, Zhi Li, Yonggao Mou, Mingli Ye, Renke You, Xuegong Zhang, Sheng Liu*, Zhichao Miao*. **A brain cell atlas integrating single-cell transcriptomes across human brain regions.** *Nat Med* (2024). https://doi.org/10.1038/s41591-024-03150-z
- **GEO Citation Policy** — Follow NCBI GEO guidelines for citing datasets and third-party analyses.
🔗 https://www.ncbi.nlm.nih.gov/geo/info/citations.html#third-party
- **HCA Data Use Agreement**
🔗 https://data.humancellatlas.org/about/data-use-agreement
> **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:
```bibtex
@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}
}
``` |