junidude14 commited on
Commit
d2dc8f7
·
verified ·
1 Parent(s): d261650

Archive 4 checkpoints (1-4)

Browse files
.gitattributes CHANGED
@@ -233,3 +233,5 @@ paper-releases/pbisc-diffusion/updates/20261012T233237Z-figure-layout-todo/diffu
233
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/EXPERIMENT_REUSE_INDEX.jsonl filter=lfs diff=lfs merge=lfs -text
234
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pdf filter=lfs diff=lfs merge=lfs -text
235
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pptx filter=lfs diff=lfs merge=lfs -text
 
 
 
233
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/EXPERIMENT_REUSE_INDEX.jsonl filter=lfs diff=lfs merge=lfs -text
234
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pdf filter=lfs diff=lfs merge=lfs -text
235
  paper-releases/pbisc-diffusion/updates/20261013T005008Z-reuse-audit-results-deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pptx filter=lfs diff=lfs merge=lfs -text
236
+ paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pdf filter=lfs diff=lfs merge=lfs -text
237
+ paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pptx filter=lfs diff=lfs merge=lfs -text
paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e22d2e9bb2f37b6f8d43ef758c276860365a526dbdce08c1cdf255095884c97
3
+ size 4605309
paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_results_review_20261013.pptx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a17d5ebfd73dcfea2f70f85d7f3529ffa8b4330b03968c59e9ee737f687f1690
3
+ size 5239302
paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 2026-10-13 style correction
2
+
3
+ The current 34-slide results review uses the original 76-slide renderer (`generate_deck.py`) and shared Arial figure style (`tools/style.py`). Original overview, bulk-conditioning and corpus assets are restored intact. Six saved-table panels were restyled without new experiments or changes to estimates.
4
+
5
+ - [Current PDF](PBISC-Diffusion_results_review_20261013.pdf) · [Current PPTX](PBISC-Diffusion_results_review_20261013.pptx)
6
+ - [Figure 1 preview](data/style_review_20261013/slide_03.png) · [Verification](data/style_review_20261013/VERIFICATION.json)
7
+ - [Style correction record](data/style_review_20261013/REPORT.md)
8
+
9
+ # PBISC-Diffusion results decks
10
+
11
+ **Current available-results review (2026-10-13):**
12
+ [PDF](PBISC-Diffusion_results_review_20261013.pdf) ·
13
+ [editable PPTX](PBISC-Diffusion_results_review_20261013.pptx).
14
+ This 34-slide review reuses completed evidence in the approved Figure 1–5
15
+ sequence. It keeps historical five-fold, exact-five healthy draws and
16
+ multi-visit five-donor disease designs explicit. Corrected rare-state tables
17
+ and saved healthy composition scores are redrawn on CPU; no new training or
18
+ generation is introduced. Figure 6 awaits the user-prepared dataset.
19
+
20
+ Sources and per-slide protocol labels:
21
+ `data/results_review_20261013_provenance.json` and
22
+ `data/results_review_20261013_slide_map.csv`.
23
+ Builder: `tools/build_results_review_20261013.py`.
24
+ The incomplete 8-page TODO layout and older strict-campaign review working
25
+ copies are superseded; their immutable archive records are preserved.
26
+
27
+ The original 76-slide deck below remains the prior source/reference deck.
28
+
29
+ ## Original 2026-09-30 r00 deck and historical change log
30
+
31
+ 76-slide English deck, ordered by the six main figures of the Nature-style manuscript plan (user request 2026-10-06,
32
+ following `paper-release-20260928/reference-papers/Nature Style Manuscript Writing.pdf`):
33
+ - Title and outline: 6 figures, Supplementary, Appendix, Discussion.
34
+ - "Manuscript plan: six main figures": a table of each figure's claim and how many panels are ready.
35
+ - For each figure:
36
+ - a divider;
37
+ - a plan slide, a table of panel / content / evidence slide / status (Ready, Adapt, Draft, Build, Run, Plan);
38
+ - the existing slides that serve its panels, each labelled "Fig. 2c" etc. in the top-right corner.
39
+ - Supplementary: a plan slide plus the from-scratch results. Appendix: the modified scSemiProfiler run. Discussion: the
40
+ other-tissues outlook.
41
+
42
+ User decisions of 2026-10-06:
43
+ - No PBISC-VAE: scSemiProfiler, a VAE-based method, is the comparison (Fig. 3).
44
+ - Fig. 2 shows LoRA first on the healthy cohort (ImMicro) with the realism metrics (precision, coverage, classifier
45
+ AUROC, MMD, E_N); the disease-cohort comparison comes later.
46
+ - CYBERSORTx and other bulk deconvolution methods go to the Supplementary only (PBISC generates single cells).
47
+ - Figs 4 and 6 stay unplanned. Their existing slides are kept in the section as "Fig. 4 candidate" / "Fig. 6 candidate".
48
+
49
+ Only order, section labels, the agenda and new plan or draft slides changed. The new slides are "Overview draft (Nature
50
+ style)", the manuscript's candidate Fig. 1, and "Pretraining corpus", the Fig. 1d strip. No new result figures were
51
+ made.
52
+ - The plan lives in `data/figure_plan.json`.
53
+ - `tools/figure_plan.py` draws the plan tables and the slide text, and checks that every slide is placed exactly once.
54
+ - `tools/restructure_figure_order_20261006.py` rebuilds the order from the plan. It is rerun after every plan change and
55
+ keeps all slide fields.
56
+ - The earlier section order (10 sections, 45 slides) is in `_archive/2026-10-06_before_figure_order/`.
57
+
58
+ Short keyword lines only; the figures carry the results. Every slide that uses a published method, metric or
59
+ baseline has a one-line "References:" footer; full citations are in the speaker notes.
60
+
61
+ - `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
62
+ - `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
63
+ - `data/slides_spec.json`: slide order, titles, keywords, footnotes, references, speaker-note text
64
+ - `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
65
+ - `figures/`: exactly the figures the slides show (PNG + PDF), made by `tools/sec*.py`. Intermediate panels go to a
66
+ temporary folder; superseded figures are deleted, not kept (2026-10-02, user request; every deleted file was
67
+ checked to be in the paper archive by sha256 first).
68
+ - `data/sec*.csv` and `data/*_slide_text.json`: every plotted or quoted number with its source path
69
+ - `render/`: PDF and 70-dpi slide JPGs for checking
70
+
71
+ ## Slide order
72
+
73
+ | section | slides |
74
+ |---|---|
75
+ | 1 Model overview | bulk in, cells out; denoiser |
76
+ | 2 Backbone | SDD → PBISC-Diffusion; bulk conditioning |
77
+ | 3 Architecture ablation | width & context (loss, benchmark); gene panel |
78
+ | 4 Metrics + SLE benchmark | **how we score generated cells** (metric table with references); SLE benchmark; per cell type; bulk broadcast baseline |
79
+ | 5 Real bulk vs pseudobulk | input shift; same shift in three cohorts; cells off-manifold; disease direction flips |
80
+ | 6 Paired fine-tuning | method; evaluation design |
81
+ | 7 LoRA ablations | full vs LoRA vs cond.-encoder-only; LoRA rank r = 4 / 16 / 64; K diversification |
82
+ | 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) |
83
+ | 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 |
84
+ | 10 Next steps | paired-subset cohorts (planned); other tissues from a few dozen pairs (Discussion framing of the from-scratch results) |
85
+ | 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 |
86
+ | Appendix | scSemiProfiler without its output threshold (sensitivity; modified read-out, not the official output) |
87
+
88
+ ## Rebuild
89
+
90
+ Everything is CPU only; no GPU or checkpoint is touched.
91
+
92
+ ```bash
93
+ # prerequisites (plan folder plans/paired_finetune_intradataset_20260927/, CPU):
94
+ # scsemi/tools/representative_dependence.py -> scsemi/analysis/representative_dependence_20261002/
95
+ # tools/contrast_extra.py (+ tools/contrast_extra_tables.py) -> scores_contrast/ (Spearman, ceiling, limma, CAT, RBO)
96
+ # tools/build_tpm_zeroshot.py + tools/score_tpm_zeroshot.sh -> scores/<ds>/zeroshot_tpm_20261002/pooled/
97
+ # (the length-corrected zero-shot arm needs one GPU sampling step: tools/sample_lockwait.sh, coordinator only)
98
+ cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
99
+ # shared helpers, not run directly: style.py, sec03_common.py, scsemi_results.py, fold_sizes.py
100
+ for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
101
+ sec04_metrics_overview sec04_sle_benchmark sec05_condition_space sec05_cells_offmanifold \
102
+ sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
103
+ sec07_k_aug sec07_rank_sweep sec08_pairs_needed sec08_cross_cohort sec09_paired_validation sec09_extra_metrics \
104
+ sec09_time_to_apply sec09_scsemi_representative sec09_cat_curves sec10_paired_subset_cohorts \
105
+ secA_scsemi_readout sec07_no_pretraining sec08_cross_scratch sec09_same_pairs \
106
+ 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)
107
+ python3 "tools/$f.py" || break
108
+ done
109
+ python3 tools/restructure_figure_order_20261006.py # order the slides by data/figure_plan.json
110
+ python3 tools/sync_sec09_text.py # copy every generated slide text (sec09_index / text_source) into the spec
111
+ python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
112
+ soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
113
+ pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
114
+ cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
115
+ ```
116
+
117
+ `generate_deck.py` stops with an error if a figure is missing, a title does not fit on one line, a footnote needs
118
+ more than 2 lines (1 line when the slide has references), the reference line needs more than 1 line, or any text
119
+ contains Korean or placeholder words. `tools/restructure_20261002.py` is the one-off script that produced the current
120
+ slide order and the references (it refuses to run twice).
121
+
122
+ ## Notes
123
+
124
+ - **No "all" label (2026-10-02).** The 5-fold arm trains each fold model on the other four folds minus 7–8
125
+ inner-validation donors; its test fold is never trained on (RUN.json `test_rows_never_loaded_for_training`). Figures
126
+ label it "5-fold CV (other 4 folds)" and learning-curve ticks show the training-pair count per fold (78–79 ImMicro,
127
+ 58–59 sepsis), read by `tools/fold_sizes.py`.
128
+ - **Learning curve x = 0 uses no pairs (2026-10-02).** It shows the zero-shot model fed the real bulk as measured
129
+ and after exon-length correction (counts / Ensembl union-exon kb, then the same fixed-depth arithmetic;
130
+ `plans/.../tools/build_tpm_zeroshot.py`, scored in `scores/<ds>/zeroshot_tpm_20261002/pooled`). The old x = 0
131
+ calibration point, whose alpha used every training pair of the fold, is gone; calibration appears only fitted on the
132
+ same n pairs as the LoRA point (squares; `cal_budget_20261001`).
133
+ - **Disease metrics (2026-10-02).** Next to Pearson logFC r and the Welch top-50 DEG overlap: Spearman r, the
134
+ split-half ceiling (observed vs observed, Spearman–Brown), limma-voom top-50 DEG, each arm's chance overlap, and
135
+ CAT curves with the k / 2G chance line (`plans/.../scores_contrast/`, tools/contrast_extra.py; every Pearson r and
136
+ Welch count reproduced exactly). Repeated samples of one patient (Imperial, Giroux, Ji) count as separate samples in
137
+ both DE tests, as in the scorer (footnote).
138
+ - Section 9 text is generated: `tools/sec09_paired_validation.py`, `sec09_extra_metrics.py`, `sec07_rank_sweep.py`,
139
+ `sec09_time_to_apply.py`, `sec09_scsemi_representative.py`, `sec09_cat_curves.py` write slide text JSON; sync copies
140
+ it. Hand-written: the keywords of the two "Pairs needed" slides (section 8) and of every slide in sections 1–7 and 10.
141
+ - Giroux's disease metrics exclude 196 sex-linked genes (severity is confounded with sex), from
142
+ `plans/.../scores_nosex/`. The calibration comparator is "Zero-shot + calibration" (user decision 2026-10-01).
143
+ - Story rule (user decision 2026-09-30): no PBISC-VAE and no reference calibration (refcal). The exon-length-corrected
144
+ input is used only as the no-pair x = 0 point of the learning curve (user decision 2026-10-02).
145
+ `tools/sec04_immicro.py` (refcal vs scSemiProfiler on ImMicro) is kept but is not part of the deck or the rebuild.
146
+ - scSemiProfiler 5-fold and equal-budget results are picked up automatically when they appear (`tools/scsemi_results.py`;
147
+ arm `scsemi__raw` in `scores/<cohort>/scsemi_cv_20261002/pooled*/`, `scsemi_n{5,10,20,40}__raw` in
148
+ `scores/<cohort>/scsemi_budget_20261002/pooled*/`; same donors and reference cells as the main pooled call only).
149
+ Then rerun sections 8 and 9, sync, recheck the section 8 keywords and rebuild.
150
+ - Earlier versions: `_archive/2026-09-30_before_no_vae_refcal/`, `_archive/2026-10-01_before_extra_metrics/`,
151
+ `_archive/2026-10-02_before_time_to_apply/`, `_archive/2026-10-02_before_restructure/` (pptx, PDF, spec; their
152
+ figures are in the paper archive). `DRAFT_1150_*`: the copy shown at the 2026-09-30 12:00 meeting.
153
+
154
+ - Added 2026-10-03 (user decision: the cross-cohort experiment is reported at K = 1000 only and is the figure that explains
155
+ why PBISC fits LoRA on a few pairs of each cohort): slides 25-26 in section 8, `tools/sec08_cross_cohort.py`.
156
+ - Slide 25 "Pairs from other cohorts do not transfer": per held-out cohort, composition L1 / coverage / disease logFC r of
157
+ zero-shot, calibration fitted on the other cohorts, LoRA r16 / r64 / full fine-tune trained on the other cohorts
158
+ (+ Liu 2021) at step saturation, and LoRA on the cohort's own pairs (5-fold pooled).
159
+ - Slide 26 "Longer training on other cohorts" (": gap stays" since 2026-10-06): the same metrics at every 20k-step
160
+ milestone.
161
+ - Source plan: `plans/paired_crosscohort_20261002/` (README; same-reference and same-sample checks in the script).
162
+ Agenda item 8 now reads "How many pairs, and do other cohorts' pairs transfer". The deck has 37 slides.
163
+ Pre-update copy: `_archive/2026-10-03_before_cross_cohort/`.
164
+
165
+ ## Sources
166
+
167
+ Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
168
+ `plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
169
+ `plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
170
+ `analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each `data/sec*.csv`. Reference PDFs:
171
+ `/home/sj_server_1/PBISC/paper-release-20260928/reference-papers/` (INDEX.md). Manuscript:
172
+ `/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
173
+ - 2026-10-04 appendix (user decision: supplementary, appendix only, because it changes scSemiProfiler's official
174
+ output). Slide 38 is the divider "Appendix" and slide 39 is "Appendix: scSemiProfiler without output threshold"
175
+ (`tools/secA_scsemi_readout.py`, `data/secA_scsemi_readout{.csv,_slide_text.json}`).
176
+ - Inputs: `plans/paired_finetune_intradataset_20260927/scsemi/analysis/output_variants_20261003/`. The script checks
177
+ that its LoRA-5 and official scSemiProfiler values equal the section 9 slide data draw by draw.
178
+ - Result: without upstream's output threshold, scSemiProfiler's coverage rises in 5/5 cohorts, and 23/23 LoRA-5
179
+ comparisons (coverage, precision, composition, logFC r, DEG) keep their winner.
180
+ - The outline keeps its 10 sections (the builder requires 10). The pre-change copy is in
181
+ `_archive/2026-10-04_before_appendix/`. The deck has 39 slides.
182
+ - 2026-10-05 update (user request: put the results so far into the deck). Pre-change copy: `_archive/2026-10-05_before_scratch_cv/`.
183
+ - New slide 23, "No pretraining: same cohort, from scratch" (`tools/sec07_no_pretraining.py`). Pilot on sepsis fold 0
184
+ (17 donors). Reads `fold0_scratch_20261005/` and the runs' RUN.json. The donor composition r is recomputed from
185
+ per_donor.csv and reproduces ablation_extra_donor.csv.
186
+ - New slide 28, "No pretraining: other cohorts, from scratch" (`tools/sec08_cross_scratch.py`). Held-out sepsis pilot.
187
+ Every arm is read from `paired_crosscohort_20261002/scores_masked/`: genes no training cohort measured are zeroed
188
+ in all arms, because the unmasked scratch arm puts 91–94 % of its UMI there (read from the generated_masked logs
189
+ since 2026-10-06).
190
+ - New slide 38, "Same training pairs: LoRA vs scSemiProfiler" (`tools/sec09_same_pairs.py`). scSemiProfiler 5-fold
191
+ CV with LoRA's own training pairs, plus GPU hours per fold from the receipts on either host. Cohorts that are still
192
+ running show "in progress"; rerun the script as they finish.
193
+ - These two slides now draw the scSemiProfiler CV / budget runs automatically:
194
+ - Slide 24, "Pairs needed" (diamonds; ImMicro so far): keyword 2 reworded, footnote extended.
195
+ - Slide 37, "5-fold CV" (yellow bar; ImMicro and Ji so far).
196
+ - `tools/sec09_paired_validation.py` reads the scSemiProfiler CV arm's Spearman / limma values from
197
+ `scores_contrast/<cohort>/scsemi_cv_20261002/pooled/` (contrast_extra.py --design scored). Pearson r and the Welch
198
+ DEG must match the scorer; the values stay blank until computed. Cohorts not yet run say "in progress".
199
+ - Agenda item 7 now reads "LoRA: compute, rank, K; training from scratch". The deck has 42 slides.
200
+ - New helper: `tools/grouped_bars.py`.
201
+ - 2026-10-06 update (user request: check that the cross-cohort LoRA / full FT, cross-cohort from-scratch and
202
+ same-cohort from-scratch (+ recipes) results, with benchmarks and training times, and the scratch-vs-pretrained rare
203
+ states are in the deck; user decision: the from-scratch results go to the paper's Supplementary and the Discussion
204
+ presents them as a route to other tissues). Pre-change copy: `_archive/2026-10-06_before_supplementary/`.
205
+ - **Supplementary block (new divider, slides 40-43).**
206
+ - "No pretraining: same cohort, from scratch" and "No pretraining: other cohorts, from scratch" moved here from
207
+ sections 7 and 8. Their content is unchanged; slide 42's notes now name the cross-cohort slides by title.
208
+ - New "Rare states: from scratch vs pretrained" (`tools/secS_scratch_rare_states.py`).
209
+ - It reads the rare-state screen (`plans/rare_states_screen_20261004/out/sepsis_fold0_*` and
210
+ `sepsis_loco_masked_*`).
211
+ - The cross-cohort arms use the masked scoring (46 never-measured genes zeroed in every arm).
212
+ - The donor bootstrap reproduces the verified analysis in `out/scratch_vs_lora_20261005/REPORT.md`.
213
+ - **Section 10 "Next steps".**
214
+ - New "Next: other tissues from a few dozen pairs" (`tools/sec10_other_tissues.py`): a comparison table, pretrained
215
+ + LoRA vs from scratch.
216
+ - Every value is read from the deck's own source tables. The say text is the user's Discussion framing.
217
+ - **Slide 26 "Longer training on other cohorts".** The first keyword is now training minutes to saturation (RUN.json
218
+ wall seconds), with per-cohort minutes and steps in the notes (`tools/sec08_cross_cohort.py`).
219
+ - **Slide 34 "5 donors: time to apply".**
220
+ - The pretraining hours are read from `data/sec06_ft_method.csv`, no longer hard-coded.
221
+ - The note names the 'Fine-tuning with paired bulk + sc' slide by title. Its old "slide 15" pointed at the wrong
222
+ slide.
223
+ - Agenda items 7 and 10 updated. Spec change: `tools/restructure_20261006.py` (refuses to run twice). The deck has 45
224
+ slides; no Korean text.
225
+ - **Review pass (same day).** An independent 5-agent review of the changed slides confirmed 39 issues; all are
226
+ fixed. Pre-review copies of the touched scripts and the spec: `_archive/2026-10-06_before_supplementary/*.pre_review`.
227
+ - Slide 39: pretraining now reads 33.1 M train cells (`train_split_cells`; the 41.4 M corpus includes val/test).
228
+ The rare-state row follows the bootstrap verdicts on both sides (closer on ISG-high T / on DN2 B; labels and
229
+ states both arms miss by > 4-fold are not counted). "No corpus" became "come close": the scratch runs still took
230
+ the panel, value scaler and z-score constants from the PBMC checkpoint (RUN.json `kept_from_checkpoint`, now in
231
+ the notes). The say text carries the one-fold pilot qualifier; the footnote names both pilots.
232
+ - Slide 43: "no significant difference on average" (not "no difference"). Keyword 2 is the cycling T/NK count
233
+ (8 of 8 comparisons). The notes add the ISG-high T split by panel, the scratch-closer states (DN2 B, MS1), the
234
+ 52-call tally, the fold-0 caveat (fold 0 is the own-pair LoRA's best fold for C1Q-high and cycling T/NK,
235
+ computed from `folds.csv`), label states unthinned, and "8 of 13 states shown".
236
+ - Slide 26: title "...: gap stays" and "drifts in Sepsis and Ji" are computed from the milestones (gap = no milestone
237
+ reaches the own-cohort coverage; drift = full fine-tune L1 up by >= 0.05). Minutes are in
238
+ `data/sec08_cross_cohort.csv` (wall_seconds, minutes, run_receipt) and in the numbers list.
239
+ - Slide 42: UMI share (94 %, 91–94 % across milestones), the observed share (0.014 %, from `cells_panel6k.npz`)
240
+ and both arms' stopping settings are read from the receipts; the "none" label sits inside the axes.
241
+ - 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
242
+ notes. The right panel shares the bars' rows and has a title.
243
+ - Talk text and pointers: slides 23, 25, 26, 45 (say), 22 (recipes description), 32 and 36 (slide pointers by
244
+ title), slide 1 subtitle "updated 2026-10-06".
245
+ - 2026-10-08 update (user request: put the BayesPrism, CIBERSORTx and scSemiProfiler 5-fold results into the deck).
246
+ Pre-change copy: `_archive/2026-10-08_before_deconvolution/`.
247
+ - **Two new Supplementary slides** (`tools/secS_deconvolution.py`, `data/secS_deconvolution{.csv,_slide_text.json}`):
248
+ "Deconvolution with the same pairs: composition" and "...: disease signal".
249
+ - Source: `plans/bayesprism_paired_20261006/` (README, `results/RESULTS_full.md`, `RESULTS_cibersortx.md`).
250
+ - BayesPrism (recommended genes) and official CIBERSORTx (Fractions S-mode + HiRes) use the same paired donors
251
+ as the reference and the test samples' real bulk as the mixture, with the benchmark's own truth and scorer.
252
+ - Keywords and notes are computed from the tables.
253
+ - **Supplementary plan.** The planned "Bulk deconvolution methods" row is replaced by the two Ready slides.
254
+ `tools/figure_plan.py` now takes an optional per-slide note (`supplementary.notes`) and drops "Planned:" when
255
+ nothing is planned.
256
+ - **New scSemiProfiler results picked up (server_1):**
257
+ - Sepsis and Giroux 5-fold CV. Giroux was finalized on server_1 from sha-checked copies of its fold NPZs, and
258
+ rescored without sex-linked genes in `scores_nosex/giroux2022/scsemi_cv_20261002/pooled`.
259
+ - Sepsis equal-budget n = 5/10/20/40.
260
+ - Imperial 5-fold: finished on server_2 at 13:45 and was finalized on server_1 from sha-checked fold copies.
261
+ scSemiProfiler 5-fold now covers all five cohorts.
262
+ - Spearman/limma extras for sepsis, Giroux and Imperial; realism extras for all five cohorts.
263
+ - **Text changes from the new results:**
264
+ - "Same training pairs": keywords are data-driven. LoRA leads on coverage and precision in 5/5 cohorts;
265
+ composition 4/5 and logFC r 3/4, where scSemiProfiler leads in Giroux. The GPU-time ratio is 19–62×.
266
+ - sec09_same_pairs.py now reads the sepsis fold-0 pilot queue tag (`sep_f0`). For Giroux it quotes DEG from
267
+ scores_nosex, and for older pooled LoRA calls from pooled_deg.
268
+ - "5-fold CV" keyword: logFC r 3/4.
269
+ - "Pairs needed" (hand-written): scSemiProfiler coverage 0.04 / 0.10. On sepsis disease logFC r,
270
+ 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.
271
+ - 2026-10-08, new figure split (user decision; supersedes the 2026-10-06 split; pre-change copy
272
+ `_archive/2026-10-08_before_new_figure_plan/`).
273
+ - Fig. 2: LoRA fine-tuning with no disease metrics.
274
+ - Fig. 3: PBISC vs scSemiProfiler on healthy donors, with time as a main result.
275
+ - Fig. 4: disease benchmarks on the paired cohorts (PBISC versions, scSemiProfiler, and BayesPrism / CIBERSORTx
276
+ labelled as cell-type deconvolution; the deconvolution slides moved here from the Supplementary).
277
+ - Fig. 5: rare-cell fractions and detection.
278
+ - Fig. 6: new findings from the bulk-only sepsis and COVID samples (K = 1,000 and 4,000).
279
+ - The cross-cohort transfer slides moved to the Supplementary; their placement is open.
280
+ - New slide "Time: days for scSemiProfiler, minutes for LoRA" (`tools/fig3_time_days.py`, Fig. 3d).
281
+ - Inputs: GPU hours per 5-fold experiment from the receipts (`data/sec09_same_pairs.csv`, checked against
282
+ the scSemiProfiler event logs on both hosts), the 5-donor draws (`data/sec09_time_to_apply.csv`) and the
283
+ one-time pretraining (`data/sec06_ft_method.csv`).
284
+ - Results: ImMicro 24 h vs 1.2 h, sepsis 38 h vs 37 min. All runs: scSemiProfiler 184 h (7.7 days) vs PBISC
285
+ 22 h including pretraining.
286
+ - The equal-budget scSemiProfiler runs are excluded: they reuse the 5-fold run's representative models.
287
+ - Panel status: Build / Run marks new slides or analyses still to do; Adapt marks slides to re-scope (healthy-only
288
+ Fig. 2-3, disease columns into Fig. 4).
289
+ - 2026-10-08, comparison rules (user decision; memory feedback_paper_comparison_rules):
290
+ - **Time.** Only per-cohort GPU work counts: no PBISC pretraining, no GPU queue waits. The time slide now shows the
291
+ 5-donor draws (main) next to the 5-fold runs (separate). All runs: 7.7 GPU-days vs 5.7 h.
292
+ - **No bulk-broadcast baseline.** It is removed from the SLE benchmark, CAT, deconvolution and "Pairs needed"
293
+ figures.
294
+ - The "Bulk broadcast baseline" slide is gone. Its partial r panel is now on the SLE benchmark slide
295
+ (0.21 vs 0.17).
296
+ - Still to rebuild in their own phases: Fig. 2e (ImMicro only) and Fig. 6a.
297
+ - **Main comparison = 5 pairs** (LoRA-5 vs scSemiProfiler-5); 5-fold is reported separately. Partial r is
298
+ emphasised (bold panel titles).
299
+ - **New `tools/fig4_disease.py`**, which checks all 200 logFC r / DEG values against the section-9 tables:
300
+ - "Disease signal with 5 pairs: LoRA-5 vs others" (4b);
301
+ - "5-fold CV: disease signal" (4c);
302
+ - "Sepsis: fine-tuning variants" (details).
303
+ - The old "5 donors: LoRA vs scSemiProfiler — disease signal" slide is retired. `tools/sync_sec09_text.py` lists it
304
+ in RETIRED.
305
+ - The deconvolution slides are retitled "Cell-type deconvolution, same pairs: ...".
306
+ - 2026-10-08, healthy-only Figs 2-3 (`tools/fig23_healthy.py`).
307
+ - Eight ImMicro-only slides, re-plotted from the deck's own data tables; nothing is re-scored.
308
+ - Fig. 2 (no disease metrics):
309
+ - cells, realism, full / LoRA / condition encoder, pairs needed, rank and K;
310
+ - 5 donors (main) shown next to 5-fold (separate).
311
+ - Fig. 3 (vs scSemiProfiler):
312
+ - LoRA-5 vs scSemiProfiler-5 on 6 cell metrics: LoRA ahead on 6 of 6;
313
+ - the same pairs, 5 to all;
314
+ - scSemiProfiler copies its representative;
315
+ - time.
316
+ - The earlier all-cohort slides moved to the Supplementary (note "all five cohorts").
317
+ - "5-fold CV: train on the other 4 folds" is retired (it carried the broadcast; its content is now in Fig. 4c and
318
+ the healthy slides). It is listed in RETIRED of `tools/sync_sec09_text.py`.
319
+ - 2026-10-08, Fig. 5 rare cells (`tools/fig5_rare_states.py`).
320
+ - Source: new plan `plans/rare_states_paired_20261008` (README). It covers 4 paired disease cohorts, the 5-donor
321
+ draws and 5-fold, and the arms zero-shot, calibration, scSemiProfiler and LoRA. Each NPZ is sha-checked and the
322
+ benchmark's Poisson read-out and labels are reproduced cell by cell.
323
+ - Three slides:
324
+ - fraction (5a);
325
+ - donors and disease direction (5b);
326
+ - 5-fold, separate (5c).
327
+ - Results over 56 state × cohort pairs, 5 donors:
328
+ - LoRA-5 closer to the observed fraction than scSemiProfiler-5 in 51/56;
329
+ - within 2-fold: 19 vs 5;
330
+ - better donor ranking: 43/56;
331
+ - disease direction kept: 73% vs 61%.
332
+ - Fig. 6a no longer mentions the broadcast. No slide text mentions it now.
333
+ - 2026-10-10, last broadcast mention removed from a figure (found while rewriting the manuscript from this deck).
334
+ - Fig. 2d "How we score generated cells" (`tools/sec04_metrics_overview.py`) still listed "broadcast; split-half
335
+ ceiling" as the comparator of logFC r inside the table image. It now reads "zero-shot; partial r (vs bulk)".
336
+ - Old tool, CSV and figure: `_archive/2026-10-10_metrics_overview_broadcast/`. The deck was rebuilt (76 slides); a
337
+ text search of every slide, the notes and the PDF twin of every figure a slide uses finds no "broadcast". Three
338
+ figure files of retired slides still contain it and are not used: `sec04_sle_broadcast`, `sec09_fewpair_disease`,
339
+ `sec09_fivefold`.
340
+ - The manuscript was rewritten from this deck on 2026-10-10 (`paper-release-20260928/manuscript/`,
341
+ `editorial/rewrite_20261010.md`); its figures are copies of this folder's figure PDFs.
342
+ - 2026-10-10, LoRA rank figure key (`tools/sec07_rank_sweep.py`): "LoRA rank r = 16 (used in the deck)" now reads
343
+ "(used throughout)", because the same panel is Supplementary Fig. 12a of the manuscript. Old files:
344
+ `_archive/2026-10-10_rank_sweep_label/`. Deck rebuilt (76 slides).
paper-releases/pbisc-diffusion/updates/20261013T012029Z-restore-original-deck-style/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/build_results_review_20261013.py ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Build the reviewed 34-slide deck with the original 76-slide renderer/style.
2
+
3
+ CPU only. Existing figures are reused intact; new plots read small saved CSVs.
4
+ The original deck and its specification are never rewritten.
5
+ """
6
+ from pathlib import Path
7
+ from datetime import datetime, timezone, timedelta
8
+ import copy
9
+ import csv
10
+ import hashlib
11
+ import json
12
+ import os
13
+ import sys
14
+
15
+ if os.environ.get('CUDA_VISIBLE_DEVICES') != '':
16
+ raise SystemExit('Set CUDA_VISIBLE_DEVICES empty for this CPU-only builder')
17
+ D = Path(__file__).resolve().parents[1]
18
+ sys.path.insert(0, str(D))
19
+ import generate_deck as original
20
+ from pptx import Presentation
21
+ from pptx.util import Inches
22
+ from results_review_style_plots import build as build_plots
23
+ from results_review_style_panels import build as build_panels
24
+
25
+ DATA = D/'data'
26
+ ORIGINAL = json.loads((DATA/'slides_spec.json').read_text())['slides']
27
+ PREVIOUS = json.loads((DATA/'style_review_20261013/before_results_review_20261013_provenance.json').read_text())
28
+ STEM = D/'PBISC-Diffusion_results_review_20261013'
29
+ SOURCES = {}
30
+
31
+
32
+ def sha(path):
33
+ with Path(path).open('rb') as f:
34
+ return hashlib.file_digest(f,'sha256').hexdigest()
35
+
36
+
37
+ def source(path, role):
38
+ path=Path(path).resolve()
39
+ if not path.is_file():
40
+ raise FileNotFoundError(path)
41
+ SOURCES[str(path)]={'sha256':sha(path),'role':role}
42
+ return path
43
+
44
+
45
+ def relative(path):
46
+ return str(Path(path).resolve().relative_to(D))
47
+
48
+
49
+ def from_original(number, title, section, protocol, keywords=None):
50
+ item=copy.deepcopy(ORIGINAL[number-1])
51
+ assert item['kind']=='content'
52
+ item.update(title=title,section_label=section,footnote=protocol,original_slide=number)
53
+ item['footnote_full']=protocol+'\nOriginal context: '+item.get('footnote_full',item.get('footnote',''))
54
+ if keywords is not None:
55
+ item['keywords']=keywords
56
+ # The original reference line remains visible when it fits. Full citations
57
+ # always stay in notes, unchanged from the original source specification.
58
+ if item.get('refs') and len(original.wrap(protocol,original.FOOT_PT,original.FOOT_W))>1:
59
+ item.pop('refs')
60
+ return item
61
+
62
+
63
+ def fresh(title,section,protocol,asset,keywords=()):
64
+ return {'kind':'content','title':title,'section_label':section,'layout':'full',
65
+ 'figures':[relative(Path(asset).with_suffix('.png'))],
66
+ 'keywords':list(keywords),'footnote':protocol,'footnote_full':protocol,
67
+ 'sources':str(asset)}
68
+
69
+
70
+ def main():
71
+ plots=build_plots()
72
+ panels=build_panels()
73
+ for row in plots['inputs']:
74
+ source(row['path'],row.get('role','saved plot data'))
75
+ for path in plots['assets']:
76
+ source(path,'restyled saved-table plot')
77
+ for value in panels.values():
78
+ for key in ('png','pdf','svg','provenance'):
79
+ if value.get(key):
80
+ source(value[key],'restyled panel '+key)
81
+ proof=json.loads(Path(value['provenance']).read_text())
82
+ # Preserve the complete panel-specific evidence even if its schema differs.
83
+ for field in ('inputs','sources'):
84
+ rows=proof.get(field,[])
85
+ if isinstance(rows,dict): rows=[{'path':p} for p in rows]
86
+ for row in rows:
87
+ p=row.get('path',row.get('source')) if isinstance(row,dict) else row
88
+ if p: source(p,'saved panel data')
89
+ comp,rareobs,rarecompare=plots['figures']
90
+ slides=[
91
+ {'kind':'title','title':'PBISC-Diffusion','subtitle':'Results review · existing evidence and protocol updates · 13 October 2026'},
92
+ {'kind':'agenda','title':'Six figures: evidence available now','items':[
93
+ 'Fig. 1 Pretraining, diffusion and bulk conditioning',
94
+ 'Fig. 2 Model design and paired-data requirements',
95
+ 'Fig. 3 Healthy reconstruction: quality, composition and time',
96
+ 'Fig. 4 Disease signals and deconvolution benchmarks',
97
+ 'Fig. 5 Rare cell states: corrected analysis of existing outputs',
98
+ 'Fig. 6 Bulk-only reproduction: awaiting the new dataset']},
99
+ ]
100
+ slides += [
101
+ from_original(7,'PBISC-Diffusion: pretraining to generated cells','Fig. 1a',
102
+ 'Schematic. Conditioning recipe size and the number of generated cells are distinct; no cell-type quotas.',
103
+ []),
104
+ from_original(8,'Bulk conditioning','Fig. 1b',
105
+ 'Final 6k model. Recipe size K conditions the bulk; the number of generated cells is chosen separately.',
106
+ ['One shared bulk condition; independent cell draws', 'Expression, depth and measured-gene masks', 'No cell-type or disease labels as model input']),
107
+ from_original(9,'Pretraining corpus','Fig. 1c',
108
+ 'Corpus labels describe the data; they are not model inputs. Dataset composition is not sampler exposure.'),
109
+ fresh('Native-pseudobulk model comparisons','Fig. 2a',
110
+ 'Completed held-out rescoring. Architecture: 1% detection floor; gene-panel comparison: 0.1% floor.',panels['ablation']['pdf']),
111
+ from_original(12,'Gene panels: performance and coverage','Fig. 2b',
112
+ 'Existing panel benchmark. 6k: five sampling seeds; other panels: one seed. Different axis from the architecture sweep.'),
113
+ fresh('Healthy bulk: full fine-tuning and LoRA rank','Fig. 2c',
114
+ 'Original donor-level five-fold comparison. LoRA rank 16 is a quality/parameter compromise.',panels['rank']['pdf']),
115
+ ]
116
+ # Preserve the audited scope of every retained result. Figure assets and
117
+ # takeaways are reused from the original 76-slide deck, without cropping.
118
+ mapping=[
119
+ (31,'Historical paired-data learning curve','Fig. 2d'),
120
+ (26,'Additional pairs improve donor-level information','Fig. 2e'),
121
+ (17,'Measured bulk differs from pseudobulk','Fig. 3a'),
122
+ (30,'Healthy donors: exactly five paired samples','Fig. 3b'),
123
+ ]
124
+ for position,(old,title,label) in enumerate(mapping,start=8):
125
+ assert PREVIOUS['slides'][position]['old_deck_slide']==old
126
+ p=PREVIOUS['slides'][position]['protocol']
127
+ if old==31:
128
+ p='LoRA: n training + 7 validation. scSemi: n + 7 representatives, with CV-HVG reuse. Not the strict total-n protocol.'
129
+ slides.append(from_original(old,title,label,p))
130
+ slides.append(fresh('Healthy cell-type composition','Fig. 3c',
131
+ 'Exactly five pairs per draw. Each donor is averaged over its held-out draws; descriptive comparison, no new p-values.',comp))
132
+ mapping=[
133
+ (32,'Representative-dependent composition','Fig. 3d'),
134
+ (34,'Adaptation and generation time','Fig. 3e'),
135
+ (37,'Paired cohorts and evaluation units','Fig. 4a'),
136
+ (38,'Disease signals: five-donor draws','Fig. 4b'),
137
+ (39,'Disease signals: five-fold validation','Fig. 4c'),
138
+ (40,'Disease-gene agreement across list lengths','Fig. 4d'),
139
+ (41,'Cell-type expression: deconvolution comparison','Fig. 4e'),
140
+ (46,'Composition: deconvolution comparison','Fig. 4f'),
141
+ ]
142
+ for position,(old,title,label) in enumerate(mapping,start=13):
143
+ assert PREVIOUS['slides'][position]['old_deck_slide']==old
144
+ p=PREVIOUS['slides'][position]['protocol']
145
+ kws=None
146
+ if old==32:
147
+ kws=['Composition varies with the selected representative',
148
+ 'Compare generated fractions with held-out observed fractions']
149
+ elif old==37:
150
+ kws=['403 paired samples, 275 donors',
151
+ 'Identity screening where available; donor-level splits',
152
+ 'Ji bulk: whole blood, not PBMC']
153
+ elif old==46:
154
+ kws=['PBISC closer than BayesPrism in 22/25 draws, than CIBERSORTx in 24/25',
155
+ 'Composition compared with held-out observed cells',
156
+ 'Five-fold: PBISC lowest error in 4 of 5 cohorts']
157
+ slides.append(from_original(old,title,label,p,kws))
158
+ slides += [
159
+ fresh('Rare-state frequencies in observed cells','Fig. 5a',
160
+ 'Original five-donor outputs. Median across draws; state share within its parent population. Controls included.',rareobs),
161
+ fresh('Rare-state fidelity: zero-aware reanalysis','Fig. 5b',
162
+ 'Original five-donor outputs; zero draws retained and actual donor IDs. 59 state/cohort combinations, including controls.',rarecompare),
163
+ fresh('Behcet: one-gene and multi-gene C1Q rules','Fig. 5c',
164
+ 'Descriptive: unmatched reference includes training donors. Same three pairs; two identity-pass and one uncertain.',panels['behcet']['pdf']),
165
+ {'kind':'status','title':'Remaining work','section_label':'Figure status',
166
+ 'rows':[
167
+ ['Protocol updates','Total n = 5/10/20/40 without extra validation; exact-five samples in multi-visit cohorts.'],
168
+ ['Analysis of existing outputs','Patient-aware contrasts, rare-state scoring and healthy cell visualizations.'],
169
+ ['Figure 6: new data','Reproduce a published finding in the user-prepared bulk-only cohort.']],
170
+ 'footnote':'Existing results remain visible. Protocol updates and missing-data work are identified separately.'},
171
+ ]
172
+ mapping=[
173
+ (19,'Control-cell embedding diagnostic'),
174
+ (58,'Generated-cell quality across cohorts'),
175
+ (60,'Precision and coverage across neighbourhood sizes'),
176
+ (62,'Same training pairs: five-fold comparison'),
177
+ (68,'Cross-cohort pairs do not replace local pairs'),
178
+ (69,'Longer cross-cohort training leaves a gap'),
179
+ (70,'From-scratch control: evidence and limits'),
180
+ (74,'scSemiProfiler readout sensitivity'),
181
+ (42,'SLE pseudobulk development benchmark'),
182
+ ]
183
+ for position,(old,title) in enumerate(mapping,start=25):
184
+ assert PREVIOUS['slides'][position]['old_deck_slide']==old
185
+ p=PREVIOUS['slides'][position]['protocol']
186
+ slides.append(from_original(old,title,'Supporting',p))
187
+ assert len(slides)==34
188
+ prs=Presentation();prs.slide_width=Inches(original.SLIDE_W);prs.slide_height=Inches(original.SLIDE_H)
189
+ for i,s in enumerate(slides,start=1):
190
+ kind=s['kind']
191
+ if kind=='title': original.build_title(prs,s)
192
+ elif kind=='agenda': original.build_agenda(prs,s,i)
193
+ elif kind=='status':
194
+ slide=prs.slides.add_slide(prs.slide_layouts[6]);original.white_bg(slide)
195
+ original.add_title(slide,s['title'],s['section_label'])
196
+ for row,(title,body) in enumerate(s['rows']):
197
+ y=1.35+row*1.55
198
+ original.add_text(slide,original.X0,y,11.6,.4,[title],20,bold=True)
199
+ original.add_text(slide,original.X0,y+.5,11.6,.8,[body],16,color=original.GREY)
200
+ original.add_footer(slide,s['footnote'],i)
201
+ else:
202
+ original.build_content(prs,s,i)
203
+ for f in s.get('figures',[]):
204
+ source(D/f,'figure reused intact' if s.get('original_slide') else 'restyled figure')
205
+ vector=(D/f).with_suffix('.pdf')
206
+ if vector.is_file(): source(vector,'figure vector companion')
207
+ for sh in prs.slides[-1].shapes:
208
+ assert sh.left>=0 and sh.top>=0 and sh.left+sh.width<=prs.slide_width+2 and sh.top+sh.height<=prs.slide_height+2,(i,sh.name)
209
+ prs.save(STEM.with_suffix('.pptx'))
210
+ for p in [D/'generate_deck.py',D/'tools/style.py',DATA/'slides_spec.json',
211
+ Path(__file__),D/'tools/results_review_style_plots.py',D/'tools/results_review_style_panels.py',
212
+ DATA/'style_review_20261013/before_results_review_20261013_provenance.json']:
213
+ source(p,'renderer, style or audited content source')
214
+ spec={'deck':{'output_pptx':STEM.name+'.pptx','style_source':'generate_deck.py + tools/style.py'},'slides':slides}
215
+ (DATA/'results_review_20261013_spec.json').write_text(json.dumps(spec,indent=2)+'\n')
216
+ manifest={'schema':'pbisc.results-review.reuse.v2','style_revision':2,
217
+ 'as_of_kst':datetime.now(timezone(timedelta(hours=9))).isoformat(),
218
+ 'slides':slides,'sources':SOURCES,'new_training':False,'new_generation':False,
219
+ 'cpu_work':'Style-only redraw of saved CSVs; original diagrams and charts reused intact.',
220
+ 'plot_calculations':plots.get('calculations'), 'panel_outputs':panels,
221
+ 'pptx_sha256':sha(STEM.with_suffix('.pptx')),'pdf_status':'awaiting PPTX export and visual verification'}
222
+ (DATA/'results_review_20261013_provenance.json').write_text(json.dumps(manifest,indent=2)+'\n')
223
+ with (DATA/'results_review_20261013_slide_map.csv').open('w') as f:
224
+ w=csv.DictWriter(f,fieldnames=['slide','section','title','protocol','old_deck_slide']);w.writeheader()
225
+ for i,s in enumerate(slides,1):w.writerow({'slide':i,'section':s.get('section_label',''),
226
+ 'title':s['title'],'protocol':s.get('footnote',''),'old_deck_slide':s.get('original_slide','')})
227
+ print(json.dumps({'slides':len(slides),'sources':len(SOURCES),'pptx':str(STEM.with_suffix('.pptx'))}))
228
+
229
+
230
+ if __name__=='__main__':main()