junidude14 commited on
Commit
edbe8ba
·
verified ·
1 Parent(s): 087b652

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261001T023742Z-deck-calibration-giroux-sexgenes/diffusion/dataset/server_1/model8/plans/paired_finetune_intradataset_20260927/README.md ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Within-dataset fine-tuning of the final model on paired bulk + scRNA data
2
+
3
+ User decision (2026-09-27): release the pseudobulk-pretrained final model as something users fine-tune on their own paired bulk + scRNA data. Validate it inside each paired dataset: split donors, fine-tune on the training donors' real bulk → their cells, and test on held-out donors. Start with ImMicro and Ye 2026 sepsis, run the same way. Feasibility of other datasets: `FEASIBILITY.md`.
4
+
5
+ ## Setup
6
+
7
+ - **Base model:** `runs/f01_6k_1x_seed20260627/checkpoint_epoch_016.pt` (sha 8c7cd0e8…), EMA weights. E16 is also the best-validation epoch (0.13691).
8
+ - **Data** (`data/<dataset>/`):
9
+ - `features.npz`: bulk and pseudobulk on the 20,097 axis, with measured masks.
10
+ - `cells_panel6k.npz`: retained cells on the 6k panel. Each row's cells sum exactly to its pseudobulk.
11
+ - **ImMicro:** 107 donors, 392,251 baseline cells. Built by `tools/build_immicro_cells.py`.
12
+ - **Sepsis:** 85 pairs, 82 pass identity checks, 610,713 cells. Built by the pairing agent; details in `data/ye2026_sepsis/QC_REPORT.md`. The GEX is 5′ even though GEO says 3′.
13
+ - **Folds** (`tools/prepare_dataset.py`):
14
+ - Donor-level 5-fold, stratified by group (ImMicro pool; sepsis clinical group).
15
+ - About 10 % of each fold's training donors are inner-validation, used only for early stopping.
16
+ - Identity-failed sepsis rows sit in fold −1 and are never used.
17
+ - **Conditions:**
18
+ - Fixed depth (K = 1000, one depth anchor), the published `build_realbulk_conditions.py` arithmetic.
19
+ - No test donor's single-cell depth or cell count enters its condition.
20
+ - The ImMicro raw and pseudo NPZs equal the published fixed ones bit for bit.
21
+ - Paired calibration α is fitted on each fold's training donors only.
22
+ - **Training** (`tools/ft_sdd.py`):
23
+ - Pretraining loss, bf16, AdamW, grad clip 5, EMA 0.999, donor-balanced batches of 256.
24
+ - Up to 20,000 steps. Inner-validation loss is checked every 250 steps and the best EMA state is kept.
25
+ - Modes: full (54.2 M trainable parameters), LoRA r = 16 (1.3 M, merged before saving), condition encoder only (9.5 M).
26
+ - Output checkpoints keep the base schema, so `scripts/sample_sdd_standalone.py` samples them unchanged.
27
+ - **Sampling:** test donors only, 1,500 cells each, seed 20260927, DDIM 50, EMA, Bernoulli read-out. GPU only through `tools/run_queue.sh` → `ml-run`.
28
+ - **Scoring** (`tools/score_ft.py`, `tools/score_fold.sh`):
29
+ - Frozen f01common scANVI six-type gate. Metrics: composition L1, precision/coverage (PCA-50, k = 10, reference = the scored donors' observed cells), pseudobulk r, donor recovery top-1.
30
+ - For sepsis, also per-cell-type sepsis-vs-control logFC r against observed and against bulk broadcast.
31
+ - Validated against the published ImMicro native arms: composition L1 and labels are identical.
32
+ - Precision/coverage depends on the reference draw and on how many donors are scored, so compare arms within a fold.
33
+ - **Giroux: sex-linked genes excluded from the disease metrics** (user decision 2026-10-01). Its moderate vs mild contrast is fully confounded with sex (scored subjects 4 F / 0 M vs 0 F / 5 M). Giroux logFC r, partial r, top-50 DEG and the broadcast baseline are reported from `scores_nosex/giroux2022/`, scored with `score_ft.py --exclude-genes data/sex_linked_genes/sex_linked_genes_exclude.csv` (196 genes: chrY non-PAR + X-inactivation escape genes of Tukiainen 2017; PAR genes kept) and the original frozen labels (`--reuse-labels`). Details: `scores_nosex/README.md`, `data/sex_linked_genes/README.md`.
34
+
35
+ ## ImMicro fold 0 pilot (22 test donors; real bulk input unless noted)
36
+
37
+ | arm | comp L1 ↓ | precision | coverage | pseudobulk r | donor top-1 | monocyte % (obs 18.5) |
38
+ |---|---:|---:|---:|---:|---:|---:|
39
+ | zero-shot raw | 0.484 | 0.910 | 0.423 | 0.892 | 0.05 | 37.0 |
40
+ | zero-shot paired cal (fold α) | 0.168 | 0.985 | 0.725 | 0.882 | 0.14 | 14.7 |
41
+ | zero-shot pseudobulk | 0.188 | 0.993 | 0.722 | 0.881 | 0.09 | 13.7 |
42
+ | FT condition encoder only | 0.204 | 0.979 | 0.728 | 0.892 | 0.14 | 13.0 |
43
+ | FT LoRA r = 16 | 0.153 | 0.992 | **0.915** | 0.901 | 0.18 | 14.8 |
44
+ | **FT full** | **0.147** | 0.987 | 0.841 | **0.912** | **0.32** | 14.7 |
45
+ | FT on pseudobulk (sc only), raw input | 0.426 | 0.725 | 0.257 | 0.929 | 0.18 | 23.4 |
46
+ | FT on pseudobulk (sc only), paired-cal input | 0.231 | 0.954 | 0.816 | 0.917 | 0.18 | 14.3 |
47
+
48
+ Leave-one-out composition null of the observed cells: 0.163. Chance donor top-1: 0.045.
49
+
50
+ Selected inner-validation loss (pretrained 0.10985):
51
+ - full 0.10071, still falling at the 20,000-step cap;
52
+ - LoRA 0.10127;
53
+ - condition encoder 0.10429.
54
+
55
+ **Reading (one fold, one seed):**
56
+ - Real-bulk fine-tuning beats every zero-shot arm, including the pseudobulk input.
57
+ - It also beats sc-only adaptation. The sc-only model with paired calibration reaches similar coverage (0.82), so coverage comes largely from adapting to the cohort. Composition and donor specificity, however, need the paired bulk: L1 0.147 vs 0.231, top-1 0.32 vs 0.18.
58
+ - LoRA and full are close: LoRA covers more of the observed cells, full is more donor-specific.
59
+ - The condition encoder alone captures about 60 % of full's inner-validation gain but does not beat zero-shot calibration, so it was dropped.
60
+
61
+ ## ImMicro, all five folds (107 donors, each scored by the fold model that never trained on it)
62
+
63
+ Per-fold scores, fold mean ± SD (`scores/immicro/AGGREGATE.md`):
64
+
65
+ | arm | comp L1 ↓ | precision | coverage | pseudobulk r |
66
+ |---|---:|---:|---:|---:|
67
+ | zero-shot raw | 0.454 ± 0.032 | 0.877 | 0.424 | 0.892 |
68
+ | zero-shot paired cal | 0.199 ± 0.029 | 0.976 | 0.725 | 0.880 |
69
+ | zero-shot pseudobulk | 0.204 ± 0.016 | 0.986 | 0.721 | 0.881 |
70
+ | FT LoRA r = 16 | 0.162 ± 0.017 | 0.989 | **0.919** | 0.900 |
71
+ | **FT full** | **0.157 ± 0.020** | 0.981 | 0.851 | **0.914** |
72
+ | sc-only FT, raw input | 0.444 ± 0.021 | 0.678 | 0.237 | 0.927 |
73
+ | sc-only FT, paired-cal input | 0.240 ± 0.015 | 0.955 | 0.829 | 0.917 |
74
+
75
+ **Donor-level composition L1, paired Wilcoxon over 107 donors** (FT full vs each arm):
76
+
77
+ | comparison | Δ L1 | FT full better in | p |
78
+ |---|---:|---:|---:|
79
+ | vs zero-shot paired cal | −0.042 | 68 % | 1e-7 |
80
+ | vs zero-shot pseudobulk | −0.048 | 74 % | 4e-8 |
81
+ | vs sc-only FT + paired cal | −0.083 | 91 % | 2e-16 |
82
+ | vs LoRA | −0.005 | 58 % | 0.14 |
83
+ | vs leave-one-out cohort-mean null (0.161) | −0.007 | 50 % | 0.64 |
84
+
85
+ **Across-donor correlation of generated vs observed cell-type fraction (T / B / Mono / NK):**
86
+ - FT full: 0.79 / 0.80 / 0.83 / 0.81
87
+ - zero-shot paired cal: 0.67 / 0.71 / 0.85 / 0.49
88
+ - zero-shot pseudobulk: 0.71 / 0.77 / 0.90 / 0.60
89
+
90
+ **Donor top-1:** 0.15 ± 0.10 for FT full vs 0.13 for zero-shot paired cal. The fold-0 value of 0.32 did not replicate.
91
+
92
+ **Pooled scoring** (`scores/immicro/pooled/`: one call over all 107 donors, reference = all 107 donors' observed cells, so absolute precision/coverage are lower than the per-fold values):
93
+
94
+ | arm | precision / coverage | depth-matched precision / coverage |
95
+ |---|---|---|
96
+ | FT LoRA | 0.924 / 0.784 | 0.961 / 0.962 |
97
+ | FT full | 0.890 / 0.695 | 0.946 / 0.950 |
98
+ | zero-shot paired cal | 0.905 / 0.527 | 0.944 / 0.769 |
99
+ | zero-shot pseudobulk | 0.936 / 0.524 | 0.965 / 0.741 |
100
+
101
+ **Reading:**
102
+ - Fine-tuning on real bulk removes the real-bulk bias.
103
+ - It beats the pseudobulk input, which was the zero-shot ceiling.
104
+ - It improves the across-donor ranking of T, B and NK fractions.
105
+ - It does not beat the observed cohort mean on per-donor composition L1. Healthy donors vary little, so that null is strong.
106
+ - Full is better on composition; LoRA gives wider coverage.
107
+
108
+ ## Sepsis, all five folds (82 identity-passed pairs: 61 sepsis, 21 controls; cross-fitted)
109
+
110
+ Pooled scoring over all 82 donors (`scores/ye2026_sepsis/pooled/`). The contrast is computed over all 61 vs 21 donors. The per-fold contrast (4–5 controls per fold) is too noisy to use.
111
+
112
+ | arm | comp L1 ↓ | precision | coverage | sepsis-vs-control logFC r (T / B / Mono / NK; mean) | r of bulk broadcast | partial r beyond broadcast |
113
+ |---|---:|---:|---:|---|---:|---:|
114
+ | zero-shot raw | 0.511 | 0.614 | 0.067 | −0.11 / 0.06 / 0.07 / −0.07; **−0.01** | 0.316 | −0.095 |
115
+ | zero-shot paired cal | 0.401 | 0.903 | 0.431 | 0.04 / 0.16 / 0.25 / 0.04; **0.12** | 0.278 | 0.039 |
116
+ | zero-shot pseudobulk (sc-derived input) | **0.233** | 0.915 | 0.480 | 0.55 / 0.50 / 0.40 / 0.43; **0.47** | 0.730 | 0.210 |
117
+ | FT LoRA | 0.362 | **0.926** | **0.829** | 0.63 / 0.57 / 0.58 / 0.34; **0.53** | 0.316 | **0.469** |
118
+ | **FT full** | 0.372 | 0.866 | 0.795 | 0.62 / 0.60 / 0.63 / 0.29; **0.53** | 0.316 | **0.468** |
119
+ | sc-only FT, raw input | 0.472 | 0.606 | 0.134 | 0.01 / 0.22 / 0.34 / 0.03; 0.15 | 0.316 | 0.038 |
120
+ | sc-only FT, paired-cal input | 0.360 | 0.863 | 0.726 | 0.25 / 0.32 / 0.52 / 0.10; 0.30 | 0.278 | 0.190 |
121
+
122
+ Leave-one-out composition null: 0.515. Observed monocyte %: 20.8; the FT arms generate 18.0–18.5 %.
123
+
124
+ Per-fold means are in `scores/ye2026_sepsis/AGGREGATE.md`. The fold-level ranking is the same: FT full L1 0.372 ± 0.083 vs zero-shot paired cal 0.404 ± 0.071.
125
+
126
+ **Donor-level composition L1** (paired Wilcoxon, 82 donors):
127
+
128
+ | comparison | Δ L1 | p |
129
+ |---|---:|---:|
130
+ | FT full vs zero-shot paired cal | −0.029 | 0.24 |
131
+ | FT LoRA vs zero-shot paired cal | −0.039 | 0.19 |
132
+ | FT full vs sc-only FT + cal | +0.011 | 0.80 |
133
+ | FT full vs zero-shot pseudobulk | +0.138 | 2e-7 |
134
+ | FT full vs null | −0.144 (better in 72 %) | 7e-6 |
135
+
136
+ **Across-donor fraction correlation (T / B / Mono / NK):**
137
+ - FT full: 0.68 / 0.79 / 0.60 / 0.68
138
+ - zero-shot paired cal: 0.64 / 0.71 / 0.60 / 0.59
139
+ - zero-shot pseudobulk: 0.91 / 0.95 / 0.97 / 0.80
140
+
141
+ **Reading:**
142
+ - **Disease signal is the sepsis result.**
143
+ - Fine-tuned models generate cells whose per-cell-type sepsis-vs-control logFC agrees with the observed cells at r 0.53. Zero-shot calibrated bulk gives 0.12.
144
+ - They beat the real-bulk broadcast baseline in every cell type (T 0.62 vs 0.26, B 0.60 vs 0.28, Mono 0.63 vs 0.55, NK 0.29 vs 0.19). In SLE the zero-shot model lost to broadcast.
145
+ - The partial r beyond broadcast is 0.47 (zero-shot 0.04).
146
+ - They also exceed zero-shot generation from the sc-derived pseudobulk (0.47).
147
+ - **The paired bulk matters.** sc-only fine-tuning with paired-cal input reaches 0.30.
148
+ - **Composition does not improve over zero-shot calibration** (n.s.) and stays far behind the pseudobulk input: the sepsis real bulk carries weak composition information, monocytes especially (r 0.60).
149
+ - **Coverage roughly doubles** (0.43 → 0.80–0.83).
150
+ - **Full and LoRA are equivalent here.** LoRA has the higher precision.
151
+
152
+ ## Sepsis fold 0 pilot (17 test donors: 12 sepsis, 5 controls; real bulk input unless noted)
153
+
154
+ Early stopping selected fewer steps than for ImMicro:
155
+
156
+ | arm | selected step | inner-val loss (pretrained 0.12500) |
157
+ |---|---:|---:|
158
+ | full | 3,750 | 0.11344 |
159
+ | LoRA | 6,500 | 0.11357 |
160
+ | condition encoder | 5,500 | 0.11606 |
161
+ | sc-only (pseudobulk) | 20,000 | 0.11275 (pretrained 0.11720, pseudobulk conditions) |
162
+
163
+ | arm | comp L1 ↓ | precision | coverage | donor top-1 | monocyte % (obs 24.6) | sepsis-vs-control logFC r, mean of T/B/Mono/NK | partial r beyond bulk broadcast |
164
+ |---|---:|---:|---:|---:|---:|---:|---:|
165
+ | zero-shot raw | 0.451 | 0.879 | 0.181 | 0.41 | 37.3 | 0.064 | −0.035 |
166
+ | zero-shot paired cal | 0.388 | 0.984 | 0.626 | 0.41 | 25.7 | 0.255 | 0.161 |
167
+ | zero-shot pseudobulk | **0.236** | 0.990 | 0.700 | **0.65** | 29.5 | 0.328 | 0.187 |
168
+ | FT condition encoder | 0.380 | 0.983 | 0.741 | 0.35 | 17.5 | 0.261 | 0.181 |
169
+ | FT LoRA r = 16 | 0.373 | 0.986 | 0.858 | 0.47 | 15.3 | 0.487 | **0.410** |
170
+ | FT full | 0.388 | 0.978 | **0.871** | 0.35 | 16.2 | **0.489** | 0.393 |
171
+ | FT sc only, raw input | 0.422 | 0.928 | 0.351 | 0.47 | 29.6 | 0.167 | 0.030 |
172
+ | FT sc only, paired-cal input | 0.396 | 0.979 | 0.850 | 0.35 | 21.7 | 0.465 | 0.357 |
173
+
174
+ - The leave-one-out composition null is 0.513: donors differ far more than in ImMicro.
175
+ - Contrast = per-cell-type log2 fold change of donor-averaged mean CP10K, over genes detected in ≥ 1 % of observed cells of the type.
176
+ - **Bulk broadcast baseline** (the input real bulk's sepsis-vs-control logFC copied to every cell type):
177
+ - mean r 0.482 (T 0.393, B 0.470, Mono 0.702, NK 0.361);
178
+ - with pseudobulk instead of real bulk: 0.668.
179
+
180
+ **Reading (one fold, one seed, only 5 controls):**
181
+ - Fine-tuning roughly doubles the per-cell-type disease-signal agreement (0.26 → 0.49).
182
+ - For the first time the generated cells carry a clear part beyond the bulk broadcast (partial r ≈ 0.4). In SLE the zero-shot model gave about 0.2.
183
+ - By cell type, FT beats broadcast for T and B, but not for monocytes (0.57 vs 0.70).
184
+ - Most of the gain comes from adapting to the cohort: sc-only FT with the paired-cal input reaches 0.465 / 0.357.
185
+ - Composition is not improved by any real-bulk arm (0.37–0.39 vs zero-shot pseudobulk 0.236). FT arms under-produce monocytes (15–17 % vs 24.6 %).
186
+ - So in sepsis the real bulk does not carry the donors' composition to the model, unlike ImMicro. One candidate cause not yet checked: granulocyte or low-density-neutrophil signal in sepsis PBMC bulk.
187
+
188
+ ## Sepsis top-50 DEG (added 2026-09-28; `scores/ye2026_sepsis/pooled_deg/`)
189
+
190
+ **Definition:** the NC benchmark's own `bulk2sc-paper/scripts/evaluate_generated_vs_truth.py`, imported, not copied (`welch_bh_deg`, `top_deg_genes`).
191
+ - Per cell type: donor pseudobulk on the 5,975 scoring genes, log1p CPM, two-sided Welch test, BH correction.
192
+ - List: genes with FDR < 0.05, ranked by |logFC|, top 50.
193
+ - Score: the number of genes shared by the observed and generated lists, summed over T/B/Mono/NK/DC (maximum 250). The SLE "81" is the same kind of sum.
194
+
195
+ | arm | T | B | Mono | NK | DC | sum / 250 | logFC r |
196
+ |---|---:|---:|---:|---:|---:|---:|---:|
197
+ | zero-shot raw | 3 | 0 | 4 | 1 | 1 | 9 | −0.01 |
198
+ | zero-shot paired cal | 5 | 1 | 4 | 0 | 1 | 11 | 0.12 |
199
+ | zero-shot pseudobulk | 11 | 5 | 1 | 1 | 4 | 22 | 0.47 |
200
+ | sc-only FT + cal | 1 | 1 | 9 | 0 | 4 | 15 | 0.30 |
201
+ | LoRA 5 pairs | 4 | 0 | 1 | 0 | 0 | 5 | 0.29 |
202
+ | LoRA 10 | 3 | 1 | 4 | 0 | 0 | 8 | 0.42 |
203
+ | LoRA 40 | 0 | 3 | 12 | 0 | 7 | 22 | 0.48 |
204
+ | LoRA all (58) | 1 | 1 | 19 | 0 | 2 | 23 | 0.53 |
205
+ | full all | 1 | 2 | 21 | 0 | 0 | 24 | 0.53 |
206
+
207
+ Real-bulk broadcast list: 21.
208
+
209
+ **Reading:**
210
+ - With enough pairs, top-50 DEG doubles over zero-shot calibration (11 → 23–24).
211
+ - It only reaches the broadcast level, and almost all of it is monocytes.
212
+ - T and NK overlap is near zero because the generated T cells produce almost no significant genes (12 vs 1,578 observed for full). The disease signal is in the right direction (logFC r 0.6) but too weak for FDR-based DEG calls.
213
+ - Paper note: `methods.tex:87` describes CP10K, but the evaluator uses CPM.
214
+
215
+ ## New datasets and the few-pair scenario (started 2026-09-28)
216
+
217
+ **Datasets** (built by agents with the same QC/identity rules; details in each `data/<ds>/QC_REPORT.md`):
218
+
219
+ | dataset | bulk | sc | usable pairs (donors) | contrast |
220
+ |---|---|---|---|---|
221
+ | Imperial ESKD COVID (Gisby 2022 + Stephenson 2025) | PBMC, htseq | 10x 5′ CITE atlas | 157 (57 patients; longitudinal) | covid_positive vs covid_negative |
222
+ | Giroux 2022 (Duke outpatient COVID) | PBMC, NuGEN SoLo total RNA (no RPL/RPS/MT genes) | 10x 5′ v1 | 24 (9 subjects) | severe vs mild |
223
+ | Ji 2025 ChILI | **PAXgene whole blood**, QuantSeq 3′ | 10x 5′ | 33 (20 patients) | ChILI (TOL, FU1) vs ICI controls (BC, AC) |
224
+
225
+ Dataset notes:
226
+ - **Imperial:** pairs are matched on the metadata swab day. The day in the bulk column name counts from symptom onset.
227
+ - **Giroux:** the author bulk table lacks the exposed and healthy subjects.
228
+ - **Ji:** the bulk is whole blood, so this is a whole-blood → PBMC test.
229
+
230
+ **Rules:**
231
+ - Rows with fewer than 200 cells are excluded (strict-QC protocol minimum). Only Imperial is affected.
232
+ - The scorer now accepts several samples per donor: the scored unit is the sample, and the composition null leaves out every sample of that donor.
233
+
234
+ **Few-pair scenario** (`tools/prepare_fewshot.py`, `make_fewshot_queue.sh`, `score_fewshot.sh`):
235
+ - **Training donors:** 5, stratified by case/control where the dataset has one. All their pairs are used.
236
+ - **Training:** LoRA for a fixed 3,000 steps with no inner validation (`ft_sdd.py --train-donors-file --fixed-steps`).
237
+ - **Test:** every other usable donor.
238
+ - **Comparators:**
239
+ - zero-shot raw;
240
+ - zero-shot paired cal, with alpha from the **same 5 pairs**;
241
+ - zero-shot pseudobulk (reference).
242
+ - **Repeats:** 5 draws.
243
+ - **Datasets:** also run on ImMicro and sepsis so all five datasets share the protocol.
244
+
245
+ **Also run:** the 5-fold CV of `make_cv_queue.sh` on each new dataset (zero-shot ×3, LoRA on all training donors, sc-only control).
246
+
247
+ **Hosts:**
248
+ - Imperial runs entirely on server_2 (GPU and scoring; outputs about 110 GB). `tools/run_queue_s2.sh` is the server_2 env copy of `run_queue.sh`.
249
+ - The rest runs on server_1.
250
+ - Scored ImMicro and sepsis generations were moved to server_2, sha-checked, with `.moved` markers (`tools/move_generated.sh`).
251
+
252
+ ## Results: few-pair scenario (LoRA on 5 donors, fixed 3,000 steps; test = every other donor; mean ± SD over 5 draws)
253
+
254
+ | dataset | arm | comp L1 | precision | coverage | case-control logFC r | partial r beyond broadcast | top-50 DEG (sum) |
255
+ |---|---|---:|---:|---:|---:|---:|---:|
256
+ | ImMicro | zero-shot cal (same 5 pairs) | 0.203 ± 0.011 | 0.904 | 0.535 | — | — | — |
257
+ | ImMicro | **LoRA 5** | **0.176 ± 0.012** | **0.952** | **0.792** | — | — | — |
258
+ | sepsis | zero-shot cal | 0.446 ± 0.046 | 0.899 | 0.428 | 0.10 ± 0.04 | 0.00 | 9.4 ± 2.6 |
259
+ | sepsis | **LoRA 5** | 0.466 ± 0.044 | 0.906 | **0.694** | **0.35 ± 0.16** | **0.31** | 16.4 ± 6.7 |
260
+ | Ji (whole blood) | zero-shot cal | 0.514 ± 0.016 | 0.782 | 0.114 | 0.14 ± 0.09 | 0.12 | 0.0 |
261
+ | Ji (whole blood) | **LoRA 5** | 0.513 ± 0.115 | **0.978** | **0.707** | **0.33 ± 0.08** | **0.30** | 0.2 |
262
+
263
+ Composition, LoRA 5 vs zero-shot cal (paired over donor-draws):
264
+ - ImMicro: better in 69 %, p 3e-24.
265
+ - Sepsis: p 0.96.
266
+ - Ji: p 0.60.
267
+
268
+ Real-bulk broadcast r:
269
+ - sepsis 0.32, top-50 DEG 20;
270
+ - Ji 0.23.
271
+
272
+ Zero-shot from the sc-derived pseudobulk (reference):
273
+ - ImMicro L1 0.211;
274
+ - sepsis L1 0.237, r 0.48, DEG 20.8;
275
+ - Ji L1 0.171, r 0.18.
276
+
277
+ ## Results: Ji 2025, 5-fold (33 pairs pooled; 18 ChILI vs 15 controls; whole-blood bulk → PBMC cells)
278
+
279
+ | arm | comp L1 | precision | coverage | ChILI-vs-control logFC r (T/B/Mono/NK; mean) | partial r | top-50 DEG |
280
+ |---|---:|---:|---:|---|---:|---:|
281
+ | zero-shot raw | 0.738 | 0.717 | 0.055 | 0.18/−0.08/0.22/0.02; 0.08 | 0.03 | 0 |
282
+ | zero-shot cal | 0.501 | 0.740 | 0.106 | 0.23/0.00/0.21/0.13; 0.14 | 0.11 | 0 |
283
+ | zero-shot pseudobulk (reference) | 0.173 | 0.985 | 0.685 | 0.28/−0.06/0.32/0.03; 0.14 | 0.03 | 5 |
284
+ | **LoRA (all training donors)** | 0.504 | **0.971** | **0.857** | **0.48/0.24/0.79/0.41; 0.48** | **0.45** | **15** |
285
+ | sc-only FT, raw input | 0.596 | 0.718 | 0.094 | 0.15 | 0.11 | 0 |
286
+ | sc-only FT, cal input | 0.609 | 0.694 | 0.113 | 0.25 | 0.22 | 0 |
287
+
288
+ Baselines:
289
+ - Real-bulk broadcast: r 0.24, DEG 4.
290
+ - Leave-donor-out composition null: 0.452.
291
+
292
+ **Reading:**
293
+ - Whole-blood bulk is far from PBMC; the zero-shot arms fall outside the observed cell space.
294
+ - LoRA on the paired whole-blood bulk brings the cells back (coverage 0.86), and the ChILI signal agrees with the observed cells at r 0.48 (monocytes 0.79).
295
+ - The sc-only control does not work here (coverage 0.11), so the paired bulk is what teaches the whole-blood → PBMC map.
296
+ - Composition stays at zero-shot-cal level and worse than the cohort mean: whole-blood bulk does not carry PBMC composition.
297
+
298
+ ## Results: Imperial and Giroux (2026-09-28)
299
+
300
+ **Imperial ESKD COVID** (157 samples / 57 patients; COVID+ 113 vs COVID− 34 samples; runs and scores on server_2, copied to `scores/imperial_eskd/`)
301
+
302
+ | setting | arm | comp L1 | precision | coverage | COVID logFC r (T/B/Mono/NK; mean) | partial r | top-50 DEG |
303
+ |---|---|---:|---:|---:|---|---:|---:|
304
+ | 5 pairs | zero-shot cal | 0.506 | 0.845 | 0.634 | 0.68 | 0.41 | 104 |
305
+ | 5 pairs | **LoRA 5** | 0.503 | 0.853 | **0.737** | **0.75** | **0.60** | **114** |
306
+ | 5-fold | zero-shot cal | 0.494 | 0.842 | 0.639 | 0.68/0.62/0.71/0.70 | 0.41 | 111 |
307
+ | 5-fold | **LoRA** | **0.376** (p 7e-11) | 0.847 | **0.850** | **0.90/0.75/0.79/0.83; 0.82** | **0.69** | **143** |
308
+ | 5-fold | sc-only FT + cal | 0.461 | 0.691 | 0.555 | 0.81 | 0.63 | 129 |
309
+
310
+ Baselines:
311
+ - Real-bulk broadcast: r 0.66, DEG 84 (75 in the 5-pair setting).
312
+ - Zero-shot from the sc pseudobulk: L1 0.300, r 0.68.
313
+ - Composition null: 0.505.
314
+
315
+ **Giroux 2022** (24 pairs / 9 subjects; severe 11 vs mild 13)
316
+
317
+ | setting | arm | comp L1 | coverage | severe-vs-mild r | partial r | top-50 DEG |
318
+ |---|---|---:|---:|---:|---:|---:|
319
+ | 5 pairs | zero-shot cal | 0.288 | 0.944 | 0.24 | 0.11 | 1.8 |
320
+ | 5 pairs | **LoRA 5** | 0.256 | 0.961 | 0.33 | 0.19 | 11.6 |
321
+ | 5-fold | zero-shot cal | 0.266 | 0.906 | 0.31 | 0.14 | 12 |
322
+ | 5-fold | **LoRA** | 0.258 | 0.928 | **0.50** | **0.33** | **25** |
323
+
324
+ - Here the real-bulk broadcast beats every generated arm: r 0.64, DEG 39 (5-pair: r 0.54, DEG 25).
325
+ - The severe-vs-mild difference is shared across cell types.
326
+ - **Superseded for the disease metrics (2026-10-01):** severity is confounded with sex (scored 4 F / 0 M vs 0 F / 5 M) and the
327
+ observed and broadcast DEG lists were led by chrY genes. Without the 196 sex-linked genes (`scores_nosex/giroux2022/`):
328
+
329
+ | setting | arm | severe-vs-mild r | partial r | top-50 DEG |
330
+ |---|---|---:|---:|---:|
331
+ | 5 pairs | zero-shot cal | 0.23 | 0.11 | 0.0 |
332
+ | 5 pairs | **LoRA 5** | 0.30 | 0.19 | 0.2 |
333
+ | 5-fold | zero-shot cal | 0.27 | 0.13 | 0 |
334
+ | 5-fold | **LoRA** | **0.46** | **0.32** | **5** |
335
+
336
+ - The real-bulk broadcast still beats every arm on r (5-fold 0.58, 5-pair 0.49) but not on DEG: the observed lists
337
+ shrink (5-fold max 123 → 101) and every overlap, broadcast included, falls to 0–5 (5-fold broadcast 5 = LoRA 5).
338
+ - chrY-only exclusion (`scores_nochrY/`) gives nearly the same numbers; the same exclusion moves the sex-balanced
339
+ cohorts' pooled r by ≤ 0.007 and DEG by ≤ 1 (`scores_nosex/README.md`).
340
+
341
+ ## Five-dataset summary (LoRA vs zero-shot paired calibration)
342
+
343
+ | dataset (bulk) | cell realism (coverage) | composition | disease signal vs zero-shot | vs real-bulk broadcast |
344
+ |---|---|---|---|---|
345
+ | ImMicro (PBMC, healthy) | ↑ both settings | ↑ both settings (≈ cohort-mean null) | n/a | n/a |
346
+ | sepsis (PBMC) | ↑ | = | ↑ (0.12 → 0.35 with 5 pairs, 0.53 with all) | above (r); ≈ (DEG) |
347
+ | Ji (whole blood) | ↑↑ (0.11 → 0.71–0.86) | = | ↑ (0.14 → 0.33 / 0.48) | above (r and DEG) |
348
+ | Imperial (PBMC) | ↑ | = with 5 pairs, ↑ with all | ↑ (0.68 → 0.75 / 0.82; DEG 104 → 114 / 143) | above (r and DEG) |
349
+ | Giroux (PBMC, 9 subjects; sex-linked genes excluded) | ≈ (already high) | = | ↑ (0.23 → 0.30 / 0.27 → 0.46) | below (r); DEG ≈ 0 for all |
350
+
351
+ ## Recommended protocol (user decision 2026-09-28: recommend LoRA)
352
+
353
+ 1. **Backbone:** the public pseudobulk-pretrained final model (6k, 1×, E16), frozen.
354
+ 2. **Paired data:** the user's paired bulk + scRNA from the same sample (raw counts, canonical 20,097 axis, measured masks); check identity (sex genes, expression match).
355
+ - Hold out about 10 % of the pairs, and at least 5–7 donors, for early stopping.
356
+ 3. **Condition:** real bulk at the fixed-depth policy (K = 1000, one depth anchor). No single-cell depth or cell count is needed at inference.
357
+ 4. **LoRA training** (`tools/ft_sdd.py --mode lora`):
358
+ - Rank 16, alpha 16, on all 22 denoiser Linear layers (1.30 M trainable parameters).
359
+ - AdamW with lr 5e-4, warmup 200 steps, weight decay 0. Grad clip 5, bf16, EMA 0.999.
360
+ - Donor-balanced batches of 256 cells: draw a donor uniformly, then one of its cells; the condition is that donor's real bulk.
361
+ - Inner-validation loss every 250 steps; stop after 2,000 steps without improvement; cap at 20,000 steps; keep the best EMA state.
362
+ - Merge the LoRA into the weights; the standard sampler then works unchanged.
363
+ 5. **Apply** only to bulk made with the same bulk protocol as the training pairs.
364
+
365
+ **What was run** (LoRA, per fold):
366
+
367
+ | dataset | train donors | inner-val donors | train cells | selected step | cell-epochs at selection | wall time |
368
+ |---|---:|---:|---:|---|---|---:|
369
+ | ImMicro | 78–79 | 7 | ~290 k | 19,500–20,000 (cap reached, loss still falling) | ~17–18 | ~13 min |
370
+ | sepsis | 58–59 | 7–8 | ~410–426 k | 3,750–13,000 (early stop) | 2.4–8.0, mostly ~4 | 4–11 min |
371
+
372
+ **Open questions being tested:**
373
+ - The minimum number of pairs is not known.
374
+ - Whether varied K helps is not known.
375
+
376
+ ## LoRA learning curve (2026-09-28)
377
+
378
+ One nested subset per fold and n; the inner-validation donors (7–8) sit outside the training subset.
379
+
380
+ **Sepsis** (pooled over all 82 donors; contrast 61 vs 21):
381
+
382
+ | training pairs | comp L1 | precision | coverage | sepsis-vs-control logFC r (T/B/Mono/NK; mean) | partial r beyond broadcast | selected steps |
383
+ |---:|---:|---:|---:|---|---:|---|
384
+ | 0 (zero-shot paired cal) | 0.401 | 0.903 | 0.431 | 0.04/0.16/0.25/0.04; 0.12 | 0.04 | — |
385
+ | 5 | 0.428 | 0.911 | 0.767 | 0.36/0.37/0.25/0.19; 0.29 | 0.25 | 2,000–3,000 |
386
+ | 10 | 0.390 | 0.916 | 0.786 | 0.54/0.49/0.33/0.32; 0.42 | 0.37 | 2,000–3,250 |
387
+ | 20 | 0.380 | 0.927 | 0.807 | 0.43/0.33/0.47/0.24; 0.37 | 0.30 | 2,500–4,000 |
388
+ | 40 | 0.365 | 0.922 | 0.818 | 0.57/0.52/0.52/0.29; 0.48 | 0.40 | 3,000–7,000 |
389
+ | 58 (all) | 0.362 | 0.926 | 0.829 | 0.63/0.57/0.58/0.34; 0.53 | 0.47 | 3,750–13,000 |
390
+
391
+ Reference rows:
392
+ - Real-bulk broadcast: mean r 0.32.
393
+ - sc-only FT with all 58 donors + paired cal: 0.30.
394
+ - Zero-shot from the sc-derived pseudobulk: 0.47, with composition 0.233.
395
+
396
+ **ImMicro** (folds 0–3, 86 donors, per-fold scoring; the selected-step column includes fold 4):
397
+
398
+ | training pairs | comp L1 (better than zero-shot cal in, p) | coverage | across-donor fraction r (T/B/Mono/NK) | selected steps |
399
+ |---:|---|---:|---|---|
400
+ | 0 (zero-shot paired cal) | 0.206 | 0.724 | 0.65/0.68/0.85/0.47 | — |
401
+ | 5 | 0.176 (70 %, 4e-5) | 0.920 | 0.62/0.71/0.82/0.19 | 2,750–5,000 |
402
+ | 10 | 0.193 (60 %, 0.05) | 0.890 | 0.56/0.72/0.75/0.45 | 3,250–19,500 |
403
+ | 20 | 0.178 (70 %, 1e-4) | 0.898 | 0.63/0.73/0.78/0.61 | 5,250–20,000 (4 of 5 folds at cap) |
404
+ | 40 | 0.171 (73 %, 3e-5) | 0.910 | 0.69/0.75/0.82/0.70 | cap |
405
+ | 78–79 (all) | 0.168 (65 %, 6e-6) | 0.917 | 0.74/0.75/0.88/0.72 | cap |
406
+
407
+ **Reading:**
408
+ - **Five pairs already fix most of the systematic real-bulk shift.**
409
+ - Coverage jumps from 0.43/0.72 to 0.77/0.92.
410
+ - ImMicro composition drops from 0.206 to 0.176.
411
+ - **Donor-level ranking and the disease signal keep improving with more pairs.**
412
+ - ImMicro NK r goes 0.19 → 0.45 → 0.61 → 0.70 → 0.72.
413
+ - Sepsis contrast goes 0.29 → 0.42 → 0.37 → 0.48 → 0.53. The dip at 20 is one subset per fold, so it is noise-level.
414
+ - About 10 pairs already beat the real-bulk broadcast in sepsis.
415
+ - With few pairs, early stopping lands at about 2,000–3,000 steps. That is a usable fixed schedule when no pairs can be spared for inner validation.
416
+
417
+ **ImMicro, all five folds pooled (107 donors; reference = all 107 donors):**
418
+
419
+ | training pairs | comp L1 (vs zero-shot cal, p) | across-donor NK r |
420
+ |---:|---|---:|
421
+ | 5 | 0.171 (2e-5) | 0.20 |
422
+ | 10 | 0.188 (0.06) | 0.40 |
423
+ | 20 | 0.172 (4e-5) | 0.56 |
424
+ | 40 | 0.171 (1e-4) | 0.70 |
425
+ | all | 0.162 (2e-7) | 0.70 |
426
+
427
+ Zero-shot paired cal gives L1 0.199.
428
+
429
+ ## K augmentation (2026-09-28)
430
+
431
+ **Sepsis, pooled over 82 donors; each arm vs plain LoRA:**
432
+
433
+ | arm | comp L1 | coverage | sepsis-vs-control r (mean) | partial r beyond broadcast |
434
+ |---|---:|---:|---:|---:|
435
+ | plain LoRA (K = 1000) | 0.362 | 0.829 | 0.527 | 0.469 |
436
+ | multi-K real bulk (K 250–4000) | 0.366 (p 0.70) | 0.819 | 0.509 | 0.447 |
437
+ | + half-batch pretraining recipes | 0.365 (p 0.73) | 0.817 | 0.496 | 0.431 |
438
+
439
+ - Inner-validation losses were within 0.0001 of plain LoRA in every fold.
440
+ - Neither augmentation helps: every metric is equal or slightly worse.
441
+
442
+ **ImMicro, pooled over 107 donors:**
443
+
444
+ | arm | comp L1 (vs plain LoRA, p) | precision | coverage | across-donor r (T/B/Mono/NK) |
445
+ |---|---|---:|---:|---|
446
+ | plain LoRA | 0.162 | 0.924 | 0.784 | 0.74/0.75/0.86/0.70 |
447
+ | multi-K | 0.168 (p 0.04, worse) | 0.928 | 0.775 | 0.74/0.76/0.85/0.66 |
448
+ | recipes | 0.161 (p 0.75) | 0.933 | 0.766 | 0.78/0.78/0.86/0.65 |
449
+
450
+ Inner-validation losses were within 0.0001 of plain LoRA in every fold.
451
+
452
+ **Conclusion:**
453
+ - Varying K brings no gain in either dataset. On the real-bulk side K is only a scale label.
454
+ - Recipes repeat the pretraining task, which does not teach the real-bulk mapping.
455
+ - The protocol keeps a single K = 1000 for the real-bulk condition.
456
+
457
+ ## Running (2026-09-28)
458
+
459
+ - **LoRA learning curve:**
460
+ - n training donors ∈ {5, 10, 20, 40}, nested and stratified (sepsis keeps its case:control ratio), subset seed 1000 + fold.
461
+ - Inner-validation and test rows are unchanged. `--train-n` in `ft_sdd.py`.
462
+ - Queues `*_lora_learning_curve.txt`: sepsis first, then ImMicro.
463
+ - **K augmentation** (`tools/ft_sdd_aug.py`, queues `*_lora_aug.txt`, after the learning curve):
464
+ - `lora_multik`: each training cell sees its donor's real bulk at K ∈ {250, 500, 1000, 2000, 4000}, with the per-cell depth kept.
465
+ - `lora_recipe`: half of each batch comes from one pretraining-style recipe. A recipe is K cells of one training donor (K from the pretraining grid, capped at that donor's cell count); its condition is their full-axis pseudobulk at recipe size K.
466
+ - Recipes need the full-axis cells in `data/<dataset>/cells_full.npz`, built by `tools/build_full_cells.py`. Their panel columns equal `cells_panel6k.npz` and their per-row sums equal `pseudo_raw_sum`.
467
+ - **Automation:** fold scoring, aggregation and pooled scoring follow automatically (`ft-lc-finalize-*`, `ft-aug-finalize-*` units).
468
+
469
+ ## Queue
470
+
471
+ - Sepsis fold 0 pilot (same eight arms) → ImMicro folds 1–4 → sepsis folds 1–4.
472
+ - Arms for folds 1–4: zero-shot raw/cal/pseudo, FT full, FT LoRA, sc-only FT control.
473
+ - Chained as systemd user units (`ft-*`), logs in `logs/`.
paper-releases/pbisc-diffusion/updates/20261001T023742Z-deck-calibration-giroux-sexgenes/diffusion/dataset/server_1/model8/plans/paired_finetune_intradataset_20260927/scores_nochrY/README.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Giroux scores without chrY non-PAR genes (sensitivity, 2026-10-01)
2
+
3
+ Same as `../scores_nosex/giroux2022/` (see its README) but excluding only the 43 chrY non-PAR genes
4
+ (`data/sex_linked_genes/chrY_nonPAR_genes.csv`; 7 of them are Giroux scoring genes: ZFY, PCDH11Y, USP9Y, DDX3Y, UTY,
5
+ NLGN4Y, KDM5D) instead of the full
6
+ 196-gene sex-linked list. Not used by the deck; it shows that chrY genes carry most of the sex confound
7
+ (pooled LoRA logFC r 0.504 → 0.466 here vs 0.461 with the full list; broadcast r 0.638 → 0.579 vs 0.575).
paper-releases/pbisc-diffusion/updates/20261001T023742Z-deck-calibration-giroux-sexgenes/diffusion/dataset/server_1/model8/plans/paired_finetune_intradataset_20260927/scores_nochrY/giroux2022/fewshot_n5/draw0/README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # score_ft.py output: giroux2022, 11 scored donors
2
+
3
+ Arms: zs_raw, zs_pseudo, zs_cal, lora5. Every arm is scored on the same donors against the same observed reference.
4
+
5
+ ## Inputs and fixed contracts
6
+ - Observed reference: `/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/scoring_cache/giroux2022/reference.npz` (sha dd0152f7bde4), built from datadir:/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/data/giroux2022;
7
+ observed cells sum exactly to the features pseudobulk of every donor. Observed labels: /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/scoring_cache/giroux2022/observed_labels/labels/labels.parquet.
8
+ - Generated cells: `generated_counts` read out once with Poisson(seed 20260916) over the **whole NPZ in row order**
9
+ (`poisson_readout.poisson_integerise`), then the scored donors' rows. These integer counts are used for labels, embedding,
10
+ depth and the contrast. Pseudobulk uses the summed `generated_counts` (rates), as `score_generated.py`.
11
+ - Labels: frozen f01common scANVI (`predict_scanvi.py`, CPU, zero query epochs), six-type gate ['T cell', 'B cell', 'Monocyte', 'NK cell', 'DC', 'Other']; query genes =
12
+ the 1,006-gene annotation list minus genes the dataset's sc assay did not measure in every sample (1006 genes).
13
+ - Scoring genes: 6k panel genes measured by both assays in every sample of the dataset (5563 genes).
14
+
15
+ ## Definitions
16
+ 1. **Composition**: fraction of each donor's cells per six-type label (all generated cells; all observed QC cells).
17
+ `comp_l1` = sum over the six labels of |generated - observed| (immicro_common.l1). `comp_l1_obs_loo_null` = L1 of the
18
+ donor's observed composition to the mean of the *other scored donors'* observed compositions. `composition_top1` =
19
+ fraction of donors whose generated composition is closest (L1) to their own observed composition.
20
+ 2. **Pseudobulk**: `pb_r` = Pearson r of CPM-log1p(summed generated_counts) vs CPM-log1p(observed pseudobulk) on the scoring
21
+ genes (evaluate_realbulk.cpm_log1p / paired_r). `pb_top1` = the donor's generated pseudobulk is closest (Pearson) to its own
22
+ observed pseudobulk among the 11 scored donors (immicro_common.retrieval = evaluate_realbulk.top1 arithmetic).
23
+ 3. **Precision / coverage / density** (stage_b_embed.py functions): per-cell CP10K over the scoring genes + log1p; PCA-50
24
+ (randomized, random_state 20260925) and k = 10 real-real k-NN balls fitted on **R1 of the scored donors only**.
25
+ Reference rule (independent of fold and arm): per donor, cells in canonical order (library_id+barcode), one
26
+ permutation from `default_rng([20260925, uint64(sha256(donor)[:8])])`; R1 = first n, R2 = next n,
27
+ n = min(150, n_cells // 2) (1650 R1 cells here). Generated query: per donor n cells (the donor's R1 size),
28
+ without replacement, `default_rng([20260926, same key])`. Precision = fraction of generated cells inside any R1 ball
29
+ (Kynkaanniemi 2019); coverage = fraction of R1 cells whose ball holds a generated cell; density = Naeem 2020.
30
+ Per-donor precision = that donor's generated cells; per-donor coverage = that donor's R1 cells (the pooled values are
31
+ their n-weighted means; plain means when every donor has 150 reference cells). R2 (held-out real cells of the same donors) is the
32
+ perfect-generator control: precision 0.9988, coverage 1.0000.
33
+ **Depth matched**: stage_b_embed depth matching run pairwise (R1 vs this arm): per donor and within-donor rank of detected
34
+ genes, both cells are thinned by UMI sampling without replacement to the smaller detected-gene count; PCA kept from
35
+ un-thinned R1, radii recomputed on thinned R1; fresh rng(20260929) per arm. R2 control: precision
36
+ 0.9982, coverage 1.0000.
37
+ 4. **Monocyte %** = 100 x Monocyte fraction (all cells) per donor; **median UMI per cell** = median over cells of the
38
+ Poisson-read (generated) / observed counts summed over the scoring genes (per donor, and pooled).
39
+ 5. **Group contrast** (T, B, Monocyte, NK): case groups ['severe'] (n = 6) vs control groups ['mild'] (n = 5); rule: explicit --case-groups / --control-groups; groups from features groups.
40
+ Genes per type = scoring genes detected (count > 0) in >= 1 % of the scored donors' observed
41
+ cells of that type. Primary statistic `mean_cp10k`: per-cell CP10K over the scoring genes; per donor the mean over its
42
+ cells of the type (donors with >= 1 such cell); group mean = mean over the group's donors (donor-balanced);
43
+ logFC = log2(case mean + 1) - log2(control mean + 1). Secondary `pseudobulk_log1p_cpm`: the SLE benchmark evaluator's
44
+ statistic (donor x type summed counts, log1p CPM over the scoring genes, mean case - mean control;
45
+ evaluate_generated_vs_truth.group_log_fold_change). Both are computed on the generated cells (their frozen labels) and on
46
+ the observed cells; `r_generated` = Pearson r of the two logFC vectors. Broadcast baseline `r_broadcast`: the same
47
+ observed vector against the logFC of the input bulk (condition NPZ `bulk_counts` of the arm, scoring genes, per-donor
48
+ CP10K resp. log1p CPM, group means). `partial_r_generated_given_broadcast`: r of the OLS residuals of observed and
49
+ generated logFC on the bulk logFC (residual_specificity.py).
50
+ 6. **Top-50 DEG overlap** (contrast.csv rows `statistic = welch_top50_deg`; summary `deg_top50`): the SLE benchmark's score (`total_top50_overlap` of
51
+ `bulk2sc-paper/scripts/evaluate_generated_vs_truth.py`, Welch backend: the "top-50 DEG 81 / 84" of the final model), run
52
+ with the evaluator's own functions on the same donor x type pseudobulks as the contrast. Per cell type, observed and
53
+ generated separately: donor x type summed counts on all 5563 scoring genes (donors of the two groups with
54
+ >= 1 cell of the type) -> `welch_bh_deg` (log1p CPM, two-sided Welch t-test case vs control, Benjamini-Hochberg over the
55
+ genes with a defined p-value; needs >= 2 donors per group) -> `top_deg_genes` (FDR < 0.05, descending |logFC|,
56
+ first 50; shorter when fewer genes pass). `top50_overlap` = |observed list & generated list|; `top50_jaccard`
57
+ the evaluator's Jaccard. Summary `sum` = total over the scored types (the quantity reported as 81), `max` = the sum of
58
+ the observed list lengths (the "of 262"), `sum_4type` = T + B + Monocyte + NK. A type is scored when its observed test
59
+ is defined; an arm whose generated test is undefined for a scored type gets overlap 0. Types: T cell, B cell, Monocyte, NK cell, DC
60
+ (aggregates: /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/scoring_cache/giroux2022/deg_reference.npz).
61
+ **Broadcast analogue** (`top50_overlap_broadcast`, as `sle_broadcast.py` `broadcast_input_bulk`; not part of the
62
+ published benchmark): the same test on the arm's condition bulk_counts (scoring genes, the 6 + 5
63
+ donors), one whole-PBMC top-50 list, compared with every type's observed list.
64
+
65
+ ## Files
66
+ - `per_donor.csv`: one row per arm x donor (all per-donor quantities above).
67
+ - `summary.json`: per arm the donor means / pooled values, provenance (NPZ sha, receipt check, generation metadata,
68
+ Poisson nnz of the whole NPZ, annotation contract), and the reference block (PCA, R2 control).
69
+ - `contrast.csv`: per arm x cell type x statistic (`mean_cp10k`, `pseudobulk_log1p_cpm`: logFC r; `welch_top50_deg`:
70
+ top-50 DEG overlap, T / B / Monocyte / NK / DC; columns of the other kind are empty).
71
+ - `arms/<arm>/labels/` (predict_scanvi.py labels + manifest), `arms/<arm>/generated_cells.parquet` (NPZ row, donor, label,
72
+ UMI on the scoring genes, P/C subsample flag), `arms/<arm>/deg_top50_lists.csv` (observed, generated and broadcast
73
+ top-50 gene lists, Ensembl ids, rank order).
74
+
75
+ ## Gene exclusion (--exclude-genes)
76
+ `/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/data/sex_linked_genes/chrY_nonPAR_genes.csv` (sha 1962e57ca198): 43 genes listed, 7 of them scoring genes (ZFY, PCDH11Y, USP9Y, DDX3Y, UTY, NLGN4Y, KDM5D). Applies to: group contrast (logFC r generated / broadcast / partial: dropped from each type's detected-gene set) and top-50 DEG (observed, generated and broadcast tests: columns dropped before log1p CPM, Welch and BH); all other metrics use every scoring gene. Definitions 5 and 6 above therefore run on 5556 of the 5563 scoring genes.
77
+
78
+ ## Labels
79
+ Frozen scANVI labels reused from `/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927/scores/giroux2022/fewshot_n5/draw0` (same reference, NPZ sha256 and scored donors; checked per arm); predict_scanvi.py was not run.
paper-releases/pbisc-diffusion/updates/20261001T023742Z-deck-calibration-giroux-sexgenes/diffusion/dataset/server_1/model8/plans/paired_finetune_intradataset_20260927/scores_nochrY/giroux2022/fewshot_n5/draw0/contrast.csv ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ arm,celltype,statistic,n_genes,r_generated,r_broadcast,partial_r_generated_given_broadcast,r_generated_vs_broadcast,n_case_donors_obs,n_control_donors_obs,n_case_donors_gen,n_control_donors_gen,n_cells_obs,n_cells_gen,deg_scored,top50_overlap,top50_jaccard,obs_top_list_size,gen_top_list_size,n_sig_obs,n_sig_gen,top50_overlap_broadcast,top50_jaccard_broadcast,broadcast_top_list_size,n_sig_broadcast
2
+ zs_raw,T cell,mean_cp10k,2879,0.17265373766114323,0.46939608807045374,-0.03847316757050886,0.4330551472535464,6,5,6,5,59044,7427,,,,,,,,,,,
3
+ zs_raw,T cell,pseudobulk_log1p_cpm,2879,0.11361270455691228,0.5686634708166969,-0.05918839044304995,0.2819317999931617,6,5,6,5,59044,7427,,,,,,,,,,,
4
+ zs_raw,B cell,mean_cp10k,3023,0.1021026570296458,0.4004516889641065,-0.005015197001365424,0.26603101649180033,6,5,6,5,9139,2108,,,,,,,,,,,
5
+ zs_raw,B cell,pseudobulk_log1p_cpm,3023,0.05619639484443282,0.48116834270811815,-0.025883417475110068,0.1633147581430431,6,5,6,5,9139,2108,,,,,,,,,,,
6
+ zs_raw,Monocyte,mean_cp10k,3046,0.22623658665083457,0.6153178644123926,0.053832724327405344,0.30192817236985436,6,5,6,5,19384,5273,,,,,,,,,,,
7
+ zs_raw,Monocyte,pseudobulk_log1p_cpm,3046,0.17050106527258208,0.6262829875881031,0.06522839843025757,0.19256634154441238,6,5,6,5,19384,5273,,,,,,,,,,,
8
+ zs_raw,NK cell,mean_cp10k,2930,0.08768493439435406,0.4087987589061673,-0.014368342921469494,0.24558842587968607,6,5,6,5,11027,1205,,,,,,,,,,,
9
+ zs_raw,NK cell,pseudobulk_log1p_cpm,2930,0.07543902847935277,0.4742545161757578,0.01037535205611348,0.13999793310785255,6,5,6,5,11027,1205,,,,,,,,,,,
10
+ zs_raw,T cell,welch_top50_deg,5556,,,,,6,5,6,5,59044,7427,True,0,0.0,1,0,1,0,0,0.0,0,0
11
+ zs_raw,B cell,welch_top50_deg,5556,,,,,6,5,6,5,9139,2108,True,0,0.0,2,0,2,0,0,0.0,0,0
12
+ zs_raw,Monocyte,welch_top50_deg,5556,,,,,6,5,6,5,19384,5273,True,0,,0,0,0,0,0,,0,0
13
+ zs_raw,NK cell,welch_top50_deg,5556,,,,,6,5,6,5,11027,1205,True,0,,0,0,0,0,0,,0,0
14
+ zs_raw,DC,welch_top50_deg,5556,,,,,6,5,6,5,1558,324,True,0,,0,0,0,0,0,,0,0
15
+ zs_pseudo,T cell,mean_cp10k,2879,0.5351167264166181,0.826876324375208,0.12280780713984288,0.5790573888700146,6,5,6,5,59044,10666,,,,,,,,,,,
16
+ zs_pseudo,T cell,pseudobulk_log1p_cpm,2879,0.3626763622581737,0.8921477790098973,0.08330153134510151,0.3672884318289206,6,5,6,5,59044,10666,,,,,,,,,,,
17
+ zs_pseudo,B cell,mean_cp10k,3023,0.2884682250750583,0.5834183388245809,0.12466987648138,0.330655008883033,6,5,6,5,9139,1642,,,,,,,,,,,
18
+ zs_pseudo,B cell,pseudobulk_log1p_cpm,3023,0.146836747676207,0.6755899684544978,0.04854495298330405,0.165095380695644,6,5,6,5,9139,1642,,,,,,,,,,,
19
+ zs_pseudo,Monocyte,mean_cp10k,3046,0.21725331647343898,0.6761245483254927,0.0370321962655588,0.28261175738673816,6,5,6,5,19384,2811,,,,,,,,,,,
20
+ zs_pseudo,Monocyte,pseudobulk_log1p_cpm,3046,0.18867946219708562,0.7925439257402022,0.03286314004904196,0.21336420983206505,6,5,6,5,19384,2811,,,,,,,,,,,
21
+ zs_pseudo,NK cell,mean_cp10k,2930,0.3627427813649613,0.7423433837761454,0.1373472283194604,0.3736588672262371,6,5,6,5,11027,1147,,,,,,,,,,,
22
+ zs_pseudo,NK cell,pseudobulk_log1p_cpm,2930,0.17026970996231386,0.7789408188123772,0.027869578643816135,0.19659237511809075,6,5,6,5,11027,1147,,,,,,,,,,,
23
+ zs_pseudo,T cell,welch_top50_deg,5556,,,,,6,5,6,5,59044,10666,True,0,0.0,1,0,1,0,1,0.1111111111111111,9,9
24
+ zs_pseudo,B cell,welch_top50_deg,5556,,,,,6,5,6,5,9139,1642,True,0,0.0,2,0,2,0,0,0.0,9,9
25
+ zs_pseudo,Monocyte,welch_top50_deg,5556,,,,,6,5,6,5,19384,2811,True,0,,0,0,0,0,0,0.0,9,9
26
+ zs_pseudo,NK cell,welch_top50_deg,5556,,,,,6,5,6,5,11027,1147,True,0,,0,0,0,0,0,0.0,9,9
27
+ zs_pseudo,DC,welch_top50_deg,5556,,,,,6,5,6,5,1558,104,True,0,0.0,0,1,0,1,0,0.0,9,9
28
+ zs_cal,T cell,mean_cp10k,2879,0.12809901979088714,0.4951741911249375,-0.005529137368160023,0.2680408702975012,6,5,6,5,59044,8350,,,,,,,,,,,
29
+ zs_cal,T cell,pseudobulk_log1p_cpm,2879,0.1545776410392046,0.5691912850819923,0.0539878287797876,0.19508636658157644,6,5,6,5,59044,8350,,,,,,,,,,,
30
+ zs_cal,B cell,mean_cp10k,3023,0.07537830995547913,0.4270399386712111,0.00215906634178123,0.1720099301425345,6,5,6,5,9139,1402,,,,,,,,,,,
31
+ zs_cal,B cell,pseudobulk_log1p_cpm,3023,0.07525930399041524,0.48372774000063967,0.011207782754097048,0.13549047129659897,6,5,6,5,9139,1402,,,,,,,,,,,
32
+ zs_cal,Monocyte,mean_cp10k,3046,0.17787042008854576,0.6197215586910692,0.06031957320100093,0.2123698343721891,6,5,6,5,19384,4137,,,,,,,,,,,
33
+ zs_cal,Monocyte,pseudobulk_log1p_cpm,3046,0.09684199562626446,0.6248703169694699,0.0434872677892549,0.10092268798444796,6,5,6,5,19384,4137,,,,,,,,,,,
34
+ zs_cal,NK cell,mean_cp10k,2930,0.07209480821867507,0.4412864265945992,-0.008704077913419234,0.18078248683691098,6,5,6,5,11027,2212,,,,,,,,,,,
35
+ zs_cal,NK cell,pseudobulk_log1p_cpm,2930,0.1178957360173458,0.4733034547042273,0.05779768313721949,0.14261939257265524,6,5,6,5,11027,2212,,,,,,,,,,,
36
+ zs_cal,T cell,welch_top50_deg,5556,,,,,6,5,6,5,59044,8350,True,0,0.0,1,0,1,0,0,0.0,0,0
37
+ zs_cal,B cell,welch_top50_deg,5556,,,,,6,5,6,5,9139,1402,True,0,0.0,2,0,2,0,0,0.0,0,0
38
+ zs_cal,Monocyte,welch_top50_deg,5556,,,,,6,5,6,5,19384,4137,True,0,,0,0,0,0,0,,0,0
39
+ zs_cal,NK cell,welch_top50_deg,5556,,,,,6,5,6,5,11027,2212,True,0,,0,0,0,0,0,,0,0
40
+ zs_cal,DC,welch_top50_deg,5556,,,,,6,5,6,5,1558,126,True,0,0.0,0,5,0,5,0,,0,0
41
+ lora5,T cell,mean_cp10k,2879,0.4033494362917463,0.46939608807045374,0.2820323640778542,0.3654574327513499,6,5,6,5,59044,10814,,,,,,,,,,,
42
+ lora5,T cell,pseudobulk_log1p_cpm,2879,0.22805160719956538,0.5686634708166969,0.11706676130510867,0.2364978398329392,6,5,6,5,59044,10814,,,,,,,,,,,
43
+ lora5,B cell,mean_cp10k,3023,0.17455750060595854,0.4004516889641065,0.11837111038060946,0.16893653174445578,6,5,6,5,9139,1203,,,,,,,,,,,
44
+ lora5,B cell,pseudobulk_log1p_cpm,3023,0.04543114302691974,0.48116834270811815,0.02901753924424046,0.04159784743431889,6,5,6,5,9139,1203,,,,,,,,,,,
45
+ lora5,Monocyte,mean_cp10k,3046,0.3146190175726008,0.6153178644123926,0.1759562917579817,0.2959961843557338,6,5,6,5,19384,2671,,,,,,,,,,,
46
+ lora5,Monocyte,pseudobulk_log1p_cpm,3046,0.16142288218654618,0.6262829875881031,0.06948842504313602,0.17254581723091647,6,5,6,5,19384,2671,,,,,,,,,,,
47
+ lora5,NK cell,mean_cp10k,2930,0.08928425164902473,0.4087987589061673,0.026718450061801867,0.1595224786130051,6,5,6,5,11027,1009,,,,,,,,,,,
48
+ lora5,NK cell,pseudobulk_log1p_cpm,2930,0.015670717261256253,0.4742545161757578,-0.007716535454782133,0.04735145302889278,6,5,6,5,11027,1009,,,,,,,,,,,
49
+ lora5,T cell,welch_top50_deg,5556,,,,,6,5,6,5,59044,10814,True,0,0.0,1,1,1,1,0,0.0,0,0
50
+ lora5,B cell,welch_top50_deg,5556,,,,,6,5,6,5,9139,1203,True,0,0.0,2,0,2,0,0,0.0,0,0
51
+ lora5,Monocyte,welch_top50_deg,5556,,,,,6,5,6,5,19384,2671,True,0,0.0,0,1,0,1,0,,0,0
52
+ lora5,NK cell,welch_top50_deg,5556,,,,,6,5,6,5,11027,1009,True,0,0.0,0,2,0,2,0,,0,0
53
+ lora5,DC,welch_top50_deg,5556,,,,,6,5,6,5,1558,291,True,0,,0,0,0,0,0,,0,0