tim-x commited on
Commit
e7e8da9
·
verified ·
1 Parent(s): f0d5779

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +273 -0
README.md ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: OmniCellTOSG
3
+ dataset_name: omnicelltosg
4
+ dataset_summary: |
5
+ OmniCellTOSG is a large-scale Text–Omic Signaling Graph (TOSG) dataset for single-cell learning.
6
+ It integrates sharded expression matrices, graph topology (full/internal/PPI edges), and textual
7
+ entity metadata (names, descriptions, sequences) with optional precomputed embeddings. It supports
8
+ graph-aware pretraining and downstream tasks such as cell-type annotation, disease status, and gender classification.
9
+
10
+ # 🏷️ Taxonomy (use standard HF enums where possible)
11
+ annotations_creators: [no-annotation]
12
+ language_creators: [found]
13
+ language: [en]
14
+ multilinguality: [monolingual]
15
+ source_datasets: [original, external]
16
+ size_categories: [">1M"] # change if needed: n<1K | 1K<n<10K | 10K<n<100K | 100K<n<1M | >1M
17
+
18
+ # 📚 Tasks (use “other” if your task isn’t in HF’s standard list)
19
+ task_categories: [other]
20
+ task_ids:
21
+ - multi-label-classification
22
+ - explanation-generation
23
+
24
+ # 🔖 Tags (free-form keywords)
25
+ tags:
26
+ - single-cell
27
+ - transcriptomics
28
+ - foundation-models
29
+
30
+ # 📄 Licensing & attribution
31
+ license: other
32
+ license_url:
33
+ - https://cellxgene.cziscience.com/tos
34
+ - https://doi.org/10.1038/s41591-024-03150-z
35
+ - https://www.ncbi.nlm.nih.gov/geo/info/citations.html#third-party
36
+
37
+ # 🔗 Project links (optional but recommended)
38
+ homepage: https://github.com/FuhaiLiAiLab/OmniCellTOSG
39
+ repository: https://github.com/FuhaiLiAiLab/OmniCellTOSG
40
+ paper: "https://arxiv.org/pdf/2504.02148"
41
+ point_of_contact: "Heming Zhang"
42
+
43
+ # 🧩 Dataset structure hints (optional)
44
+ dataset_type: multimodal-graph
45
+ configs:
46
+ - config_name: default
47
+ data_files: cell_metadata_with_mappings.csv
48
+
49
+ # ✅ Maintenance
50
+ pretty_format: true
51
+ ---
52
+
53
+
54
+ # OmniCellTOSG
55
+
56
+ <!-- markdownlint-disable first-line-h1 -->
57
+ <!-- markdownlint-disable html -->
58
+ <!-- markdownlint-disable no-duplicate-header -->
59
+
60
+ <div align="center">
61
+ <img src="https://github.com/FuhaiLiAiLab/OmniCellTOSG/blob/main/Figures/OmniCell-logo.png?raw=true" width="55%" alt="OmniCellTOSG Logo" />
62
+ </div>
63
+
64
+ <div align="center">
65
+ <a href="https://github.com/FuhaiLiAiLab/OmniCellTOSG">
66
+ <img alt="GitHub" src="https://img.shields.io/badge/GitHub-OmniCellTOSG-181717?logo=github">
67
+ </a>
68
+ <a href="https://huggingface.co/FuhaiLiAiLab">
69
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-FuhaiLiAiLab-ffcc00?color=ffcc00&logoColor=white">
70
+ </a>
71
+ <a href="https://arxiv.org/pdf/2504.02148" target="_blank">
72
+ <img alt="Paper" src="https://img.shields.io/badge/arXiv-2504.02148-b31b1b?logo=arxiv&logoColor=white">
73
+ </a>
74
+ </div>
75
+
76
+ ---
77
+
78
+ ## 🧭 Overview
79
+
80
+ **OmniCellTOSG** is a large-scale **Text–Omic Signaling Graph (TOSG)** resource for **single-cell foundation model pretraining** and **omics analysis**. It combines:
81
+ - **Expression matrices** (sharded `.npy` for scalable IO)
82
+ - **Graph topology** (full, internal, and PPI edges)
83
+ - **Textual metadata** (entity names, descriptions, sequences) with **precomputed embeddings**
84
+
85
+ Supported tasks include **graph–language foundation model pretraining**, **cell-type annotation**, **disease status** and **gender** classification, plus **core signaling inference**.
86
+
87
+ <div align="center">
88
+ <img src="https://github.com/FuhaiLiAiLab/OmniCellTOSG/blob/main/Figures/Figure2.png?raw=true" alt="Dataset Overview" />
89
+ </div>
90
+
91
+ ---
92
+
93
+ ## 📁 Folder Layout
94
+
95
+ ```text
96
+ OmniCellTOSG_Dataset/
97
+ ├── expression_matrix/
98
+ │ ├── braincellatlas_brain_part_0.npy
99
+ │ ├── cellxgene_blood_part_0.npy
100
+ │ └── ... (additional *.npy shards)
101
+ ├── cell_metadata_with_mappings.csv
102
+ ├── edge_index.npy
103
+ ├── s_bio.csv
104
+ ├── s_desc.csv
105
+ ├── s_name.csv
106
+ ├── x_bio_emb.npy
107
+ ├── x_desc_emb.npy
108
+ └── x_name_emb.csv
109
+ ```
110
+
111
+ > **Notes**
112
+ > - 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.
113
+ > - `cell_metadata_with_mappings.csv` contains **standardized per-cell annotations** (e.g., tissue, disease, sex, cell type, ontology mappings).
114
+ > - `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).
115
+ > - `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**.
116
+
117
+ ---
118
+
119
+ ## ⚙️ Installation
120
+
121
+ ```bash
122
+ pip install git+https://github.com/FuhaiLiAiLab/OmniCellTOSG
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 🚀 Quick Start
128
+
129
+ ```python
130
+ from CellTOSG_Loader.data_loader import CellTOSGDataLoader
131
+
132
+ conditions = {"tissue_general": "brain", "disease_name": "Alzheimer's Disease"}
133
+
134
+ dataset = CellTOSGDataLoader(
135
+ root="/path/to/OmniCellTOSG_Dataset",
136
+ conditions=conditions,
137
+ downstream_task="cell_type", # "disease" | "gender" | "cell_type"
138
+ label_column="cell_type",
139
+ sample_ratio=0.10,
140
+ shuffle=True,
141
+ balanced=False,
142
+ train_text=False, # False → use precomputed x_name_emb / x_desc_emb
143
+ train_bio=False, # False → use precomputed x_bio_emb
144
+ random_state=42,
145
+ output_dir="./Output/data_ad_celltype_0.1",
146
+ )
147
+
148
+ x_all = dataset.data # dict: {x_name_emb, x_desc_emb, x_bio_emb, ...}
149
+ y_all = dataset.labels # labels aligned to rows
150
+ all_edge_index = dataset.edge_index # full graph (COO [2, E])
151
+ internal_edge_index = dataset.internal_edge_index # optional transcript–protein edges
152
+ ppi_edge_index = dataset.ppi_edge_index # optional PPI edges
153
+ x_name_emb, x_desc_emb, x_bio_emb = pre_embed_text(args, dataset, pretrain_model, device) # Prepare text and seq embeddings
154
+ ```
155
+
156
+ ### Parameters (`CellTOSGDataLoader`)
157
+ - **root** *(str, required)* — Filesystem path to the dataset root (e.g., `/path/to/OmniCellTOSG_Dataset`).
158
+ - **conditions** *(dict, required)* — Row filters over cell metadata
159
+ (e.g., `{"tissue_general": "brain", "disease_name": "Alzheimer's Disease"}`).
160
+ - **downstream_task** *(str, required)* — `"disease"` | `"gender"` | `"cell_type"`.
161
+ - **label_column** *(str, required)* — Target label column (e.g., `"disease"`, `"gender"`, `"cell_type"`).
162
+ - **sample_ratio** *(float, optional)* — Fraction of rows to sample (0–1). Mutually exclusive with `sample_size`.
163
+ - **sample_size** *(int, optional)* — Absolute number of rows to sample. Mutually exclusive with `sample_ratio`.
164
+ - **balanced** *(bool, default: `False`)* — Enable class-balancing using task-specific priority labels.
165
+ - **shuffle** *(bool, default: `False`)* — Shuffle rows during sampling/composition.
166
+ - **random_state** *(int, default: `42`)* — Seed for reproducibility.
167
+ - **train_text** *(bool, default: `False`)* — If `False`, return precomputed name/desc embeddings; if `True`, return raw text (`s_name`, `s_desc`) for custom embedding.
168
+ - **train_bio** *(bool, default: `False`)* — If `False`, return precomputed sequence embeddings; if `True`, return raw sequences (`s_bio`) for custom embedding.
169
+ - **output_dir** *(str, optional)* — Directory for loader-generated artifacts (splits, logs, cached subsets).
170
+
171
+ > **Returns** (typical):
172
+ > - `x, y`: features and labels for the selected split
173
+ > - `edge_index`, `internal_edge_index`, `ppi_edge_index`: graph topological information
174
+ > - 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.
175
+
176
+ ---
177
+
178
+ ## 🧪 Pretraining
179
+
180
+ ```bash
181
+ python pretrain.py
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 🏋️ Training Examples (CLI)
187
+
188
+ **Disease status (AD, brain)**
189
+ ```bash
190
+ # Alzheimer's Disease (Take AD as an example)
191
+ python train.py \
192
+ --downstream_task disease \
193
+ --label_column disease \
194
+ --tissue_general brain \
195
+ --disease_name "Alzheimer's Disease" \
196
+ --sample_ratio 0.1 \
197
+ --train_base_layer gat \
198
+ --train_lr 0.0005 \
199
+ --train_batch_size 3 \
200
+ --train_test_random_seed 42 \
201
+ --dataset_output_dir ./Output/data_ad_disease_0.1
202
+ ```
203
+
204
+ **Gender (AD, brain)**
205
+ ```bash
206
+ # Alzheimer's Disease (Take AD as an example)
207
+ python train.py \
208
+ --downstream_task gender \
209
+ --label_column gender \
210
+ --tissue_general brain \
211
+ --disease_name "Alzheimer's Disease" \
212
+ --sample_ratio 0.1 \
213
+ --train_base_layer gat \
214
+ --train_lr 0.0005 \
215
+ --train_batch_size 2 \
216
+ --train_test_random_seed 42 \
217
+ --dataset_output_dir ./Output/data_ad_gender_0.1
218
+ ```
219
+
220
+ **Cell type annotation (LUAD, lung)**
221
+ ```bash
222
+ # Lung (LUAD) (Take LUAD as an example)
223
+ python train.py \
224
+ --downstream_task cell_type \
225
+ --label_column cell_type \
226
+ --tissue_general "lung" \
227
+ --disease_name "Lung Adenocarcinoma" \
228
+ --sample_ratio 0.2 \
229
+ --train_base_layer gat \
230
+ --train_lr 0.0001 \
231
+ --train_batch_size 3 \
232
+ --train_test_random_seed 42 \
233
+ --dataset_output_dir ./Output/data_luad_celltype_0.2
234
+ ```
235
+
236
+ **Signaling inference**
237
+ ```bash
238
+ python analysis.py
239
+ ```
240
+
241
+ ---
242
+
243
+ ## ⚖️ Licensing & Attribution
244
+
245
+ This dataset aggregates data from **CellxGENE**, the **Brain Cell Atlas**, and **GEO**. Use of these resources is governed by their respective terms and citation policies:
246
+
247
+ - **CellxGENE Terms of Service** — Follow the platform’s ToS for data access, reuse, and sharing.
248
+ 🔗 https://cellxgene.cziscience.com/tos
249
+
250
+ - **Brain Cell Atlas (citation required)**
251
+ *Cite:*
252
+ 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
253
+
254
+ - **GEO Citation Policy** — Follow NCBI GEO guidelines for citing datasets and third-party analyses.
255
+ 🔗 https://www.ncbi.nlm.nih.gov/geo/info/citations.html#third-party
256
+
257
+ > **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.
258
+
259
+ ---
260
+
261
+ ## 📚 Citation
262
+
263
+ If you use **OmniCellTOSG**, please cite:
264
+
265
+ ```bibtex
266
+ @misc{omnicelltosg2025,
267
+ title = {OmniCellTOSG: A Text–Omic Signaling Graph Dataset for Single-Cell Learning},
268
+ author = {Zhang, Heming and Li, Fuhai and collaborators},
269
+ year = {2025},
270
+ note = {Dataset on Hugging Face},
271
+ url = {https://huggingface.co/FuhaiLiAiLab}
272
+ }
273
+ ```