junidude14 commited on
Commit
ea735b3
·
verified ·
1 Parent(s): 924a4ca

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/audit_reuse_20261013/backups/deconvolution/tools/finalize_campaign.py ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Complete source-bound CPU analyses and render Figure 1–5 after the GPU campaign."""
2
+ from __future__ import annotations
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import time
10
+
11
+ from runtime import Runtime, atomic_json, sha256, stamp
12
+ import campaign as C
13
+
14
+ ROOT = C.ROOT
15
+ ARMS = ("lora", "pairedcal", "scsemi", "raw", "refcal")
16
+ PDF_PY = "/home/sj_server_1/miniforge3/bin/python" # verified pptx, matplotlib, pandas environment
17
+
18
+
19
+ def assert_publication_ready(figures: dict, rare: dict) -> None:
20
+ if figures.get("status") != "complete":
21
+ raise ValueError("Figure 2–4 strict evidence is incomplete")
22
+ if rare.get("design") != "strict5pair" or rare.get("units") != 20:
23
+ raise ValueError("Figure 5 requires all 20 strict units; diagnostic results are insufficient")
24
+
25
+
26
+ def generated_arms(path: Path) -> dict[str, Path]:
27
+ cohort = C.read_support(path)["cohort"]
28
+ values = {a: C.gen_dir(path) / f"{a}.npz" for a in ("lora", "pairedcal", "scsemi")}
29
+ values.update({a: ROOT / "generated/global" / cohort / f"{a}.npz" for a in ("raw", "refcal")})
30
+ return values
31
+
32
+
33
+ def wait_cuda_idle() -> None:
34
+ while True:
35
+ result = subprocess.run(["nvidia-smi", "--query-compute-apps=pid,process_name,used_memory",
36
+ "--format=csv,noheader"], capture_output=True, text=True, check=True)
37
+ if not result.stdout.strip():
38
+ return
39
+ time.sleep(15)
40
+
41
+
42
+ def deconvolution(runtime: Runtime, units: list[Path]) -> None:
43
+ script = ROOT / "tools/deconv_strict.py"
44
+ for path in units:
45
+ support = C.read_support(path)
46
+ if support["cohort"] == "immicro":
47
+ continue
48
+ out = ROOT / "deconvolution" / C.relative(path)
49
+ for action in ("prepare", "bayesprism", "cibersortx", "score"):
50
+ wait_cuda_idle()
51
+ outputs = {"prepare": [out / "INPUTS.json"],
52
+ "bayesprism": [out / "inputs" / support["cohort"] / "fewshot0_full/bp/DONE"],
53
+ "cibersortx": [out / "cibersortx" / support["cohort"] / "fewshot0/out_fractions/DONE"],
54
+ "score": [out / "score/SUMMARY.json", out / "score/figure4_methods.csv",
55
+ out / "score/expression_signal.csv"]}[action]
56
+ runtime.execute(f"{C.name(path)}-deconv-{action}",
57
+ [C.CPU_PY, "-u", str(script), "--support-manifest", str(path),
58
+ "--action", action, "--threads", "4"], memory_gib=24,
59
+ inputs=[path, script], outputs=outputs,
60
+ previous_outputs=preserve_preview_outputs(runtime, f"{C.name(path)}-deconv-{action}", outputs)
61
+ if action == "prepare" else None)
62
+ if action == "score":
63
+ result = json.loads((out / "score/SUMMARY.json").read_text())
64
+ if result.get("status") not in ("complete", "complete_with_not_estimable"):
65
+ raise ValueError(f"deconvolution is not complete: {out}")
66
+
67
+
68
+ def rare_caches(runtime: Runtime, units: list[Path]) -> None:
69
+ script = ROOT / "tools/rare_cache_builder.py"
70
+ for path in units:
71
+ if C.read_support(path)["cohort"] == "immicro":
72
+ continue
73
+ out = ROOT / "work/rare_strict_caches" / C.relative(path)
74
+ score = ROOT / "scores" / C.relative(path) / "score"
75
+ argv = [C.CPU_PY, "-u", str(script), "--support-manifest", str(path),
76
+ "--score-dir", str(score), "--output-dir", str(out),
77
+ "--cell-budget", "1500", "--depth-target", "1000"]
78
+ for arm, source in generated_arms(path).items():
79
+ argv += ["--arm", f"{arm}={source}"]
80
+ runtime.execute(f"{C.name(path)}-rare-cache", argv, memory_gib=16,
81
+ inputs=[path, script, score / "summary.json", score.parent / "scoring_support.json"],
82
+ outputs=[out / "rare_manifest.json"])
83
+
84
+
85
+ def preserve_diagnostic() -> None:
86
+ """Keep the first diagnostic's source data when strict tables replace the live navigation files."""
87
+ dest = ROOT / "diagnostic_legacy_v1"
88
+ if dest.exists():
89
+ return
90
+ files = [*sorted((ROOT / "source_data").glob("rare_*")),
91
+ *sorted((ROOT / "reports").glob("rare_*")),
92
+ *sorted((ROOT / "figures").glob("fig5*diagnostic*"))]
93
+ records = []
94
+ for path in files:
95
+ if path.is_file():
96
+ target = dest / path.relative_to(ROOT)
97
+ target.parent.mkdir(parents=True, exist_ok=True)
98
+ shutil.copy2(path, target)
99
+ records.append({"path": str(target), "sha256": sha256(target)})
100
+ atomic_json(dest / "PRESERVED.json", {"at": stamp(), "design": "legacy_5donor_diagnostic", "files": records})
101
+
102
+
103
+ def preserve_preview_outputs(runtime: Runtime, name: str, paths: list[Path]) -> dict:
104
+ """A preview may be replaced only after preserving its exact bytes with an explicit receipt."""
105
+ if runtime.receipt_path(name).exists():
106
+ return {}
107
+ proof = {}
108
+ for path in paths:
109
+ if not path.exists():
110
+ continue
111
+ dest = ROOT / "previews/before_strict_final" / name / path.relative_to(ROOT)
112
+ dest.parent.mkdir(parents=True, exist_ok=True)
113
+ if dest.exists() and sha256(dest) != sha256(path):
114
+ raise ValueError(f"a different preview is already preserved: {dest}")
115
+ if not dest.exists():
116
+ shutil.copy2(path, dest)
117
+ proof[str(path)] = {"backup": str(dest), "sha256": sha256(path)}
118
+ if proof:
119
+ atomic_json(ROOT / "previews/before_strict_final" / f"{name}.json", {"at": stamp(), "outputs": proof})
120
+ return proof
121
+
122
+
123
+ def _run_preserving(runtime: Runtime, name: str, argv: list[str], *, memory_gib: int,
124
+ inputs: list[Path], outputs: list[Path]) -> None:
125
+ runtime.execute(name, argv, memory_gib=memory_gib, inputs=inputs, outputs=outputs,
126
+ previous_outputs=preserve_preview_outputs(runtime, name, outputs))
127
+
128
+
129
+ def cross_draw_statistics(runtime: Runtime, units: list[Path]) -> None:
130
+ script = ROOT / "tools/finalize_outputs.py"
131
+ disease = [p for p in units if C.read_support(p)["cohort"] != "immicro"]
132
+ if len(disease) != 20:
133
+ raise ValueError("cross-draw statistics require all 20 disease units")
134
+ inputs = [script, ROOT / "tools/score_strict.py", ROOT / "tools/donor_statistics.py"]
135
+ for path in disease:
136
+ base = ROOT / "scores" / C.relative(path)
137
+ inputs.extend([path, base / "scoring_support.json", base / "score/summary.json",
138
+ base / "score/per_donor.csv", base / "statistics/per_donor_long.csv",
139
+ base / "statistics/status.json"])
140
+ _run_preserving(runtime, "aggregate-five-draw-donor-ci",
141
+ [C.CPU_PY, str(script), "--action", "cross-draw", "--require-complete"],
142
+ memory_gib=8, inputs=inputs,
143
+ outputs=[ROOT / "source_data/fig4_cross_draw_donor_ci.csv",
144
+ ROOT / "source_data/fig4_cross_draw_donor_ci.json"])
145
+
146
+
147
+ def corrected_disease_signal(runtime: Runtime, units: list[Path]) -> None:
148
+ script = ROOT / "tools/disease_signal.py"
149
+ disease = [p for p in units if C.read_support(p)["cohort"] != "immicro"]
150
+ if len(disease) != 20:
151
+ raise ValueError("donor-aware disease signal requires all 20 disease units")
152
+ inputs = [script, ROOT / "tools/score_strict.py", ROOT / "tools/donor_statistics.py"]
153
+ for path in disease:
154
+ base = ROOT / "scores" / C.relative(path)
155
+ deg = base / "statistics/donor_deg"
156
+ inputs.extend([path, base / "scoring_support.json", base / "score/summary.json",
157
+ base / "statistics/status.json", deg / "genes_kept.csv",
158
+ deg / "donor_deg_summary.csv"])
159
+ inputs.extend(sorted(p for p in deg.glob("*/*/*") if p.is_file() and p.name in (
160
+ "donor_condition_pseudobulk.csv", "donor_limma_genes.csv", "limma_status.json")))
161
+ cohort = C.read_support(path)["cohort"]
162
+ inputs.extend([C.OLD / "data" / cohort / "features.npz", C.OLD / "data" / cohort / "folds.csv"])
163
+ names = ("fig4_donor_aware_signal.csv", "fig4_donor_aware_summary.csv",
164
+ "fig4_donor_aware_genes.csv", "fig4_donor_aware_cat.csv",
165
+ "fig4_donor_aware_provenance.json")
166
+ _run_preserving(runtime, "compute-donor-aware-disease-signal",
167
+ [C.CPU_PY, str(script), "--require-complete"], memory_gib=12,
168
+ inputs=inputs, outputs=[ROOT / "source_data" / name for name in names])
169
+
170
+
171
+ def _figure234_outputs() -> list[Path]:
172
+ names = ("fig2_ablation_and_support", "fig3_healthy_strict_oof", "fig3_realism_metrics",
173
+ "fig3_umap_by_celltype", "fig3_composition_fractions", "fig3_runtime_components",
174
+ "fig3_canonical_marker_dotplot", "fig4_disease_strict_draws", "fig4_disease_signal_strict",
175
+ "fig4_disease_signal_scatter", "fig4_disease_signal_heatmap", "fig4_disease_signal_cat",
176
+ "fig4_deconvolution_strict", "fig4_deconvolution_expression_strict",
177
+ "fig4_deconvolution_historical_signal", "fig4_deconvolution_covered_sensitivity",
178
+ "fig4_historical_5fold_separate")
179
+ files = [ROOT / "figures" / f"{name}.{ext}" for name in names for ext in ("pdf", "svg", "png")]
180
+ files += [ROOT / "source_data" / name for name in (
181
+ "fig2_historical_rank_full.csv", "fig2_strict_curve.csv", "fig3_per_sample.csv",
182
+ "fig3_extras.csv", "fig4_strict_per_sample.csv", "fig4_corrected_statistics.csv",
183
+ "fig4_strict_contrast.csv", "fig4_deconvolution.csv", "fig4_deconvolution_signal.csv",
184
+ "fig4_historical_5fold.csv")]
185
+ files += [ROOT / "reports/figures234_readiness.json", ROOT / "reports/figures234_readiness.md"]
186
+ return files
187
+
188
+
189
+ def final_documents(runtime: Runtime, figures: dict, rare: dict) -> None:
190
+ assert_publication_ready(figures, rare)
191
+ deck = ROOT / "tools/build_review_deck.py"
192
+ panel_outputs = [ROOT / "deck" / f"fig1_panel_{panel}.{ext}"
193
+ for panel in ("ab", "cd", "e") for ext in ("png", "svg")]
194
+ _run_preserving(runtime, "render-final-review-deck",
195
+ [PDF_PY, str(deck), "--require-complete"], memory_gib=4,
196
+ inputs=[deck, ROOT / "reports/figures234_readiness.json",
197
+ ROOT / "reports/rare_provenance.json", ROOT / "reports/rare_visual_provenance.json"],
198
+ outputs=[ROOT / "deck/paper_figures_final.pptx", ROOT / "deck/final_gate_sources.json",
199
+ ROOT / "deck/README.md", *panel_outputs])
200
+ manuscript = ROOT / "tools/assemble_manuscript.py"
201
+ stage = ROOT / "manuscript"
202
+ previous_sources = [*stage.glob("*.tex"), *stage.glob("sections/*.tex"),
203
+ stage / "main.pdf", stage / "supplementary.pdf", stage / "integration_manifest.json"]
204
+ # Assembly changes many staged TeX files; preserve the earlier review copy
205
+ # before replacing any of them, while Runtime protects its manifest output.
206
+ proof = preserve_preview_outputs(runtime, "assemble-verified-manuscript", previous_sources)
207
+ manifest = stage / "integration_manifest.json"
208
+ runtime.execute("assemble-verified-manuscript", [C.CPU_PY, str(manuscript), "--require-complete"],
209
+ memory_gib=4,
210
+ inputs=[manuscript, ROOT / "reports/figures234_readiness.json",
211
+ ROOT / "reports/rare_provenance.json",
212
+ ROOT / "source_data/fig4_cross_draw_donor_ci.csv"],
213
+ outputs=[manifest],
214
+ previous_outputs={str(manifest): proof[str(manifest)]} if str(manifest) in proof else {})
215
+ export = ROOT / "tools/finalize_outputs.py"
216
+ _run_preserving(runtime, "compile-final-manuscript-pdfs",
217
+ [PDF_PY, str(export), "--action", "manuscript-pdf", "--require-complete"],
218
+ memory_gib=8, inputs=[export, manifest, stage / "main.tex", stage / "supplementary.tex"],
219
+ outputs=[stage / "main.pdf", stage / "supplementary.pdf"])
220
+ _run_preserving(runtime, "convert-final-deck-pdf",
221
+ [PDF_PY, str(export), "--action", "deck-pdf", "--require-complete"],
222
+ memory_gib=8, inputs=[export, ROOT / "deck/paper_figures_final.pptx",
223
+ ROOT / "deck/final_gate_sources.json"],
224
+ outputs=[ROOT / "deck/paper_figures_final.pdf"])
225
+
226
+
227
+ def render(runtime: Runtime, units: list[Path]) -> None:
228
+ preserve_diagnostic()
229
+ cross_draw_statistics(runtime, units)
230
+ corrected_disease_signal(runtime, units)
231
+ visual = ROOT / "tools/export_healthy_visuals.py"
232
+ _run_preserving(runtime, "export-healthy-visuals", [C.CPU_PY, str(visual)], memory_gib=24,
233
+ inputs=[visual, *units], outputs=[ROOT / "source_data" / name for name in (
234
+ "fig3_visual_data.json", "fig3_visual_data.npz", "fig3_marker_codetection.csv",
235
+ "fig3_runtime_evidence.json", "fig3_runtime.csv", "fig3_runtime.json",
236
+ "fig3_celltype_fractions.csv", "fig3_umap_coordinates.csv")])
237
+ cache_root = ROOT / "work/rare_strict_caches"
238
+ analysis = ROOT / "tools/build_figure5.py"
239
+ _run_preserving(runtime, "analyze-strict-rare", [C.CPU_PY, str(analysis), "--manifest-dir", str(cache_root)],
240
+ memory_gib=12, inputs=[analysis, *sorted(cache_root.rglob("rare_manifest.json"))],
241
+ outputs=[ROOT / "source_data" / name for name in (
242
+ "rare_per_sample.csv", "rare_per_donor.csv", "rare_summary.csv",
243
+ "rare_ineligible_states.csv")])
244
+ export = ROOT / "tools/export_rare_visuals.py"
245
+ _run_preserving(runtime, "export-strict-rare-visuals",
246
+ [C.CPU_PY, str(export), "--manifest-dir", str(cache_root)],
247
+ memory_gib=16, inputs=[export, ROOT / "source_data/rare_summary.csv"],
248
+ outputs=[ROOT / "reports/rare_visual_provenance.json", ROOT / "reports/rare_provenance.json",
249
+ *[ROOT / "source_data" / n for n in ("rare_visual_cells.csv", "rare_visual_heatmap.csv",
250
+ "rare_visual_donor_draws.csv")],
251
+ *[ROOT / "figures" / f"fig5_rare_visuals_strict.{ext}" for ext in ("pdf", "svg", "png")]])
252
+ plot = ROOT / "tools/figure5_panels.py"
253
+ _run_preserving(runtime, "render-strict-rare", [C.CPU_PY, str(plot), "--require-complete"],
254
+ memory_gib=4, inputs=[plot, ROOT / "tools/figure5_details.py", ROOT / "reports/rare_provenance.json"],
255
+ outputs=[ROOT / "source_data" / name for name in ("rare_behcet_descriptive.csv",
256
+ "rare_behcet_per_sample.csv", "rare_all_states.csv", "rare_all_states_aggregate.csv")]
257
+ + [ROOT / "reports/rare_behcet_provenance.json"]
258
+ + [ROOT / "figures" / f"fig5_{stem}_strict.{ext}" for stem in
259
+ ("rare_states", "all_states", "behcet_rules") for ext in ("pdf", "svg", "png")])
260
+ plot = ROOT / "tools/build_results_figures.py"
261
+ _run_preserving(runtime, "render-strict-figures234", [C.CPU_PY, str(plot), "--require-complete"],
262
+ memory_gib=8, inputs=[plot, ROOT / "tools/figure2_panels.py", ROOT / "deconvolution/deconvolution_manifest.json",
263
+ ROOT / "source_data/fig4_cross_draw_donor_ci.json",
264
+ ROOT / "source_data/fig4_donor_aware_provenance.json"],
265
+ outputs=_figure234_outputs())
266
+ ready = json.loads((ROOT / "reports/figures234_readiness.json").read_text())
267
+ rare = json.loads((ROOT / "reports/rare_provenance.json").read_text())
268
+ strict = all(u.get("design") == "strict5pair" and u.get("evidence_tier") == "strict" for u in rare.get("units", []))
269
+ assert_publication_ready(ready, {"design": "strict5pair" if strict else "diagnostic", "units": len(rare.get("units", []))})
270
+ final_documents(runtime, ready, {"design": "strict5pair" if strict else "diagnostic",
271
+ "units": len(rare.get("units", []))})
272
+
273
+
274
+ def main() -> None:
275
+ p = argparse.ArgumentParser(description=__doc__)
276
+ p.add_argument("--stage", choices=("deconvolution", "rare", "render", "all"), default="all")
277
+ a = p.parse_args()
278
+ units = C.discover_units()
279
+ if len(units) != 40:
280
+ raise ValueError("all 40 strict support units are required before finalization")
281
+ runtime = Runtime(ROOT)
282
+ state = {"state": "running", "stage": a.stage, "at": stamp(), "figure6": "waiting_user_data"}
283
+ out = ROOT / "FINALIZATION_STATUS.json"
284
+ atomic_json(out, state)
285
+ try:
286
+ if a.stage in ("deconvolution", "all"):
287
+ deconvolution(runtime, units)
288
+ if a.stage in ("rare", "all"):
289
+ rare_caches(runtime, units)
290
+ if a.stage in ("render", "all"):
291
+ render(runtime, units)
292
+ if a.stage in ("render", "all"):
293
+ artifacts = [ROOT / "manuscript/main.pdf", ROOT / "manuscript/supplementary.pdf",
294
+ ROOT / "deck/paper_figures_final.pptx", ROOT / "deck/paper_figures_final.pdf",
295
+ ROOT / "source_data/fig4_cross_draw_donor_ci.csv",
296
+ ROOT / "source_data/fig4_donor_aware_signal.csv"]
297
+ if any(not p.is_file() or p.stat().st_size == 0 for p in artifacts):
298
+ raise ValueError("final PDF/deck or disease source artifact missing after render")
299
+ state.update(state="complete", artifacts={str(p): sha256(p) for p in artifacts},
300
+ canonical_integration="awaiting_review", archive_update="coordinator_task_end")
301
+ else:
302
+ state.update(state="selected_finalization_stage_complete")
303
+ state["finished_at"] = stamp()
304
+ except BaseException as exc:
305
+ state.update(state="stopped_needs_inspection", error=str(exc), stopped_at=stamp())
306
+ raise
307
+ finally:
308
+ atomic_json(out, state)
309
+
310
+
311
+ if __name__ == "__main__":
312
+ main()
paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/audit_reuse_20261013/backups/navigation/AGENTS.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model 8 PBISC-Diffusion paper maintenance
2
+
3
+ This active Model 8 source and its experiments are part of the
4
+ `pbisc-diffusion` paper. At task start, read
5
+ `../../paper-release-20260928/maintenance/POLICY.md` along with this
6
+ directory's README and applicable parent instructions.
7
+
8
+ At the end of each related task, follow that policy's versioned update
9
+ workflow for the exact source, experiment, checkpoint, or evidence assets that
10
+ changed. From the release root, use
11
+ `maintenance/update.py prepare --request FILE --id ID`, inspect the prepared
12
+ update, then run `maintenance/update.py publish ID --execute` and
13
+ `maintenance/update.py status` under the policy. Record a no-op or pending
14
+ status when no
15
+ asset changed or publication failed; never describe that as an upload. Do not
16
+ regenerate or alter the frozen 2026-09-28 release, its root manifests, or the
17
+ HF `paper-20260928` revision. Inference assets are location plus receipt by
18
+ default unless the task explicitly needs their payload.
19
+
20
+ The private dataset must stay private. Include datalake, VAE, or Model 7 assets
21
+ only with exact evidence that they are dependencies of this diffusion paper.
22
+ The parent host GPU safety rules still apply.
paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/audit_reuse_20261013/backups/navigation/deck_README.md ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PBISC-Diffusion paper summary deck (2026-09-30, r00; ordered by the six manuscript figures since 2026-10-06)
2
+
3
+ 76-slide English deck, ordered by the six main figures of the Nature-style manuscript plan (user request 2026-10-06,
4
+ following `paper-release-20260928/reference-papers/Nature Style Manuscript Writing.pdf`):
5
+ - Title and outline: 6 figures, Supplementary, Appendix, Discussion.
6
+ - "Manuscript plan: six main figures": a table of each figure's claim and how many panels are ready.
7
+ - For each figure:
8
+ - a divider;
9
+ - a plan slide, a table of panel / content / evidence slide / status (Ready, Adapt, Draft, Build, Run, Plan);
10
+ - the existing slides that serve its panels, each labelled "Fig. 2c" etc. in the top-right corner.
11
+ - Supplementary: a plan slide plus the from-scratch results. Appendix: the modified scSemiProfiler run. Discussion: the
12
+ other-tissues outlook.
13
+
14
+ User decisions of 2026-10-06:
15
+ - No PBISC-VAE: scSemiProfiler, a VAE-based method, is the comparison (Fig. 3).
16
+ - Fig. 2 shows LoRA first on the healthy cohort (ImMicro) with the realism metrics (precision, coverage, classifier
17
+ AUROC, MMD, E_N); the disease-cohort comparison comes later.
18
+ - CYBERSORTx and other bulk deconvolution methods go to the Supplementary only (PBISC generates single cells).
19
+ - Figs 4 and 6 stay unplanned. Their existing slides are kept in the section as "Fig. 4 candidate" / "Fig. 6 candidate".
20
+
21
+ Only order, section labels, the agenda and new plan or draft slides changed. The new slides are "Overview draft (Nature
22
+ style)", the manuscript's candidate Fig. 1, and "Pretraining corpus", the Fig. 1d strip. No new result figures were
23
+ made.
24
+ - The plan lives in `data/figure_plan.json`.
25
+ - `tools/figure_plan.py` draws the plan tables and the slide text, and checks that every slide is placed exactly once.
26
+ - `tools/restructure_figure_order_20261006.py` rebuilds the order from the plan. It is rerun after every plan change and
27
+ keeps all slide fields.
28
+ - The earlier section order (10 sections, 45 slides) is in `_archive/2026-10-06_before_figure_order/`.
29
+
30
+ Short keyword lines only; the figures carry the results. Every slide that uses a published method, metric or
31
+ baseline has a one-line "References:" footer; full citations are in the speaker notes.
32
+
33
+ - `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
34
+ - `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
35
+ - `data/slides_spec.json`: slide order, titles, keywords, footnotes, references, speaker-note text
36
+ - `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
37
+ - `figures/`: exactly the figures the slides show (PNG + PDF), made by `tools/sec*.py`. Intermediate panels go to a
38
+ temporary folder; superseded figures are deleted, not kept (2026-10-02, user request; every deleted file was
39
+ checked to be in the paper archive by sha256 first).
40
+ - `data/sec*.csv` and `data/*_slide_text.json`: every plotted or quoted number with its source path
41
+ - `render/`: PDF and 70-dpi slide JPGs for checking
42
+
43
+ ## Slide order
44
+
45
+ | section | slides |
46
+ |---|---|
47
+ | 1 Model overview | bulk in, cells out; denoiser |
48
+ | 2 Backbone | SDD → PBISC-Diffusion; bulk conditioning |
49
+ | 3 Architecture ablation | width & context (loss, benchmark); gene panel |
50
+ | 4 Metrics + SLE benchmark | **how we score generated cells** (metric table with references); SLE benchmark; per cell type; bulk broadcast baseline |
51
+ | 5 Real bulk vs pseudobulk | input shift; same shift in three cohorts; cells off-manifold; disease direction flips |
52
+ | 6 Paired fine-tuning | method; evaluation design |
53
+ | 7 LoRA ablations | full vs LoRA vs cond.-encoder-only; LoRA rank r = 4 / 16 / 64; K diversification |
54
+ | 8 Pairs needed | composition / coverage / steps (with scSemiProfiler at the same n); donor and disease signal; pairs from other cohorts; longer training on them (with training minutes) |
55
+ | 9 Paired validation | cohorts; 5 donors: cells, realism beyond P/C, P/C at k = 3 / 5 / 10, scSemiProfiler copies its representative, disease signal, CAT curves, time to apply; 5-fold CV (with scSemiProfiler on the same pairs); same training pairs: LoRA vs scSemiProfiler; 5-fold realism metrics |
56
+ | 10 Next steps | paired-subset cohorts (planned); other tissues from a few dozen pairs (Discussion framing of the from-scratch results) |
57
+ | Supplementary | no pretraining: same cohort, from scratch (pilot); no pretraining: other cohorts, from scratch (pilot); rare states: from scratch vs pretrained; deconvolution with the same pairs: composition; deconvolution with the same pairs: disease signal |
58
+ | Appendix | scSemiProfiler without its output threshold (sensitivity; modified read-out, not the official output) |
59
+
60
+ ## Rebuild
61
+
62
+ Everything is CPU only; no GPU or checkpoint is touched.
63
+
64
+ ```bash
65
+ # prerequisites (plan folder plans/paired_finetune_intradataset_20260927/, CPU):
66
+ # scsemi/tools/representative_dependence.py -> scsemi/analysis/representative_dependence_20261002/
67
+ # tools/contrast_extra.py (+ tools/contrast_extra_tables.py) -> scores_contrast/ (Spearman, ceiling, limma, CAT, RBO)
68
+ # tools/build_tpm_zeroshot.py + tools/score_tpm_zeroshot.sh -> scores/<ds>/zeroshot_tpm_20261002/pooled/
69
+ # (the length-corrected zero-shot arm needs one GPU sampling step: tools/sample_lockwait.sh, coordinator only)
70
+ cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
71
+ # shared helpers, not run directly: style.py, sec03_common.py, scsemi_results.py, fold_sizes.py
72
+ for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
73
+ sec04_metrics_overview sec04_sle_benchmark sec05_condition_space sec05_cells_offmanifold \
74
+ sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
75
+ sec07_k_aug sec07_rank_sweep sec08_pairs_needed sec08_cross_cohort sec09_paired_validation sec09_extra_metrics \
76
+ sec09_time_to_apply sec09_scsemi_representative sec09_cat_curves sec10_paired_subset_cohorts \
77
+ secA_scsemi_readout sec07_no_pretraining sec08_cross_scratch sec09_same_pairs \
78
+ secS_scratch_rare_states secS_deconvolution fig3_time_days fig4_disease fig23_healthy fig5_rare_states sec10_other_tissues figure_plan; do # keep this order (sec10 reads secS; figure_plan last)
79
+ python3 "tools/$f.py" || break
80
+ done
81
+ python3 tools/restructure_figure_order_20261006.py # order the slides by data/figure_plan.json
82
+ python3 tools/sync_sec09_text.py # copy every generated slide text (sec09_index / text_source) into the spec
83
+ python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
84
+ soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
85
+ pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
86
+ cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
87
+ ```
88
+
89
+ `generate_deck.py` stops with an error if a figure is missing, a title does not fit on one line, a footnote needs
90
+ more than 2 lines (1 line when the slide has references), the reference line needs more than 1 line, or any text
91
+ contains Korean or placeholder words. `tools/restructure_20261002.py` is the one-off script that produced the current
92
+ slide order and the references (it refuses to run twice).
93
+
94
+ ## Notes
95
+
96
+ - **No "all" label (2026-10-02).** The 5-fold arm trains each fold model on the other four folds minus 7–8
97
+ inner-validation donors; its test fold is never trained on (RUN.json `test_rows_never_loaded_for_training`). Figures
98
+ label it "5-fold CV (other 4 folds)" and learning-curve ticks show the training-pair count per fold (78–79 ImMicro,
99
+ 58–59 sepsis), read by `tools/fold_sizes.py`.
100
+ - **Learning curve x = 0 uses no pairs (2026-10-02).** It shows the zero-shot model fed the real bulk as measured
101
+ and after exon-length correction (counts / Ensembl union-exon kb, then the same fixed-depth arithmetic;
102
+ `plans/.../tools/build_tpm_zeroshot.py`, scored in `scores/<ds>/zeroshot_tpm_20261002/pooled`). The old x = 0
103
+ calibration point, whose alpha used every training pair of the fold, is gone; calibration appears only fitted on the
104
+ same n pairs as the LoRA point (squares; `cal_budget_20261001`).
105
+ - **Disease metrics (2026-10-02).** Next to Pearson logFC r and the Welch top-50 DEG overlap: Spearman r, the
106
+ split-half ceiling (observed vs observed, Spearman–Brown), limma-voom top-50 DEG, each arm's chance overlap, and
107
+ CAT curves with the k / 2G chance line (`plans/.../scores_contrast/`, tools/contrast_extra.py; every Pearson r and
108
+ Welch count reproduced exactly). Repeated samples of one patient (Imperial, Giroux, Ji) count as separate samples in
109
+ both DE tests, as in the scorer (footnote).
110
+ - Section 9 text is generated: `tools/sec09_paired_validation.py`, `sec09_extra_metrics.py`, `sec07_rank_sweep.py`,
111
+ `sec09_time_to_apply.py`, `sec09_scsemi_representative.py`, `sec09_cat_curves.py` write slide text JSON; sync copies
112
+ it. Hand-written: the keywords of the two "Pairs needed" slides (section 8) and of every slide in sections 1–7 and 10.
113
+ - Giroux's disease metrics exclude 196 sex-linked genes (severity is confounded with sex), from
114
+ `plans/.../scores_nosex/`. The calibration comparator is "Zero-shot + calibration" (user decision 2026-10-01).
115
+ - Story rule (user decision 2026-09-30): no PBISC-VAE and no reference calibration (refcal). The exon-length-corrected
116
+ input is used only as the no-pair x = 0 point of the learning curve (user decision 2026-10-02).
117
+ `tools/sec04_immicro.py` (refcal vs scSemiProfiler on ImMicro) is kept but is not part of the deck or the rebuild.
118
+ - scSemiProfiler 5-fold and equal-budget results are picked up automatically when they appear (`tools/scsemi_results.py`;
119
+ arm `scsemi__raw` in `scores/<cohort>/scsemi_cv_20261002/pooled*/`, `scsemi_n{5,10,20,40}__raw` in
120
+ `scores/<cohort>/scsemi_budget_20261002/pooled*/`; same donors and reference cells as the main pooled call only).
121
+ Then rerun sections 8 and 9, sync, recheck the section 8 keywords and rebuild.
122
+ - Earlier versions: `_archive/2026-09-30_before_no_vae_refcal/`, `_archive/2026-10-01_before_extra_metrics/`,
123
+ `_archive/2026-10-02_before_time_to_apply/`, `_archive/2026-10-02_before_restructure/` (pptx, PDF, spec; their
124
+ figures are in the paper archive). `DRAFT_1150_*`: the copy shown at the 2026-09-30 12:00 meeting.
125
+
126
+ - Added 2026-10-03 (user decision: the cross-cohort experiment is reported at K = 1000 only and is the figure that explains
127
+ why PBISC fits LoRA on a few pairs of each cohort): slides 25-26 in section 8, `tools/sec08_cross_cohort.py`.
128
+ - Slide 25 "Pairs from other cohorts do not transfer": per held-out cohort, composition L1 / coverage / disease logFC r of
129
+ zero-shot, calibration fitted on the other cohorts, LoRA r16 / r64 / full fine-tune trained on the other cohorts
130
+ (+ Liu 2021) at step saturation, and LoRA on the cohort's own pairs (5-fold pooled).
131
+ - Slide 26 "Longer training on other cohorts" (": gap stays" since 2026-10-06): the same metrics at every 20k-step
132
+ milestone.
133
+ - Source plan: `plans/paired_crosscohort_20261002/` (README; same-reference and same-sample checks in the script).
134
+ Agenda item 8 now reads "How many pairs, and do other cohorts' pairs transfer". The deck has 37 slides.
135
+ Pre-update copy: `_archive/2026-10-03_before_cross_cohort/`.
136
+
137
+ ## Sources
138
+
139
+ Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
140
+ `plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
141
+ `plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
142
+ `analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each `data/sec*.csv`. Reference PDFs:
143
+ `/home/sj_server_1/PBISC/paper-release-20260928/reference-papers/` (INDEX.md). Manuscript:
144
+ `/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
145
+ - 2026-10-04 appendix (user decision: supplementary, appendix only, because it changes scSemiProfiler's official
146
+ output). Slide 38 is the divider "Appendix" and slide 39 is "Appendix: scSemiProfiler without output threshold"
147
+ (`tools/secA_scsemi_readout.py`, `data/secA_scsemi_readout{.csv,_slide_text.json}`).
148
+ - Inputs: `plans/paired_finetune_intradataset_20260927/scsemi/analysis/output_variants_20261003/`. The script checks
149
+ that its LoRA-5 and official scSemiProfiler values equal the section 9 slide data draw by draw.
150
+ - Result: without upstream's output threshold, scSemiProfiler's coverage rises in 5/5 cohorts, and 23/23 LoRA-5
151
+ comparisons (coverage, precision, composition, logFC r, DEG) keep their winner.
152
+ - The outline keeps its 10 sections (the builder requires 10). The pre-change copy is in
153
+ `_archive/2026-10-04_before_appendix/`. The deck has 39 slides.
154
+ - 2026-10-05 update (user request: put the results so far into the deck). Pre-change copy: `_archive/2026-10-05_before_scratch_cv/`.
155
+ - New slide 23, "No pretraining: same cohort, from scratch" (`tools/sec07_no_pretraining.py`). Pilot on sepsis fold 0
156
+ (17 donors). Reads `fold0_scratch_20261005/` and the runs' RUN.json. The donor composition r is recomputed from
157
+ per_donor.csv and reproduces ablation_extra_donor.csv.
158
+ - New slide 28, "No pretraining: other cohorts, from scratch" (`tools/sec08_cross_scratch.py`). Held-out sepsis pilot.
159
+ Every arm is read from `paired_crosscohort_20261002/scores_masked/`: genes no training cohort measured are zeroed
160
+ in all arms, because the unmasked scratch arm puts 91–94 % of its UMI there (read from the generated_masked logs
161
+ since 2026-10-06).
162
+ - New slide 38, "Same training pairs: LoRA vs scSemiProfiler" (`tools/sec09_same_pairs.py`). scSemiProfiler 5-fold
163
+ CV with LoRA's own training pairs, plus GPU hours per fold from the receipts on either host. Cohorts that are still
164
+ running show "in progress"; rerun the script as they finish.
165
+ - These two slides now draw the scSemiProfiler CV / budget runs automatically:
166
+ - Slide 24, "Pairs needed" (diamonds; ImMicro so far): keyword 2 reworded, footnote extended.
167
+ - Slide 37, "5-fold CV" (yellow bar; ImMicro and Ji so far).
168
+ - `tools/sec09_paired_validation.py` reads the scSemiProfiler CV arm's Spearman / limma values from
169
+ `scores_contrast/<cohort>/scsemi_cv_20261002/pooled/` (contrast_extra.py --design scored). Pearson r and the Welch
170
+ DEG must match the scorer; the values stay blank until computed. Cohorts not yet run say "in progress".
171
+ - Agenda item 7 now reads "LoRA: compute, rank, K; training from scratch". The deck has 42 slides.
172
+ - New helper: `tools/grouped_bars.py`.
173
+ - 2026-10-06 update (user request: check that the cross-cohort LoRA / full FT, cross-cohort from-scratch and
174
+ same-cohort from-scratch (+ recipes) results, with benchmarks and training times, and the scratch-vs-pretrained rare
175
+ states are in the deck; user decision: the from-scratch results go to the paper's Supplementary and the Discussion
176
+ presents them as a route to other tissues). Pre-change copy: `_archive/2026-10-06_before_supplementary/`.
177
+ - **Supplementary block (new divider, slides 40-43).**
178
+ - "No pretraining: same cohort, from scratch" and "No pretraining: other cohorts, from scratch" moved here from
179
+ sections 7 and 8. Their content is unchanged; slide 42's notes now name the cross-cohort slides by title.
180
+ - New "Rare states: from scratch vs pretrained" (`tools/secS_scratch_rare_states.py`).
181
+ - It reads the rare-state screen (`plans/rare_states_screen_20261004/out/sepsis_fold0_*` and
182
+ `sepsis_loco_masked_*`).
183
+ - The cross-cohort arms use the masked scoring (46 never-measured genes zeroed in every arm).
184
+ - The donor bootstrap reproduces the verified analysis in `out/scratch_vs_lora_20261005/REPORT.md`.
185
+ - **Section 10 "Next steps".**
186
+ - New "Next: other tissues from a few dozen pairs" (`tools/sec10_other_tissues.py`): a comparison table, pretrained
187
+ + LoRA vs from scratch.
188
+ - Every value is read from the deck's own source tables. The say text is the user's Discussion framing.
189
+ - **Slide 26 "Longer training on other cohorts".** The first keyword is now training minutes to saturation (RUN.json
190
+ wall seconds), with per-cohort minutes and steps in the notes (`tools/sec08_cross_cohort.py`).
191
+ - **Slide 34 "5 donors: time to apply".**
192
+ - The pretraining hours are read from `data/sec06_ft_method.csv`, no longer hard-coded.
193
+ - The note names the 'Fine-tuning with paired bulk + sc' slide by title. Its old "slide 15" pointed at the wrong
194
+ slide.
195
+ - Agenda items 7 and 10 updated. Spec change: `tools/restructure_20261006.py` (refuses to run twice). The deck has 45
196
+ slides; no Korean text.
197
+ - **Review pass (same day).** An independent 5-agent review of the changed slides confirmed 39 issues; all are
198
+ fixed. Pre-review copies of the touched scripts and the spec: `_archive/2026-10-06_before_supplementary/*.pre_review`.
199
+ - Slide 39: pretraining now reads 33.1 M train cells (`train_split_cells`; the 41.4 M corpus includes val/test).
200
+ The rare-state row follows the bootstrap verdicts on both sides (closer on ISG-high T / on DN2 B; labels and
201
+ states both arms miss by > 4-fold are not counted). "No corpus" became "come close": the scratch runs still took
202
+ the panel, value scaler and z-score constants from the PBMC checkpoint (RUN.json `kept_from_checkpoint`, now in
203
+ the notes). The say text carries the one-fold pilot qualifier; the footnote names both pilots.
204
+ - Slide 43: "no significant difference on average" (not "no difference"). Keyword 2 is the cycling T/NK count
205
+ (8 of 8 comparisons). The notes add the ISG-high T split by panel, the scratch-closer states (DN2 B, MS1), the
206
+ 52-call tally, the fold-0 caveat (fold 0 is the own-pair LoRA's best fold for C1Q-high and cycling T/NK,
207
+ computed from `folds.csv`), label states unthinned, and "8 of 13 states shown".
208
+ - Slide 26: title "...: gap stays" and "drifts in Sepsis and Ji" are computed from the milestones (gap = no milestone
209
+ reaches the own-cohort coverage; drift = full fine-tune L1 up by >= 0.05). Minutes are in
210
+ `data/sec08_cross_cohort.csv` (wall_seconds, minutes, run_receipt) and in the numbers list.
211
+ - Slide 42: UMI share (94 %, 91–94 % across milestones), the observed share (0.014 %, from `cells_panel6k.npz`)
212
+ and both arms' stopping settings are read from the receipts; the "none" label sits inside the axes.
213
+ - Slide 34: keywords use the cohort means of the figure (17–59×, 57 min–4.1 h); the per-draw range 11–63× is in the
214
+ notes. The right panel shares the bars' rows and has a title.
215
+ - Talk text and pointers: slides 23, 25, 26, 45 (say), 22 (recipes description), 32 and 36 (slide pointers by
216
+ title), slide 1 subtitle "updated 2026-10-06".
217
+ - 2026-10-08 update (user request: put the BayesPrism, CIBERSORTx and scSemiProfiler 5-fold results into the deck).
218
+ Pre-change copy: `_archive/2026-10-08_before_deconvolution/`.
219
+ - **Two new Supplementary slides** (`tools/secS_deconvolution.py`, `data/secS_deconvolution{.csv,_slide_text.json}`):
220
+ "Deconvolution with the same pairs: composition" and "...: disease signal".
221
+ - Source: `plans/bayesprism_paired_20261006/` (README, `results/RESULTS_full.md`, `RESULTS_cibersortx.md`).
222
+ - BayesPrism (recommended genes) and official CIBERSORTx (Fractions S-mode + HiRes) use the same paired donors
223
+ as the reference and the test samples' real bulk as the mixture, with the benchmark's own truth and scorer.
224
+ - Keywords and notes are computed from the tables.
225
+ - **Supplementary plan.** The planned "Bulk deconvolution methods" row is replaced by the two Ready slides.
226
+ `tools/figure_plan.py` now takes an optional per-slide note (`supplementary.notes`) and drops "Planned:" when
227
+ nothing is planned.
228
+ - **New scSemiProfiler results picked up (server_1):**
229
+ - Sepsis and Giroux 5-fold CV. Giroux was finalized on server_1 from sha-checked copies of its fold NPZs, and
230
+ rescored without sex-linked genes in `scores_nosex/giroux2022/scsemi_cv_20261002/pooled`.
231
+ - Sepsis equal-budget n = 5/10/20/40.
232
+ - Imperial 5-fold: finished on server_2 at 13:45 and was finalized on server_1 from sha-checked fold copies.
233
+ scSemiProfiler 5-fold now covers all five cohorts.
234
+ - Spearman/limma extras for sepsis, Giroux and Imperial; realism extras for all five cohorts.
235
+ - **Text changes from the new results:**
236
+ - "Same training pairs": keywords are data-driven. LoRA leads on coverage and precision in 5/5 cohorts;
237
+ composition 4/5 and logFC r 3/4, where scSemiProfiler leads in Giroux. The GPU-time ratio is 19–62×.
238
+ - sec09_same_pairs.py now reads the sepsis fold-0 pilot queue tag (`sep_f0`). For Giroux it quotes DEG from
239
+ scores_nosex, and for older pooled LoRA calls from pooled_deg.
240
+ - "5-fold CV" keyword: logFC r 3/4.
241
+ - "Pairs needed" (hand-written): scSemiProfiler coverage 0.04 / 0.10. On sepsis disease logFC r,
242
+ scSemiProfiler at 5–40 pairs (0.52–0.58) is above LoRA (0.29–0.48), while its top-50 DEG stays at 2–6.
243
+ - 2026-10-08, new figure split (user decision; supersedes the 2026-10-06 split; pre-change copy
244
+ `_archive/2026-10-08_before_new_figure_plan/`).
245
+ - Fig. 2: LoRA fine-tuning with no disease metrics.
246
+ - Fig. 3: PBISC vs scSemiProfiler on healthy donors, with time as a main result.
247
+ - Fig. 4: disease benchmarks on the paired cohorts (PBISC versions, scSemiProfiler, and BayesPrism / CIBERSORTx
248
+ labelled as cell-type deconvolution; the deconvolution slides moved here from the Supplementary).
249
+ - Fig. 5: rare-cell fractions and detection.
250
+ - Fig. 6: new findings from the bulk-only sepsis and COVID samples (K = 1,000 and 4,000).
251
+ - The cross-cohort transfer slides moved to the Supplementary; their placement is open.
252
+ - New slide "Time: days for scSemiProfiler, minutes for LoRA" (`tools/fig3_time_days.py`, Fig. 3d).
253
+ - Inputs: GPU hours per 5-fold experiment from the receipts (`data/sec09_same_pairs.csv`, checked against
254
+ the scSemiProfiler event logs on both hosts), the 5-donor draws (`data/sec09_time_to_apply.csv`) and the
255
+ one-time pretraining (`data/sec06_ft_method.csv`).
256
+ - Results: ImMicro 24 h vs 1.2 h, sepsis 38 h vs 37 min. All runs: scSemiProfiler 184 h (7.7 days) vs PBISC
257
+ 22 h including pretraining.
258
+ - The equal-budget scSemiProfiler runs are excluded: they reuse the 5-fold run's representative models.
259
+ - Panel status: Build / Run marks new slides or analyses still to do; Adapt marks slides to re-scope (healthy-only
260
+ Fig. 2-3, disease columns into Fig. 4).
261
+ - 2026-10-08, comparison rules (user decision; memory feedback_paper_comparison_rules):
262
+ - **Time.** Only per-cohort GPU work counts: no PBISC pretraining, no GPU queue waits. The time slide now shows the
263
+ 5-donor draws (main) next to the 5-fold runs (separate). All runs: 7.7 GPU-days vs 5.7 h.
264
+ - **No bulk-broadcast baseline.** It is removed from the SLE benchmark, CAT, deconvolution and "Pairs needed"
265
+ figures.
266
+ - The "Bulk broadcast baseline" slide is gone. Its partial r panel is now on the SLE benchmark slide
267
+ (0.21 vs 0.17).
268
+ - Still to rebuild in their own phases: Fig. 2e (ImMicro only) and Fig. 6a.
269
+ - **Main comparison = 5 pairs** (LoRA-5 vs scSemiProfiler-5); 5-fold is reported separately. Partial r is
270
+ emphasised (bold panel titles).
271
+ - **New `tools/fig4_disease.py`**, which checks all 200 logFC r / DEG values against the section-9 tables:
272
+ - "Disease signal with 5 pairs: LoRA-5 vs others" (4b);
273
+ - "5-fold CV: disease signal" (4c);
274
+ - "Sepsis: fine-tuning variants" (details).
275
+ - The old "5 donors: LoRA vs scSemiProfiler — disease signal" slide is retired. `tools/sync_sec09_text.py` lists it
276
+ in RETIRED.
277
+ - The deconvolution slides are retitled "Cell-type deconvolution, same pairs: ...".
278
+ - 2026-10-08, healthy-only Figs 2-3 (`tools/fig23_healthy.py`).
279
+ - Eight ImMicro-only slides, re-plotted from the deck's own data tables; nothing is re-scored.
280
+ - Fig. 2 (no disease metrics):
281
+ - cells, realism, full / LoRA / condition encoder, pairs needed, rank and K;
282
+ - 5 donors (main) shown next to 5-fold (separate).
283
+ - Fig. 3 (vs scSemiProfiler):
284
+ - LoRA-5 vs scSemiProfiler-5 on 6 cell metrics: LoRA ahead on 6 of 6;
285
+ - the same pairs, 5 to all;
286
+ - scSemiProfiler copies its representative;
287
+ - time.
288
+ - The earlier all-cohort slides moved to the Supplementary (note "all five cohorts").
289
+ - "5-fold CV: train on the other 4 folds" is retired (it carried the broadcast; its content is now in Fig. 4c and
290
+ the healthy slides). It is listed in RETIRED of `tools/sync_sec09_text.py`.
291
+ - 2026-10-08, Fig. 5 rare cells (`tools/fig5_rare_states.py`).
292
+ - Source: new plan `plans/rare_states_paired_20261008` (README). It covers 4 paired disease cohorts, the 5-donor
293
+ draws and 5-fold, and the arms zero-shot, calibration, scSemiProfiler and LoRA. Each NPZ is sha-checked and the
294
+ benchmark's Poisson read-out and labels are reproduced cell by cell.
295
+ - Three slides:
296
+ - fraction (5a);
297
+ - donors and disease direction (5b);
298
+ - 5-fold, separate (5c).
299
+ - Results over 56 state × cohort pairs, 5 donors:
300
+ - LoRA-5 closer to the observed fraction than scSemiProfiler-5 in 51/56;
301
+ - within 2-fold: 19 vs 5;
302
+ - better donor ranking: 43/56;
303
+ - disease direction kept: 73% vs 61%.
304
+ - Fig. 6a no longer mentions the broadcast. No slide text mentions it now.
305
+ - 2026-10-10, last broadcast mention removed from a figure (found while rewriting the manuscript from this deck).
306
+ - Fig. 2d "How we score generated cells" (`tools/sec04_metrics_overview.py`) still listed "broadcast; split-half
307
+ ceiling" as the comparator of logFC r inside the table image. It now reads "zero-shot; partial r (vs bulk)".
308
+ - Old tool, CSV and figure: `_archive/2026-10-10_metrics_overview_broadcast/`. The deck was rebuilt (76 slides); a
309
+ text search of every slide, the notes and the PDF twin of every figure a slide uses finds no "broadcast". Three
310
+ figure files of retired slides still contain it and are not used: `sec04_sle_broadcast`, `sec09_fewpair_disease`,
311
+ `sec09_fivefold`.
312
+ - The manuscript was rewritten from this deck on 2026-10-10 (`paper-release-20260928/manuscript/`,
313
+ `editorial/rewrite_20261010.md`); its figures are copies of this folder's figure PDFs.
314
+ - 2026-10-10, LoRA rank figure key (`tools/sec07_rank_sweep.py`): "LoRA rank r = 16 (used in the deck)" now reads
315
+ "(used throughout)", because the same panel is Supplementary Fig. 12a of the manuscript. Old files:
316
+ `_archive/2026-10-10_rank_sweep_label/`. Deck rebuilt (76 slides).
paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/plans/paper_figures_strictpairs_20261012/audit_reuse_20261013/backups/navigation/deconv_strict.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Strict five-pair deconvolution adapter
2
+
3
+ `tools/deconv_strict.py` runs one disease unit at a time. The support manifest is authoritative: exactly its five `train_sample_ids` form the reference, exactly its `test_sample_ids` form the real-bulk mixture, and `excluded_sample_ids` never enter either side. The old five-donor/all-visits split is not used. The original `aggregates_full.npz` is linked read-only inside the new unit output; it is a per-sample raw-count aggregate, not a fitted model or test-derived reference. The legacy builders and scorer are imported into one isolated Python invocation and redirected in memory. No legacy file is edited.
4
+
5
+ For a unit such as `protocol/splits/ji2025_chili/disease/draw0/support.json`, run from this plan directory:
6
+
7
+ ```bash
8
+ CUDA_VISIBLE_DEVICES='' python tools/deconv_strict.py --support-manifest protocol/splits/ji2025_chili/disease/draw0/support.json --action prepare --threads 4
9
+ CUDA_VISIBLE_DEVICES='' python tools/deconv_strict.py --support-manifest protocol/splits/ji2025_chili/disease/draw0/support.json --action bayesprism --threads 4
10
+ CUDA_VISIBLE_DEVICES='' python tools/deconv_strict.py --support-manifest protocol/splits/ji2025_chili/disease/draw0/support.json --action cibersortx --threads 4
11
+ CUDA_VISIBLE_DEVICES='' python tools/deconv_strict.py --support-manifest protocol/splits/ji2025_chili/disease/draw0/support.json --action score --threads 4
12
+ ```
13
+
14
+ `--action all` performs those stages in order. `--out` is accepted only when it equals the unit's canonical `deconvolution/<cohort>/disease/drawN` directory. Run the four actions for each of the 20 disease support manifests, one unit at a time. The CIBERSORTx action checks the two existing local images. It reads `cibersortx.key` only at runtime, writes a temporary mode-600 env file, expands credentials inside the container, redacts any echoed values before saving a log, and removes the temp file. It does not install images. Its two containers are each capped at 16 GiB and the requested CPU count. BayesPrism reuses the existing pinned R script and R library.
15
+
16
+ Every action runs the host guard checks first, defers when CUDA compute is present, and requires at least 48 GiB `MemAvailable` before the memory-heavy CPU work. The adapter never starts a CUDA process.
17
+
18
+ Each unit writes `INPUTS.json`, BayesPrism and CIBERSORTx method outputs, and `score/{figure4_methods.csv,expression_signal.csv,SUMMARY.json}`. The shared `deconvolution/deconvolution_manifest.json` is an atomic Figure 4 input with exact support hash, reference and mixture IDs, source hashes, methods, metric summaries, and CSV hashes. Pass it to `tools/build_results_figures.py --deconvolution-manifest deconvolution/deconvolution_manifest.json`. The old five-fold results remain a separately labelled historical panel.
19
+
20
+ Preparation is immutable once `INPUTS.json` exists: rerunning `prepare` verifies every input hash and the raw-count aggregate link, then returns without rewriting. A method's existing `DONE` is reusable only with a receipt bound to the support hash, prepared input hash, and method output hashes. HiRes also binds its copied Fractions signature, source GEP, and filtered fractions results. Changed inputs, an unreceipted existing `DONE`, or partial method files fail closed; the adapter does not delete or automatically relaunch those outputs.
21
+
22
+ The composition CSV contains observed and predicted cell fractions by test sample and six-type gate. The signal CSV has a donor-aware primary sensitivity: visits are averaged within donor and case/control condition after per-sample log2-CPM normalization, so each donor-condition contributes once. On the same covered scoring genes, observed and method profiles receive separate unweighted limma `lmFit`/`eBayes` fits, with `duplicateCorrelation` and donor blocking when donors appear in both conditions. It exports donor-equal logFC correlation, partial correlation given real bulk, and FDR-significant top-50 DEG overlap where estimable. BayesPrism Z and CIBERSORTx HiRes are continuous posterior or imputed expression, so this is labelled continuous-expression sensitivity, separate from the raw-integer-count edgeR/limma-voom primary in `donor_statistics.py`. The historical sample-level Welch family is retained with distinct metric names and `gene_variant` values. HiRes with at most eight mixture samples, missing output, or zero imputed genes is `not_estimable`, never zero. Missing limma infrastructure is `pending`; scientifically underpowered groups or genes are `not_estimable`. Method-only scores are not relabelled as a LoRA comparison.
23
+
24
+ `score/SUMMARY.json` has top-level `status`, `required_methods`, `methods`, `metrics`, and `pending_reasons`. A completed method has `methods.<name>.status=complete`; a missing required method or required HiRes output is `pending`. `metrics.<name>.corrected_deg.status` is `complete`, `not_estimable` for a scientific data limit, or `pending` for missing fit infrastructure. Any pending method or type fit makes the top-level status `pending`; the `score`/`all` CLI action returns nonzero and does not publish a Figure 4 manifest entry. If a previous completed entry exists, it moves to `inactive_units` with its evidence preserved so Figure 4 cannot mistake a pending rerun for completion. HiRes at most eight mixtures or a verified zero-imputed result is scientifically `not_estimable`.
25
+
26
+ Verification so far: thirteen focused CPU tests pass, covering all 20 strict support manifests, exact five-reference selection, exclusion of visits, rejection of extra or missing method mixtures and HiRes types, output isolation and hostile unit paths, receipt/input immutability and partial-output preservation, pending readiness precedence and stale Figure 4 invalidation, credential-free host argv and saved logs, equal donor-condition weighting with repeated visits, and tiny unpaired/paired limma fixtures. No BayesPrism or CIBERSORTx method was executed as part of this implementation.