valegiunca commited on
Commit
5e3b50d
·
verified ·
1 Parent(s): da344f1

Upload 10 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ banner.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,147 @@
1
  ---
2
  license: mit
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ tags:
4
+ - single-cell
5
+ - transcriptomics
6
+ - biology
7
+ - pytorch
8
  ---
9
+
10
+ <p align="center">
11
+ <a href="https://valegiunchiglia.github.io/cascade-website/">
12
+ <img src="banner.png" alt="CASCADE — Cross-System, Multi-Scale Single-Cell Foundation Model with Clinical Applications" width="100%">
13
+ </a>
14
+ </p>
15
+
16
+ <h1 align="center">CASCADE: context-aware single-cell modelling links cellular programmes to patient-level disease phenotypes</h1>
17
+
18
+ <table align="center" border="0" cellspacing="0" cellpadding="4" style="border-collapse: collapse; border: none; background: transparent; margin-left: auto; margin-right: auto;">
19
+ <tr>
20
+ <td style="border: none; background: transparent;"><a href="https://valegiunchiglia.github.io/cascade-website/"><img src="https://img.shields.io/badge/Website-4CAF50?logo=googlechrome&logoColor=white" alt="Website"></a></td>
21
+ <td style="border: none; background: transparent;"><a href="https://github.com/mims-harvard/CASCADE"><img src="https://img.shields.io/badge/Code-181717?logo=github&logoColor=white" alt="Code"></a></td>
22
+ <td style="border: none; background: transparent;"><img src="https://img.shields.io/badge/Paper-coming%20soon-b31b1b?logo=arxiv&logoColor=white" alt="Paper (coming soon)"></td>
23
+ <td style="border: none; background: transparent;"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-HLCA-FFD21E" alt="Dataset: HLCA"></td>
24
+ </tr>
25
+ </table>
26
+
27
+ ## Model Card
28
+
29
+ This repository contains a CASCADE checkpoint pre-trained on the Human Lung Cell Atlas (HLCA) cohort.
30
+
31
+ ## Introduction
32
+
33
+ CASCADE integrates contextual information into both input representation and pre-training
34
+ objectives, allowing the same cell to be interpreted through multiple biologically meaningful
35
+ axes and enabling patient-level phenotype prediction from single-cell profiles.
36
+
37
+ **1. Context-aware tokenisation.** Each cell is encoded as context-dependent up- and
38
+ down-regulated genes relative to a biologically defined reference group, producing multiple
39
+ representations per cell across disease, tissue, cell type, and treatment contexts.
40
+
41
+ **2. Context-specific representation learning.** Shared cell embeddings are projected through
42
+ separate context-specific projectors (disease, tissue, cell type, treatment), learning how
43
+ molecular programmes vary across biologically meaningful contexts via contrastive objectives.
44
+
45
+ **3. Patient representation & explainability.** Cell-level embeddings are aggregated across all
46
+ cells from a donor to produce a patient-level representation for multiscale phenotype
47
+ prediction. CASCADE-Explainer identifies the cell types and genes most responsible for each
48
+ prediction.
49
+
50
+ - Code: https://github.com/mims-harvard/CASCADE
51
+ - Project page: https://valegiunchiglia.github.io/cascade-website/
52
+ - Source dataset: https://cellxgene.cziscience.com/collections/edb893ee-4066-4128-9aec-5eb2b03f8287
53
+
54
+ ## Training Data
55
+
56
+ - **Disease states** (16): COVID-19, chronic obstructive pulmonary disease, chronic rhinitis, cystic fibrosis, hypersensitivity pneumonitis, interstitial lung disease, lung adenocarcinoma, lung large cell carcinoma, lymphangioleiomyomatosis, non-specific interstitial pneumonia, normal, pleomorphic carcinoma, pneumonia, pulmonary fibrosis, pulmonary sarcoidosis, squamous cell lung carcinoma
57
+ - **Tissues** (4): lung, lung parenchyma, nose, respiratory airway
58
+ - **Cell types** (51): identified by Cell Ontology (CL) ID — CL:0000037, CL:0000057, CL:0000077, CL:0000084, CL:0000097, CL:0000158, CL:0000186, CL:0000192, CL:0000236, CL:0000313, .... Look up terms at https://www.ebi.ac.uk/ols4/ontologies/cl.
59
+
60
+ ## Model Architecture
61
+
62
+ CASCADE's encoder (`TransformerGenerator`) is a shared transformer over context-aware gene
63
+ token sequences, followed by context-specific projection heads (one per context in the table
64
+ below) trained with a context-specific contrastive objective.
65
+
66
+ ### Model Hyperparameters
67
+
68
+ | Hyperparameter | Value |
69
+ |---|---|
70
+ | Embedding dim (`d_model`) | 384 |
71
+ | Attention heads (`nhead`) | 6 |
72
+ | Transformer layers (`nlayers`) | 12 |
73
+ | Feedforward dim (`dim_embedding`) | 384 |
74
+ | Dropout | 0.1 |
75
+ | Vocabulary size | 18711 |
76
+ | Cell embedding style | `avg-pool` |
77
+ | Contexts | disease, cell_type, tissue |
78
+ | Context-specific projections | True |
79
+ | Domain adaptation (Sinkhorn) | True |
80
+
81
+ ### Files Included
82
+
83
+ | File | Purpose |
84
+ |---|---|
85
+ | `model.safetensors` | Model weights only (stripped of optimizer/scheduler/scaler state) |
86
+ | `config.json` | Architecture hyperparameters needed to reconstruct `TransformerGenerator` |
87
+ | `tokenizer_dictionary_HLCA.pkl` | Gene/context vocabulary (18711 tokens) used by the context-aware tokenizer |
88
+ | `metadata_dictionary_HLCA.pkl` | Obs-column metadata mapping preserved from the source AnnData |
89
+ | `median_genes_*_all_HLCA.pkl` | Per-context median expression reference used to derive up-/down-regulated gene tokens at tokenization time |
90
+
91
+ ## Usage Instructions
92
+
93
+ The model architecture (`TransformerGenerator`) is not a standard `transformers` class, so
94
+ loading it requires the `cascade` package from the GitHub repo rather than `AutoModel`:
95
+
96
+ ```bash
97
+ pip install git+https://github.com/mims-harvard/CASCADE
98
+ ```
99
+
100
+ ```python
101
+ import json, pickle
102
+ from huggingface_hub import hf_hub_download
103
+ from safetensors.torch import load_file
104
+ from cascade.model.cascade_model import TransformerGenerator
105
+
106
+ repo_id = "<your-org>/CASCADE-HLCA"
107
+
108
+ config = json.load(open(hf_hub_download(repo_id, "config.json")))
109
+ vocab = pickle.load(open(hf_hub_download(repo_id, f"tokenizer_dictionary_HLCA.pkl"), "rb"))
110
+ weights = load_file(hf_hub_download(repo_id, "model.safetensors"))
111
+
112
+ model = TransformerGenerator(
113
+ d_model=config["d_model"],
114
+ nhead=config["nhead"],
115
+ ntoken=config["vocab_size"],
116
+ dim_embedding=config["dim_embedding"],
117
+ nlayers=config["nlayers"],
118
+ vocab=vocab,
119
+ nclass=config["nclass"],
120
+ dropout=config["dropout"],
121
+ pad_token=config["pad_token"],
122
+ cell_emb_style=config["cell_emb_style"],
123
+ context_specific_projections=config["context_specific_projections"],
124
+ constant_ctx=config["constant_ctx"],
125
+ only_contrastive=config["only_contrastive"],
126
+ DA=config["DA"],
127
+ lambda_sinkhorn=config["lambda_sinkhorn"],
128
+ merged_contexts=config["merged_contexts"],
129
+ )
130
+ model.load_state_dict(weights)
131
+ model.eval()
132
+ ```
133
+
134
+ To tokenize new raw data for this model, see `cascade/data/tokenizer.py` in the GitHub repo,
135
+ using the `tokenizer_dictionary_HLCA.pkl` and `median_genes_*_all_HLCA.pkl` files
136
+ from this repo as the vocab and per-context median reference respectively.
137
+
138
+ ## Citation
139
+
140
+ Paper coming soon — see the [project page](https://valegiunchiglia.github.io/cascade-website/)
141
+ for updates.
142
+
143
+ ## Contact
144
+
145
+ For any questions or feedback, please open an issue in the [GitHub repository](https://github.com/mims-harvard/CASCADE)
146
+ or contact [Valentina Giunchiglia](mailto:v.giunchiglia20@imperial.ac.uk) and
147
+ [Marinka Zitnik](mailto:marinka@hms.harvard.edu).
banner.png ADDED

Git LFS Details

  • SHA256: 1253ffda38a1e6af65b0adc6c63244711ebc0dd0437d51bb7b01d1e6b6daea65
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB
config.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset": "HLCA",
3
+ "architecture": "TransformerGenerator",
4
+ "d_model": 384,
5
+ "nhead": 6,
6
+ "nlayers": 12,
7
+ "dim_embedding": 384,
8
+ "dropout": 0.1,
9
+ "nclass": 2,
10
+ "pad_token": "<pad>",
11
+ "cell_emb_style": "avg-pool",
12
+ "context_specific_projections": true,
13
+ "constant_ctx": false,
14
+ "only_contrastive": true,
15
+ "DA": true,
16
+ "lambda_sinkhorn": 0.005,
17
+ "contexts": [
18
+ "disease",
19
+ "cell_type",
20
+ "tissue"
21
+ ],
22
+ "merged_contexts": "disease_cell_type_tissue",
23
+ "vocab_size": 18711,
24
+ "max_length_up": 1024,
25
+ "max_length_down": 1024,
26
+ "temperature": 0.1,
27
+ "seed": 20,
28
+ "training_epoch": 2,
29
+ "training_global_step": 3682000,
30
+ "data_composition": {
31
+ "diseases": [
32
+ "COVID-19",
33
+ "chronic obstructive pulmonary disease",
34
+ "chronic rhinitis",
35
+ "cystic fibrosis",
36
+ "hypersensitivity pneumonitis",
37
+ "interstitial lung disease",
38
+ "lung adenocarcinoma",
39
+ "lung large cell carcinoma",
40
+ "lymphangioleiomyomatosis",
41
+ "non-specific interstitial pneumonia",
42
+ "normal",
43
+ "pleomorphic carcinoma",
44
+ "pneumonia",
45
+ "pulmonary fibrosis",
46
+ "pulmonary sarcoidosis",
47
+ "squamous cell lung carcinoma"
48
+ ],
49
+ "tissues": [
50
+ "lung",
51
+ "lung parenchyma",
52
+ "nose",
53
+ "respiratory airway"
54
+ ],
55
+ "cell_type_ontology_ids": [
56
+ "CL:0000037",
57
+ "CL:0000057",
58
+ "CL:0000077",
59
+ "CL:0000084",
60
+ "CL:0000097",
61
+ "CL:0000158",
62
+ "CL:0000186",
63
+ "CL:0000192",
64
+ "CL:0000236",
65
+ "CL:0000313",
66
+ "CL:0000319",
67
+ "CL:0000451",
68
+ "CL:0000499",
69
+ "CL:0000583",
70
+ "CL:0000622",
71
+ "CL:0000623",
72
+ "CL:0000624",
73
+ "CL:0000625",
74
+ "CL:0000784",
75
+ "CL:0000786",
76
+ "CL:0000860",
77
+ "CL:0000861",
78
+ "CL:0000875",
79
+ "CL:0000990",
80
+ "CL:0002062",
81
+ "CL:0002063",
82
+ "CL:0002075",
83
+ "CL:0002138",
84
+ "CL:0002144",
85
+ "CL:0002145",
86
+ "CL:0002399",
87
+ "CL:0002480",
88
+ "CL:0002543",
89
+ "CL:0002632",
90
+ "CL:0002633",
91
+ "CL:0005006",
92
+ "CL:0005012",
93
+ "CL:0009089",
94
+ "CL:0010003",
95
+ "CL:0019001",
96
+ "CL:0019003",
97
+ "CL:0019019",
98
+ "CL:1000223",
99
+ "CL:1000312",
100
+ "CL:1001568",
101
+ "CL:1001603",
102
+ "CL:2000093",
103
+ "CL:4028004",
104
+ "CL:4028006",
105
+ "CL:4030023",
106
+ "unknown"
107
+ ]
108
+ }
109
+ }
median_genes_all_all_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15ad9a57844d311bcb025aa4ed5b87e4ca7518b45fcd33308b1bea934ed911be
3
+ size 617483
median_genes_cells_all_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a9f4b20cda2ba2cd0edfbf6756d92f27005c66acd3cdae29384a99e3e46621f
3
+ size 19318975
median_genes_disease_all_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f3f3d6074a8ac46c4c4a377baf371d0a6d7f920d8c332bb0743183a755e4f90
3
+ size 6228132
median_genes_tissue_all_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1ae8c02e822e46f8839b818e426795a24ef67c7234fedfc2548976eece46b72
3
+ size 1739601
metadata_dictionary_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0dfce23239217b47b1151bc441ac71a6c9e9191e43cdf12f720b662b403a6639
3
+ size 1368
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81116c256f93ba8fd4d4e5018f0354674ed6640545148af8dec9111f308d8872
3
+ size 90805088
tokenizer_dictionary_HLCA.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb57eebe837569c0189b992bc2f7465b85a51f3475c3ede97e80bad6141fd0a9
3
+ size 392712