junidude14 commited on
Commit
3adba59
·
verified ·
1 Parent(s): 697a357

Archive 4 checkpoints (1-4)

Browse files
.gitattributes CHANGED
@@ -245,3 +245,5 @@ paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-maste
245
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013.pptx filter=lfs diff=lfs merge=lfs -text
246
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/figures/expanded_master_20261013/healthy/gene_length_input.pdf filter=lfs diff=lfs merge=lfs -text
247
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/figures/expanded_master_20261013/healthy/stored_real_reference_umap.pdf filter=lfs diff=lfs merge=lfs -text
 
 
 
245
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013.pptx filter=lfs diff=lfs merge=lfs -text
246
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/figures/expanded_master_20261013/healthy/gene_length_input.pdf filter=lfs diff=lfs merge=lfs -text
247
  paper-releases/pbisc-diffusion/updates/20261013T034842Z-expanded-131-slide-master/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/figures/expanded_master_20261013/healthy/stored_real_reference_umap.pdf filter=lfs diff=lfs merge=lfs -text
248
+ paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013_reordered.pptx filter=lfs diff=lfs merge=lfs -text
249
+ paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013_reordered.pdf filter=lfs diff=lfs merge=lfs -text
paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013_reordered.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbe168a8c9446432c51abf206ec7711b53e2bf823692401602d69845e3268513
3
+ size 16044504
paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_expanded_master_20261013_reordered.pptx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45a48b93e220db22ee5c74cc2e3358b59d2309c57d65203e63d59e443d05fedf
3
+ size 17989220
paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/reorder_master_figures_20261013.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Apply the author's Figure 1-6 scope to the actual 131-slide PPTX.
2
+
3
+ Consumes the already verified gold/blue master. Does not run its old builder,
4
+ experiments, scoring, recolouring, or manuscript updates. Original assets stay
5
+ unchanged; the obsolete guide at source page 5 becomes a healthy-only FT view.
6
+ """
7
+ from pathlib import Path
8
+ from datetime import datetime, timezone
9
+ import copy
10
+ import csv
11
+ import hashlib
12
+ import json
13
+ import os
14
+ import subprocess
15
+ import sys
16
+
17
+ if os.environ.get('CUDA_VISIBLE_DEVICES') != '':
18
+ raise SystemExit('CPU-only: set CUDA_VISIBLE_DEVICES empty')
19
+ D = Path(__file__).resolve().parents[1]
20
+ A = D / 'data/figure_order_fixed_20261013'
21
+ SOURCE = D / 'data/expanded_master_20261013/spec.json'
22
+ OUT = 'PBISC-Diffusion_expanded_master_20261013_reordered'
23
+ sys.path.insert(0, str(D))
24
+ import generate_deck as G
25
+ from pptx import Presentation
26
+ from pptx.util import Inches, Pt
27
+ from pptx.dml.color import RGBColor
28
+
29
+
30
+ def sha(path):
31
+ with Path(path).open('rb') as stream:
32
+ return hashlib.file_digest(stream, 'sha256').hexdigest()
33
+
34
+
35
+ GROUPS = [
36
+ ('Introduction', [1, 2, 3, 4]),
37
+ ('Figure 1', [6, 7, 9, 11, 16]),
38
+ ('Figure 2', [19, 20, 13, 14, 15]),
39
+ ('Figure 3', [52, 53, 21, 23, 5, 51, 49, 54, 55]),
40
+ ('Figure 4', [60, 61, 63, 67, 68, 71]),
41
+ ('Figure 5', [86, 87]),
42
+ ('Figure 6', [102, 103, 107]),
43
+ ('Supplementary', [108, 109]),
44
+ ('Supp S01', [8, 10, 17, 38, 39, 41]),
45
+ ('Supp S02', [12, 18, 72, 73, 74, 75]),
46
+ ('Supp S03', [22, *range(24, 38)]),
47
+ ('Supp S04', [40, 42, 43, 46, 47]),
48
+ ('Supp S05', [44, 45, 48, 57, 116]),
49
+ ('Supp S06', [50, 56, 58, 59, 117, 118, 119]),
50
+ ('Supp S07', [62, 64, 65, 66, 110, 111, 112, 113, 114, 115]),
51
+ ('Supp S08', [69, 70, 82, 83, 84, 85, 120, 121, 122]),
52
+ ('Supp S09', [76, 77, 78, 79, 80, 81]),
53
+ ('Supp S10', [89, 91, 92, 93, 95, 96]),
54
+ ('Supp S11', [97, 98, 99, 100, 101]),
55
+ ('Supp S12', [123, 124, 125, 126, 127]),
56
+ ('Supp S13', [129]),
57
+ ('Supp S14', [106]),
58
+ ('Historical archive', [128, 88, 90, 94, 104, 105]),
59
+ ('Discussion', [130, 131]),
60
+ ]
61
+ ORDER = [p for _, pages in GROUPS for p in pages]
62
+ assert len(ORDER) == 131 and sorted(ORDER) == list(range(1, 132))
63
+ PAGE = {old: new for new, old in enumerate(ORDER, 1)}
64
+ BOUNDS = {name: [PAGE[p] for p in pages] for name, pages in GROUPS}
65
+
66
+
67
+ def pages(*old):
68
+ return ', '.join(str(PAGE[p]) for p in old)
69
+
70
+
71
+ def card(s, title, label, rows, footnote):
72
+ s['superseded_figures'] = s.pop('figures', [])
73
+ for key in ('keywords', 'layout', 'text_source', 'refs', 'refs_full', 'numbers', 'say', 'figures_before_palette'):
74
+ s.pop(key, None)
75
+ s.update(kind='plan_card', title=title, section_label=label, rows=rows,
76
+ footnote=footnote,
77
+ footnote_full=footnote + '\nAuthor-defined Figure scope, 13 October 2026. Supersedes the former planning card.',
78
+ sources='data/figure_assignment_20261013/AUTHOR_SCOPE.md; data/figure_order_fixed_20261013/page_map.csv')
79
+
80
+
81
+ def plans(slides):
82
+ by = {s['source_page_131']: s for s in slides}
83
+ card(by[4], 'Manuscript map: the six figures', 'Current scope', [
84
+ ('Figure 1', 'Experimental overview and corpus statistics', 'Concept and corpus'),
85
+ ('Figure 2', 'Architecture and gene-context ablations', 'SLE pseudobulk'),
86
+ ('Figure 3', 'Mismatch > full FT > rank > paired-data budget', 'Healthy measured pairs'),
87
+ ('Figure 4', 'Disease logFC, DEG and CAT benchmarks', 'Disease measured pairs'),
88
+ ('Figure 5', 'Rare-population identity in paired samples', 'Qualitative assembly'),
89
+ ('Figure 6', 'Reproduce a published finding from bulk-only samples', 'Planned')],
90
+ 'One continuous Figure 3 story includes healthy adaptation and the five-pair comparison.')
91
+ card(by[7], 'Figure 1: overview and corpus', 'Figure 1 plan', [
92
+ ('1a', 'Pretraining > paired adaptation > bulk-to-cell inference', 'p. ' + pages(9)),
93
+ ('1b', 'Corpus size, assays, conditions and cell types', 'p. ' + pages(11)),
94
+ ('1c', 'Corpus scale and pseudobulk recipe size', 'p. ' + pages(16)),
95
+ ('Details', 'Backbone, conditioner and denoiser implementation', 'Supplement S01')],
96
+ 'Architecture and gene-context performance ablations belong to Figure 2.')
97
+ card(by[20], 'Figure 2: SLE model ablations', 'Figure 2 plan', [
98
+ ('2a', 'Architecture width and conditioning context', 'p. ' + pages(13)),
99
+ ('2b', 'Gene context: 2k, 3k, 6k and 15k', 'p. ' + pages(14)),
100
+ ('2c', 'Common-axis precision, coverage and composition', 'p. ' + pages(15)),
101
+ ('Controls', 'SLE conditioning, cell types and bulk-broadcast controls', 'Supplement S02')],
102
+ 'SLE pseudobulk only. Architecture and gene-panel families retain their separate detection floors.')
103
+ card(by[53], 'Figure 3: the paired-adaptation story', 'Figure 3 plan', [
104
+ ('3a', 'Real-bulk / pseudobulk mismatch and its consequence', 'pp. ' + pages(21, 23)),
105
+ ('3b', 'Raw / calibrated / full FT / LoRA: one healthy cohort', 'p. ' + pages(5)),
106
+ ('3c', 'Full FT versus LoRA r4 / r16 / r64', 'p. ' + pages(51)),
107
+ ('3d', 'Training-pair budget: historical n + 7 validation', 'p. ' + pages(49)),
108
+ ('3e-f', 'Genuine five-pair performance and donor-level errors', 'pp. ' + pages(54, 55))],
109
+ 'All performance panels use healthy measured bulk-sc pairs. Rank 16 is a quality-parameter compromise.')
110
+ card(by[61], 'Figure 4: disease signal preservation', 'Figure 4 plan', [
111
+ ('4a', 'Disease signal with five training donors', 'p. ' + pages(63)),
112
+ ('4b', 'Five-fold held-out disease comparisons', 'p. ' + pages(67)),
113
+ ('4c', 'Agreement across disease-gene list lengths', 'p. ' + pages(68)),
114
+ ('4d', 'Cell-type expression comparison with deconvolution', 'p. ' + pages(71)),
115
+ ('Scope', 'Sepsis, Imperial, Giroux and Ji; SLE is in Figure 2', 'Measured paired data')],
116
+ 'Keep cohort-specific exceptions visible. Cohort inventory, partial corrected DEG and quality controls are in Supplementary.')
117
+ card(by[87], 'Figure 5: paired rare-population identity', 'Figure 5 plan', [
118
+ ('5a', 'Matched observed / PBISC / scSemi population views', 'Assemble saved cells'),
119
+ ('5b', 'Marker expression and per-cell co-detection', 'Assemble saved cells'),
120
+ ('5c', 'Examples across held-out disease/control donors', 'Observed-based selection'),
121
+ ('Available', 'Paired rare-state frequencies, misses and direction', 'Supplement S10'),
122
+ ('Separate', 'Pseudobulk screens and unmatched Behcet references', 'Supplement S11')],
123
+ 'Existing quantitative rare-state plots support case selection; they are not completed qualitative identity panels.')
124
+ card(by[103], 'Figure 6: published-finding reproduction', 'Figure 6 plan', [
125
+ ('6a', 'Define paired adaptation and bulk-only target samples', 'Planned'),
126
+ ('6b', 'Fix one published finding and its exact comparison', 'Planned'),
127
+ ('6c', 'Report the adapted-model bulk-only reproduction', 'Result pending'),
128
+ ('6d', 'Independent support and raw-bulk comparison', 'Result pending')],
129
+ 'Reproduction of an existing finding is the objective. Historical exploratory searches are retained in the archive section.')
130
+ supp_rows = [
131
+ ('S01-S02', 'Methods, corpus loss and SLE controls', 'pp. ' + str(BOUNDS['Supp S01'][0]) + '-' + str(BOUNDS['Supp S02'][-1])),
132
+ ('S03-S06', 'Input diagnostics, evaluation, healthy quality and budgets', 'pp. ' + str(BOUNDS['Supp S03'][0]) + '-' + str(BOUNDS['Supp S06'][-1])),
133
+ ('S07-S09', 'Cohorts, disease quality, corrected DEG and external diagnostics', 'pp. ' + str(BOUNDS['Supp S07'][0]) + '-' + str(BOUNDS['Supp S09'][-1])),
134
+ ('S10-S11', 'Paired rare-state quantities and separate external screens', 'pp. ' + str(BOUNDS['Supp S10'][0]) + '-' + str(BOUNDS['Supp S11'][-1])),
135
+ ('S12-S14', 'Transfer, scratch, readout and bulk-only cohort shift', 'pp. ' + str(BOUNDS['Supp S12'][0]) + '-' + str(BOUNDS['Supp S14'][-1])),
136
+ ('Archive', 'Superseded rare scoring and historical bulk-only plans', 'pp. ' + str(BOUNDS['Historical archive'][0]) + '-' + str(BOUNDS['Historical archive'][-1]))]
137
+ card(by[109], 'Supplementary evidence map', 'Supplementary', supp_rows,
138
+ 'All source evidence remains available. Supplement numbers describe groups, not final manuscript figure counts.')
139
+
140
+
141
+ def make_spec():
142
+ original = json.loads(SOURCE.read_text())['slides']
143
+ slides = []
144
+ for group, numbers in GROUPS:
145
+ for old in numbers:
146
+ s = copy.deepcopy(original[old - 1])
147
+ s.update(source_page_131=old, deck_group=group, section=group)
148
+ s['previous_section_label'] = s.get('section_label')
149
+ s['section_label'] = group.replace('Supp ', 'Supp. ')
150
+ slides.append(s)
151
+ by = {s['source_page_131']: s for s in slides}
152
+ by[1].update(title='PBISC-Diffusion: manuscript evidence',
153
+ subtitle='131 slides | Author-defined Figures 1-6 | 13 October 2026')
154
+ by[2].update(title='Figures 1-6: the corrected order', items=[
155
+ 'Figure 1 Experimental overview and corpus',
156
+ 'Figure 2 SLE pseudobulk: architecture and gene context',
157
+ 'Figure 3 Real-bulk mismatch and healthy paired adaptation',
158
+ 'Figure 4 Disease integrity on measured paired cohorts',
159
+ 'Figure 5 Paired rare-population qualitative evidence',
160
+ 'Figure 6 Published-finding reproduction from bulk-only data',
161
+ 'Supplementary evidence and controls',
162
+ 'Historical scoring / plans and discussion'])
163
+ by[3].update(title='How this corrected deck is organized', rows=[
164
+ ('Figures 1 and 2', 'Overview and corpus are followed by SLE pseudobulk architecture and gene-context ablations.'),
165
+ ('One Figure 3 narrative', 'Mismatch, full fine-tuning, LoRA rank and paired-data efficiency now form a single healthy paired-data section.'),
166
+ ('Complete evidence coverage', 'All 131 source pages are accounted for. Superseded planning cards are rewritten; scientific figures retain their original values.')],
167
+ footnote='The prior 131-slide master is preserved. A source-to-current page map accompanies this reordered deck.')
168
+ by[3]['footnote_full'] = by[3]['footnote']
169
+ for old, title in {
170
+ 6: 'Figure 1. Overview and corpus',
171
+ 19: 'Figure 2. SLE model ablations',
172
+ 52: 'Figure 3. Real-bulk adaptation',
173
+ 60: 'Figure 4. Disease signal preservation',
174
+ 86: 'Figure 5. Rare-population identity',
175
+ 102: 'Figure 6. Published-finding reproduction',
176
+ 108: 'Supplementary evidence',
177
+ 128: 'Historical scoring and plans',
178
+ 130: 'Discussion and outlook',
179
+ }.items():
180
+ by[old]['title'] = title
181
+ by[5].update(kind='content', title='Healthy paired data: full FT and LoRA',
182
+ section_label='Fig. 3b', figures=['figures/figure_order_fixed_20261013/healthy_ft_comparison.png'],
183
+ layout='full', keywords=[],
184
+ footnote='ImMicro measured bulk-sc pairs; pooled five-fold results. All four methods use the same saved scoring table.',
185
+ footnote_full='Healthy-only extraction: dataset=immicro, call=pooled; raw, calibrated, full FT and LoRA r16. No disease or fold0 condition-encoder pilot rows. No new statistics.',
186
+ sources='data/sec07_ft_modes_accuracy.csv; data/figure_order_fixed_20261013/healthy_ft_comparison.json')
187
+ by[5].pop('rows', None)
188
+ by[9]['title'] = 'Experimental overview'
189
+ by[16]['title'] = 'Corpus scale and generation workflow'
190
+ labels = {9:'Fig. 1a',11:'Fig. 1b',16:'Fig. 1c',13:'Fig. 2a',14:'Fig. 2b',15:'Fig. 2c',
191
+ 21:'Fig. 3a',23:'Fig. 3a detail',51:'Fig. 3c',49:'Fig. 3d',54:'Fig. 3e',55:'Fig. 3f',
192
+ 63:'Fig. 4a',67:'Fig. 4b',68:'Fig. 4c',71:'Fig. 4d'}
193
+ for old, label in labels.items():
194
+ by[old]['section_label'] = label
195
+ by[51]['title'] = 'Full FT and LoRA ranks: quality and parameters'
196
+ by[49]['title'] = 'Healthy paired-data budget: n training + 7 validation'
197
+ by[54]['title'] = 'Five pairs, no extra validation: LoRA vs scSemi'
198
+ by[107].update(title='Figure 6: what the reproduction must establish', section_label='Figure 6', rows=[
199
+ ('Adaptation and target samples', 'Record paired supports, bulk-only targets and donor/visit overlap.'),
200
+ ('Published endpoint', 'Fix the paper finding, cell population, severity/time definition and evaluation before a new analysis.'),
201
+ ('Result and evidence', 'Show the reproduction result and comparison with the bulk signal; distinguish retrospective replay from independent confirmation.')],
202
+ footnote='Result pending. Historical candidate searches neither prove nor disprove a prespecified published-finding reproduction.')
203
+ by[107]['footnote_full'] = by[107]['footnote']
204
+ for old in (88, 90, 94):
205
+ by[old]['section_label'] = 'Historical only'
206
+ by[old]['footnote'] = 'Historical scorer; excluded from current main conclusions. Zero-draw and sample-unit limitations apply.'
207
+ for old in (98, 100, 101):
208
+ by[old]['section_label'] = 'Supp. S11'
209
+ plans(slides)
210
+ assert sorted(s['original_slide'] for s in slides if 'original_slide' in s) == list(range(1, 77))
211
+ return {'deck':{'output_pptx':OUT+'.pptx','output_pdf':OUT+'.pdf'}, 'slides':slides}
212
+
213
+
214
+ def draw_note(prs, s, number):
215
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
216
+ G.white_bg(slide)
217
+ G.add_title(slide, s['title'], s.get('section_label'))
218
+ step = 4.9 / len(s['rows'])
219
+ for i, (head, body) in enumerate(s['rows']):
220
+ y = 1.25 + i * step
221
+ G.add_text(slide, G.X0, y, 11.8, .4, [head], 18, bold=True)
222
+ assert len(G.wrap(body, 16, 11.8)) <= 3
223
+ G.add_text(slide, G.X0, y+.46, 11.8, step-.5, [body], 16, color=G.GREY)
224
+ G.add_footer(slide, s.get('footnote'), number)
225
+ G.add_notes(slide, s)
226
+
227
+
228
+ def draw_card(prs, s, number):
229
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
230
+ G.white_bg(slide)
231
+ G.add_title(slide, s['title'], s.get('section_label'))
232
+ rows = s['rows']
233
+ top, step = 1.2, min(.88, 5.25 / (len(rows)+1))
234
+ widths = [1.42, 7.67, 3.36]
235
+ table = slide.shapes.add_table(len(rows)+1, 3, Inches(G.X0), Inches(top),
236
+ Inches(sum(widths)), Inches(step*(len(rows)+1))).table
237
+ for j, width in enumerate(widths):
238
+ table.columns[j].width = Inches(width)
239
+ for i, values in enumerate([('Panel', 'Content', 'Evidence / location'), *rows]):
240
+ table.rows[i].height = Inches(step)
241
+ for j, value in enumerate(values):
242
+ cell = table.cell(i, j)
243
+ cell.text = value
244
+ cell.margin_left = cell.margin_right = Inches(.13)
245
+ cell.margin_top = Inches(.11)
246
+ cell.margin_bottom = Inches(.06)
247
+ cell.fill.solid()
248
+ cell.fill.fore_color.rgb = RGBColor.from_string('F2F2F2' if i == 0 else 'FFFFFF')
249
+ for p in cell.text_frame.paragraphs:
250
+ p.space_after = Pt(0)
251
+ p.line_spacing = 1.0
252
+ for run in p.runs:
253
+ run.font.name = 'Arial'
254
+ run.font.size = Pt(16 if j == 1 else 14)
255
+ run.font.bold = i == 0 or j == 0
256
+ run.font.color.rgb = G.INK if j != 2 else G.GREY
257
+ G.add_footer(slide, s.get('footnote'), number)
258
+ G.add_notes(slide, s)
259
+
260
+
261
+ def main():
262
+ A.mkdir(parents=True, exist_ok=True)
263
+ spec = make_spec()
264
+ slides = spec['slides']
265
+ inputs = {str(p):{'sha256':sha(p)} for p in [SOURCE, Path(__file__), D/'generate_deck.py',
266
+ D/'data/figure_assignment_20261013/AUTHOR_SCOPE.md',
267
+ D/'data/sec07_ft_modes_accuracy.csv',
268
+ D/'data/figure_order_fixed_20261013/healthy_ft_comparison.json']}
269
+ old = json.loads(SOURCE.read_text())['slides']
270
+ protected = [D/'PBISC-Diffusion_expanded_master_20261013.pptx',
271
+ D/'PBISC-Diffusion_expanded_master_20261013.pdf',
272
+ D/'PBISC-Diffusion_paper_summary_20260930.pptx',
273
+ D/'PBISC-Diffusion_paper_summary_20260930.pdf']
274
+ protected += sorted({D/f for s in old for f in s.get('figures', [])})
275
+ protected_hashes = {str(p):sha(p) for p in protected}
276
+ prs = Presentation()
277
+ prs.slide_width, prs.slide_height = Inches(G.SLIDE_W), Inches(G.SLIDE_H)
278
+ renderers = {'title':G.build_title, 'agenda':G.build_agenda, 'divider':G.build_divider,
279
+ 'content':G.build_content, 'evidence_note':draw_note, 'plan_card':draw_card}
280
+ for number, s in enumerate(slides, 1):
281
+ func = renderers[s['kind']]
282
+ func(prs, s) if s['kind'] == 'title' else func(prs, s, number)
283
+ for f in s.get('figures', []):
284
+ inputs[str(D/f)] = {'sha256':sha(D/f)}
285
+ prs.save(D/(OUT+'.pptx'))
286
+ (A/'spec.json').write_text(json.dumps(spec, indent=2)+'\n')
287
+ mapping = [{'current_page':i,'previous_131_page':s['source_page_131'],
288
+ 'original_76_page':s.get('original_slide',''),'group':s['deck_group'],
289
+ 'panel':s.get('section_label',''),'title':s['title']} for i,s in enumerate(slides,1)]
290
+ for name, rows in [('page_map.csv', mapping), ('original_76_coverage.csv', [r for r in mapping if r['original_76_page']])]:
291
+ with (A/name).open('w', encoding='utf-8-sig', newline='') as f:
292
+ writer = csv.DictWriter(f, fieldnames=list(rows[0]))
293
+ writer.writeheader()
294
+ writer.writerows(rows)
295
+ manifest = {'schema':'pbisc.author-figure-order.v1','generated_at':datetime.now(timezone.utc).isoformat(),
296
+ 'source_spec':str(SOURCE),'source_spec_sha256':sha(SOURCE),'slides':slides,
297
+ 'groups':BOUNDS,'sources':inputs,'protected_source_hashes':protected_hashes,
298
+ 'source_pages':131,'original_76_ids_preserved':True,'superseded_admin_cards_rewritten':True,
299
+ 'new_training':False,'new_generation':False,'new_scoring':False,
300
+ 'new_plot':'Healthy-only extraction of existing pooled full-FT metrics; no refitting.',
301
+ 'output':{'pptx':{'path':str(D/(OUT+'.pptx')),'sha256':sha(D/(OUT+'.pptx'))}}}
302
+ (A/'manifest.json').write_text(json.dumps(manifest, indent=2)+'\n')
303
+ print(json.dumps({'slides':len(slides),'groups':BOUNDS,'pptx':str(D/(OUT+'.pptx'))}))
304
+
305
+
306
+ if __name__ == '__main__':
307
+ main()
paper-releases/pbisc-diffusion/updates/20261013T060507Z-author-figure-order-131deck/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/verify_figure_order_20261013.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Check actual slide order, preserved evidence and rendered layout."""
2
+ from pathlib import Path
3
+ from collections import Counter
4
+ from datetime import datetime, timezone
5
+ import hashlib
6
+ import json
7
+ import sys
8
+ import fitz
9
+ from pptx import Presentation
10
+
11
+ D = Path(__file__).resolve().parents[1]
12
+ A = D / 'data/figure_order_fixed_20261013'
13
+ Q = A / 'qa'
14
+ sys.path.insert(0, str(D/'tools'))
15
+ import verify_expanded_master_20261013 as helper
16
+ helper.QA = Q
17
+
18
+
19
+ def sha(path):
20
+ with Path(path).open('rb') as stream:
21
+ return hashlib.file_digest(stream, 'sha256').hexdigest()
22
+
23
+
24
+ def main():
25
+ Q.mkdir(parents=True, exist_ok=True)
26
+ spec = json.loads((A/'spec.json').read_text())
27
+ manifest = json.loads((A/'manifest.json').read_text())
28
+ records = spec['slides']
29
+ source = json.loads(Path(manifest['source_spec']).read_text())['slides']
30
+ pptx_path, pdf_path = D/spec['deck']['output_pptx'], D/spec['deck']['output_pdf']
31
+ prs, pdf = Presentation(pptx_path), fitz.open(pdf_path)
32
+ failures = []
33
+ counts = {'spec':len(records),'pptx':len(prs.slides),'pdf':len(pdf)}
34
+ if set(counts.values()) != {131}: failures.append(['counts',counts])
35
+ if sorted(r['source_page_131'] for r in records) != list(range(1,132)):
36
+ failures.append(['source_page_bijection'])
37
+ if sorted(r['original_slide'] for r in records if 'original_slide' in r) != list(range(1,77)):
38
+ failures.append(['original76_coverage'])
39
+ expected = {'Figure 1':[6,7,9,11,16], 'Figure 2':[19,20,13,14,15],
40
+ 'Figure 3':[52,53,21,23,5,51,49,54,55], 'Figure 4':[60,61,63,67,68,71]}
41
+ for group, old_pages in expected.items():
42
+ actual = [r['source_page_131'] for r in records if r['deck_group']==group]
43
+ if actual != old_pages: failures.append(['author_scope',group,actual])
44
+ rewritten = {4,7,20,53,61,87,103,109}
45
+ preserved_evidence = []
46
+ for i, r in enumerate(records,1):
47
+ old = r['source_page_131']
48
+ if old not in rewritten and old != 5:
49
+ same = r.get('figures',[]) == source[old-1].get('figures',[])
50
+ if not same: failures.append(['source_scientific_figures',i,old])
51
+ if r.get('figures'): preserved_evidence.append(old)
52
+ if any(Path(f).name.startswith('figplan_') for f in r.get('figures',[])):
53
+ failures.append(['obsolete_plan_image',i])
54
+ group = r['deck_group']
55
+ if group.startswith('Figure ') and r['kind']=='content':
56
+ if not r['section_label'].startswith('Fig. '+group[-1]):
57
+ failures.append(['section_label',i,r['section_label']])
58
+ protected = []
59
+ for path, expected_hash in manifest['protected_source_hashes'].items():
60
+ ok = Path(path).is_file() and sha(path)==expected_hash
61
+ protected.append({'path':path,'unchanged':ok,'sha256':expected_hash})
62
+ if not ok: failures.append(['protected_source_changed',path])
63
+ for path, binding in manifest['sources'].items():
64
+ if sha(path) != binding['sha256']: failures.append(['source_hash',path])
65
+ plot = json.loads((A/'healthy_ft_comparison.json').read_text())
66
+ if not (plot['dataset']=='immicro' and plot['call']=='pooled' and plot['n_donors']==107
67
+ and plot['validation']['csv_rows_exact_string_match']
68
+ and plot['validation']['max_abs_difference_from_source_summary']==0):
69
+ failures.append(['healthy_only_extraction'])
70
+ image_checks = []
71
+ fonts = set()
72
+ for i,(slide,record) in enumerate(zip(prs.slides,records),1):
73
+ image_checks.append(helper._image_proofs(slide,record,i,failures))
74
+ for shape in slide.shapes:
75
+ if shape.left < -2 or shape.top < -2 or shape.left+shape.width > prs.slide_width+2 or shape.top+shape.height > prs.slide_height+2:
76
+ failures.append(['pptx_shape_bounds',i,shape.name])
77
+ for tf in helper._text_frames(shape):
78
+ for paragraph in tf.paragraphs:
79
+ for run in paragraph.runs:
80
+ fonts.update(helper._font_names(run,paragraph))
81
+ if fonts != {'Arial'}: failures.append(['font_family',sorted(fonts)])
82
+ for i,page in enumerate(pdf,1):
83
+ blocks = page.get_text('dict')['blocks']
84
+ for block in blocks:
85
+ for line in block.get('lines',[]):
86
+ for span in line.get('spans',[]):
87
+ x0,y0,x1,y1=span['bbox']
88
+ if x0<-.75 or y0<-.75 or x1>page.rect.width+.75 or y1>page.rect.height+.75:
89
+ failures.append(['pdf_text_bounds',i,span['text'],span['bbox']])
90
+ rendered = helper._render(pdf, records)
91
+ old_titles = ['Figure 1. Design and performance of PBISC',
92
+ 'Figure 2. Fine-tuning PBISC with LoRA',
93
+ 'Figure 3. PBISC vs scSemiProfiler on healthy donors',
94
+ 'Figure 6. Discovery from public bulk-only data']
95
+ actual_text = '\n'.join(p.get_text() for p in pdf)
96
+ for old in old_titles:
97
+ if old in actual_text: failures.append(['obsolete_visible_title',old])
98
+ manifest['output']['pdf']={'path':str(pdf_path),'sha256':sha(pdf_path)}
99
+ (A/'manifest.json').write_text(json.dumps(manifest,indent=2)+'\n')
100
+ report={'schema':'pbisc.author-figure-order.qa.v1','checked_at':datetime.now(timezone.utc).isoformat(),
101
+ 'automated_checks_pass':not failures,'status':'automated_pass_visual_pending' if not failures else 'failed',
102
+ 'counts':counts,'failures':failures,'source_page_bijection':True,'original76_coverage':True,
103
+ 'groups':manifest['groups'],'protected_sources':protected,
104
+ 'unchanged_scientific_source_pages':preserved_evidence,'font_families':sorted(fonts),
105
+ 'image_checks':image_checks,'renders':rendered,
106
+ 'artifacts':{'pptx':{'path':str(pptx_path),'sha256':sha(pptx_path)},
107
+ 'pdf':{'path':str(pdf_path),'sha256':sha(pdf_path)}},
108
+ 'visual_review':{'status':'pending'}}
109
+ (Q/'VERIFICATION.json').write_text(json.dumps(report,indent=2)+'\n')
110
+ print(json.dumps({'pass':not failures,'counts':counts,'failures':failures,'contacts':len(rendered['contacts'])}))
111
+ if failures: raise SystemExit(1)
112
+
113
+
114
+ if __name__=='__main__':main()