junidude14 commited on
Commit
418fbe1
·
verified ·
1 Parent(s): 17a6017

Archive 4 checkpoints (1-4)

Browse files
.gitattributes CHANGED
@@ -71,3 +71,5 @@ paper-releases/pbisc-diffusion/updates/20261001T145641Z-lora-rank-sweep-calibrat
71
  paper-releases/pbisc-diffusion/updates/20261001T145641Z-lora-rank-sweep-calibration-budget/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx filter=lfs diff=lfs merge=lfs -text
72
  paper-releases/pbisc-diffusion/updates/20261002T002920Z-deck-extra-metrics-scsemi-prep/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pdf filter=lfs diff=lfs merge=lfs -text
73
  paper-releases/pbisc-diffusion/updates/20261002T002920Z-deck-extra-metrics-scsemi-prep/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx filter=lfs diff=lfs merge=lfs -text
 
 
 
71
  paper-releases/pbisc-diffusion/updates/20261001T145641Z-lora-rank-sweep-calibration-budget/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx filter=lfs diff=lfs merge=lfs -text
72
  paper-releases/pbisc-diffusion/updates/20261002T002920Z-deck-extra-metrics-scsemi-prep/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pdf filter=lfs diff=lfs merge=lfs -text
73
  paper-releases/pbisc-diffusion/updates/20261002T002920Z-deck-extra-metrics-scsemi-prep/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx filter=lfs diff=lfs merge=lfs -text
74
+ paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pdf filter=lfs diff=lfs merge=lfs -text
75
+ paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx filter=lfs diff=lfs merge=lfs -text
paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0016014c1001731abe40a49a025a6e12709ad457e885e3ac94851e55189a7929
3
+ size 5647990
paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe22865ddb3ac01d0c052f3dc121d2873d14f485542b37949d29fb4cd236a775
3
+ size 6353209
paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PBISC-Diffusion paper summary deck (2026-09-30, r00)
2
+
3
+ 34-slide English summary of the PBISC-Diffusion (Model 8) paper experiments: title,
4
+ outline, 10 sections (25 content slides), then a Backup divider and 7 backup slides.
5
+ Short keyword lines only; the figures carry the results. Section 10 is planned work.
6
+
7
+ - `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
8
+ - `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
9
+ - `data/slides_spec.json`: slide order, titles, keywords, footnotes, speaker-note text
10
+ - `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
11
+ - `figures/`: all slide figures (PNG + PDF), made by `tools/sec*.py`
12
+ - `data/sec*.csv`, `data/sec09_slide_text.json`, `data/sec09_extra_slide_text.json`,
13
+ `data/sec07_rank_sweep_slide_text.json`, `data/sec09_time_to_apply_slide_text.json`,
14
+ `data/sec09_scsemi_representative_slide_text.json`: every plotted or quoted number with its source path
15
+ - `render/`: PDF and 70-dpi slide JPGs for checking
16
+
17
+ ## Rebuild
18
+
19
+ Everything is CPU only; no GPU or checkpoint is touched.
20
+
21
+ ```bash
22
+ # prerequisite of tools/sec09_scsemi_representative.py (CPU; copies server_2 inputs once):
23
+ # python3 ../../plans/paired_finetune_intradataset_20260927/scsemi/tools/representative_dependence.py
24
+ cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
25
+ # figures + data tables (sec03_common.py, style.py and scsemi_results.py are shared helpers, not run directly)
26
+ for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
27
+ sec04_sle_benchmark sec05_condition_space sec05_cells_offmanifold \
28
+ sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
29
+ sec07_k_aug sec07_rank_sweep sec08_pairs_needed sec09_paired_validation sec09_extra_metrics \
30
+ sec09_time_to_apply sec09_scsemi_representative sec10_paired_subset_cohorts; do
31
+ python3 "tools/$f.py" || break
32
+ done
33
+ python3 tools/sync_sec09_text.py # copy generated slide text (sec09, sec09_extra, sec07_rank_sweep,
34
+ # sec09_time_to_apply, sec09_scsemi_representative) into the spec
35
+ python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
36
+ soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
37
+ pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
38
+ cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
39
+ ```
40
+
41
+ `generate_deck.py` stops with an error if a figure is missing, a title does not fit on one
42
+ line, a footnote needs more than 2 lines, or any text contains Korean or placeholder words.
43
+
44
+ ## Notes
45
+
46
+ - Section 9 (few-pair scSemiProfiler comparison) uses all 25 scSemiProfiler draws
47
+ (5 cohorts x 5 draws). If scores change, rerun `tools/sec09_paired_validation.py`, then
48
+ `tools/sync_sec09_text.py`, then check the short footnotes it lists and rebuild.
49
+ - Section 9 update (user decisions 2026-10-01): (1) the gene-wise calibration comparator is back,
50
+ named "Zero-shot + calibration" (few-pair `zs_cal`, alpha from the same 5 donors; 5-fold `zs__cal`)
51
+ and the sc-only control is "sc-only fine-tune (+ calibration)" (`pseudo_full__cal`); (2) Giroux's
52
+ disease metrics (logFC r, partial r, top-50 DEG, broadcast) exclude 196 sex-linked genes because its
53
+ severity is confounded with sex, read from `plans/paired_finetune_intradataset_20260927/scores_nosex/`
54
+ (see its README). Both are stated in the slide footnotes.
55
+ - On-slide footnotes are one short line; the full source and method text is in the speaker
56
+ notes (`footnote_full` in the spec).
57
+ - `DRAFT_1150_*`: frozen copy shown at the 2026-09-30 12:00 meeting (23/25 scSemiProfiler
58
+ draws, long footnotes). Superseded by the files above.
59
+ - Story rule (user decision 2026-09-30): the deck and paper do not mention PBISC-VAE, reference
60
+ calibration (refcal), the TPM input variant or any calibration arm (calibration arm reinstated
61
+ 2026-10-01 as "Zero-shot + calibration"; never "refcal"). The no-fine-tune baseline is
62
+ zero-shot on real bulk as measured; the sc-only control is the sc-only fine-tune fed raw bulk.
63
+ `tools/sec04_immicro.py` (refcal vs scSemiProfiler on ImMicro) is kept but no longer in the deck.
64
+ The pre-revision deck, scripts and figures are in `_archive/2026-09-30_before_no_vae_refcal/`.
65
+
66
+ - Added 2026-10-02 (from `plans/paired_finetune_intradataset_20260927/scores_extra/` and `scores/<cohort>/rankcal_20261001.*`):
67
+ slide 23 "5 donors: realism beyond precision/coverage" (classifier AUC, MMD², scSemiProfiler's E_N per cohort;
68
+ few-pair arms, mean ± SD over draws) and three backups: slide 30 LoRA rank r = 4 / 16 / 64 (ImMicro, sepsis),
69
+ slide 31 the same realism metrics for the 5-fold pooled design, slide 32 precision/coverage at k = 3 / 5 / 10
70
+ (few-pair; the 5-fold k ranking is in the speaker notes). Scripts: `tools/sec09_extra_metrics.py` (checks every
71
+ value against `scores_extra/{fewshot,pooled}_headline.csv`) and `tools/sec07_rank_sweep.py` (checks
72
+ `rankcal_20261001.json` against the scoring calls). Their slide text is generated (`text_source` in the spec) and
73
+ synced by `tools/sync_sec09_text.py`. Pre-update deck: `_archive/2026-10-01_before_extra_metrics/`.
74
+ - scSemiProfiler 5-fold and equal-budget results are picked up automatically when they appear
75
+ (`tools/scsemi_results.py`: arm `scsemi__raw` in `scores/<cohort>/scsemi_cv_20261002/pooled*/`, arms
76
+ `scsemi_n{5,10,20,40}__raw` in `scores/<cohort>/scsemi_budget_20261002/pooled*/`, extra metrics below
77
+ `scores_extra/<cohort>/scsemi_cv_20261002/`; a call is used only for the same donors and reference cells as the
78
+ main pooled call). When present: a "scSemiProfiler, all training pairs" bar on slide 24 (Giroux disease metrics only
79
+ after a `scores_nosex/giroux2022/scsemi_cv_20261002/` rescore, else "rescore pending"), a scSemiProfiler line across
80
+ n on slides 18–19 ("all" = the 5-fold run), and a scSemiProfiler row on slide 31. When absent, each script prints a
81
+ NOTE and the figures are unchanged. After they arrive: rerun the four scripts, sync, check the hand-written keywords
82
+ of slides 18–19 (not generated) and rebuild. The presence path was tested with synthetic arms in a scratch copy
83
+ (`DECK_SCSEMI_PLAN_ROOT`, `DECK_FIGDIR`, `DECK_OUTDATA` redirect the lookup and outputs).
84
+
85
+ - Added 2026-10-02, second update (pre-update deck: `_archive/2026-10-02_before_time_to_apply/`). Slide numbers
86
+ from 24 on moved by one: "All pairs, 5-fold" is now slide 25, the backups are 28-34 (LoRA rank 31, 5-fold realism
87
+ 32, k = 3 / 5 / 10 33). In the note above, read slide 24 -> 25 and slide 31 -> 32.
88
+ - Slide 24 "5 donors: time to apply" (`tools/sec09_time_to_apply.py`): GPU time per draw of LoRA-5 vs
89
+ scSemiProfiler-5 on the same 25 draws, read from receipts and queue logs on both hosts (LoRA RUN.json + sampling
90
+ job wall clock; scSemiProfiler model receipts + export `total_target_seconds`). The script stops if a draw lacks
91
+ a complete record. Data prep, scoring and PBISC's one-time pretraining are not counted (footnote).
92
+ - Backup slide 34 "scSemiProfiler copies its representative" (`tools/sec09_scsemi_representative.py`, from
93
+ `plans/paired_finetune_intradataset_20260927/scsemi/analysis/representative_dependence_20261002/`): composition
94
+ L1 of copying the assigned representative's observed composition vs scSemiProfiler-5 and LoRA-5, and their
95
+ Spearman with that copy error. The KMeans proxy for upstream's own representative choice (not a rerun) is in the
96
+ speaker notes only.
97
+
98
+ ## Sources
99
+
100
+ Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
101
+ `plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
102
+ `plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
103
+ `analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each
104
+ `data/sec*.csv`. Manuscript: `/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
paper-releases/pbisc-diffusion/updates/20261002T022002Z-deck-time-to-apply-scsemi-reps/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/sec09_scsemi_representative.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Backup slide for section 9 of the 2026-09-30 paper-summary deck: scSemiProfiler's composition follows its representative.
3
+
4
+ CPU only. Reads plans/paired_finetune_intradataset_20260927/scsemi/analysis/representative_dependence_20261002/
5
+ {per_target.csv, summary.csv, kmeans_proxy.csv} (made by scsemi/tools/representative_dependence.py; rerun that first)
6
+ and draws:
7
+ a composition L1 per cohort: copying the representative's observed composition, scSemiProfiler-5, LoRA-5
8
+ (bar = mean over 5 draws of the per-draw mean, whiskers = SD, dots = draws)
9
+ b Spearman, over test samples, of each method's L1 with the copy error
10
+ The KMeans proxy (upstream's own representative choice, not a rerun) goes to the speaker notes only.
11
+
12
+ Outputs (deck folder; DECK_FIGDIR / DECK_OUTDATA override the folders):
13
+ figures/sec09_scsemi_representative.{png,pdf}
14
+ data/sec09_scsemi_representative.csv every plotted value with its source
15
+ data/sec09_scsemi_representative_slide_text.json title, keywords, footnotes, quoted numbers (synced by
16
+ tools/sync_sec09_text.py through text_source)
17
+ """
18
+ from __future__ import annotations
19
+
20
+ import os
21
+
22
+ os.environ["CUDA_VISIBLE_DEVICES"] = "" # plotting only
23
+
24
+ import json
25
+ import sys
26
+ from pathlib import Path
27
+
28
+ import numpy as np
29
+ import pandas as pd
30
+
31
+ DECK = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/"
32
+ "2026-09-30--paper-summary--r00")
33
+ sys.path.insert(0, str(DECK / "tools"))
34
+ import sec09_paired_validation as S9 # noqa: E402 (shared section 9 names and colours; sets the deck rcParams)
35
+ import style # noqa: E402
36
+ import matplotlib.pyplot as plt # noqa: E402
37
+ from matplotlib.patches import Patch # noqa: E402
38
+
39
+ A = S9.T / "scsemi" / "analysis" / "representative_dependence_20261002"
40
+ FIGDIR = Path(os.environ.get("DECK_FIGDIR", str(DECK / "figures")))
41
+ OUTDATA = Path(os.environ.get("DECK_OUTDATA", str(DECK / "data")))
42
+ ORDER, NAME, ROWNAME = S9.ORDER, S9.NAME, S9.ROWNAME
43
+ FS, SUB, EDGE = S9.FS, S9.SUB, S9.EDGE
44
+ ARMS = [("copy", "copy_l1", style.ARM["broadcast"], "Copy the representative's composition"),
45
+ ("scsemi", "scsemi_l1", style.ARM["scsemi"], "scSemiProfiler, 5 donors"),
46
+ ("lora", "lora_l1", style.ARM["lora"], "LoRA, 5 donors")]
47
+
48
+
49
+ def main() -> int:
50
+ per = pd.read_csv(A / "per_target.csv")
51
+ summ = pd.read_csv(A / "summary.csv").set_index("cohort")
52
+ prox = pd.read_csv(A / "kmeans_proxy.csv").set_index("cohort")
53
+ by_draw = per.groupby(["cohort", "draw"])[[c for _, c, _, _ in ARMS]].mean()
54
+ # the plotted pooled means must equal the analysis summary
55
+ for ds in ORDER:
56
+ for _, c, _, _ in ARMS:
57
+ if not np.isclose(per[per.cohort == ds][c].mean(), summ.loc[ds, c]):
58
+ raise SystemExit(f"{ds} {c}: per_target and summary disagree")
59
+ fig, (ax, bx) = plt.subplots(1, 2, figsize=(12.3, 4.6), gridspec_kw={"width_ratios": [2.0, 1.0], "wspace": 0.12})
60
+ h, gap = 0.27, 0.4
61
+ yt, rows = [], []
62
+ for i, ds in enumerate(ORDER):
63
+ y0 = i * (3 * h + gap)
64
+ for k, (key, col, colour, lab) in enumerate(ARMS):
65
+ v = by_draw.loc[ds][col].to_numpy()
66
+ y = y0 + k * h
67
+ ax.barh(y, v.mean(), h * 0.88, color=colour, edgecolor="none")
68
+ ax.errorbar(v.mean(), y, xerr=v.std(ddof=1), fmt="none", ecolor=EDGE, elinewidth=1, capsize=2.5)
69
+ ax.scatter(v, np.full(v.size, y), s=12, facecolor="white", edgecolor=EDGE, linewidth=0.8, zorder=3)
70
+ rows += [dict(panel="a", cohort=ds, series=key, draw=j, value=float(x),
71
+ source=str(A / "per_target.csv")) for j, x in enumerate(v)]
72
+ yt.append(y0 + h)
73
+ p = summ.loc[ds, "scsemi_vs_copy_wilcoxon_p"]
74
+ diff = summ.loc[ds, "scsemi_minus_copy"]
75
+ verdict = "worse" if (p < 0.05 and diff > 0) else ("better" if (p < 0.05 and diff < 0) else "no difference")
76
+ ax.text(0.79, y0 + h, f"scSemi vs copy:\n{verdict}", va="center", ha="left", fontsize=FS - 3, color=SUB,
77
+ linespacing=1.1)
78
+ nt = per.groupby(["cohort", "draw"]).size().groupby(level=0).agg(["min", "max"])
79
+ ax.set_yticks(yt, [f"{ROWNAME[d]}\ntest {nt.loc[d, 'min']}" + (f"–{nt.loc[d, 'max']}" if nt.loc[d, 'max'] != nt.loc[d, 'min'] else "")
80
+ + " per draw" for d in ORDER], fontsize=FS - 2)
81
+ ax.invert_yaxis()
82
+ ax.set_xlim(0, 1.02)
83
+ ax.set_xticks([0, 0.2, 0.4, 0.6])
84
+ ax.set_xlabel("Composition L1 ↓")
85
+ ax.tick_params(axis="y", length=0)
86
+ for i, ds in enumerate(ORDER):
87
+ y0 = i * (3 * h + gap)
88
+ for k, (key, col) in enumerate((("scsemi", "rho_scsemi_copy"), ("lora", "rho_lora_copy"))):
89
+ v = summ.loc[ds, col]
90
+ colour = style.ARM[key]
91
+ bx.barh(y0 + (k + 1) * h, v, h * 0.88, color=colour, edgecolor="none")
92
+ bx.text(v + 0.02, y0 + (k + 1) * h, f"{v:.2f}", va="center", fontsize=FS - 3, color=SUB)
93
+ rows.append(dict(panel="b", cohort=ds, series=key, draw=None, value=float(v), source=str(A / "summary.csv")))
94
+ bx.set_yticks(yt, [""] * len(yt))
95
+ bx.tick_params(axis="y", length=0)
96
+ bx.invert_yaxis()
97
+ bx.set_xlim(0, 1.08)
98
+ bx.set_xlabel("Spearman with the copy error")
99
+ fig.legend(handles=[Patch(color=c, label=l) for _, _, c, l in ARMS], loc="lower center", ncol=3,
100
+ bbox_to_anchor=(0.45, -0.08), fontsize=FS - 2, handlelength=1.2, columnspacing=1.6)
101
+ style.save(fig, "sec09_scsemi_representative", FIGDIR)
102
+ OUTDATA.mkdir(exist_ok=True)
103
+ pd.DataFrame(rows).to_csv(OUTDATA / "sec09_scsemi_representative.csv", index=False)
104
+
105
+ s = summ.loc[list(ORDER)]
106
+ worse = [d for d in ORDER if s.loc[d, "scsemi_vs_copy_wilcoxon_p"] < 0.05 and s.loc[d, "scsemi_minus_copy"] > 0]
107
+ better = [d for d in ORDER if s.loc[d, "scsemi_vs_copy_wilcoxon_p"] < 0.05 and s.loc[d, "scsemi_minus_copy"] < 0]
108
+ lora_below = [d for d in ORDER if s.loc[d, "lora_l1"] < s.loc[d, "copy_l1"]]
109
+ kw = [f"scSemi-5 never beats copying its representative: {len(ORDER) - len(better)}/{len(ORDER)}",
110
+ f"Its error tracks the representative's: rho {s.rho_scsemi_copy.min():.2f}–{s.rho_scsemi_copy.max():.2f}",
111
+ f"LoRA-5 below the copy error in {len(lora_below)}/{len(ORDER)} cohorts"]
112
+ numbers = [{"value": f"{NAME[d]}: copy {s.loc[d, 'copy_l1']:.3f}, scSemi-5 {s.loc[d, 'scsemi_l1']:.3f} "
113
+ f"(Wilcoxon vs copy p {s.loc[d, 'scsemi_vs_copy_wilcoxon_p']:.2g}), LoRA-5 {s.loc[d, 'lora_l1']:.3f}; "
114
+ f"rho scSemi {s.loc[d, 'rho_scsemi_copy']:.2f}, LoRA {s.loc[d, 'rho_lora_copy']:.2f}",
115
+ "source": str(A / "summary.csv")} for d in ORDER]
116
+ proxy = "; ".join(f"{NAME[d]} ({int(prox.loc[d, 'n_representative_samples'])} samples) "
117
+ f"ours {prox.loc[d, 'copy_l1_our_draws']:.2f}, KMeans {prox.loc[d, 'copy_l1_kmeans']:.2f}, "
118
+ f"random samples {prox.loc[d, 'copy_l1_random_samples']:.2f}" for d in ORDER)
119
+ numbers.append({"value": "KMeans proxy, copy error: " + proxy, "source": str(A / "kmeans_proxy.csv")})
120
+ full = ("Same 25 five-donor draws. scSemiProfiler gives every test sample exactly one representative, the nearest "
121
+ "training sample in its bulk PCA (assignment.json), and runs its encoder on that representative's cells. "
122
+ "Copy = composition L1 between the test sample's and its representative's observed cells (same frozen "
123
+ "scANVI labels as the scorer). Bars: mean over draws of the per-draw mean; dots = draws. scSemi vs copy: "
124
+ "paired Wilcoxon over test samples (" + ", ".join(f"{NAME[d]} p {s.loc[d, 'scsemi_vs_copy_wilcoxon_p']:.2g}"
125
+ for d in ORDER) + "). "
126
+ "Upstream's own representative choice (KMeans on the same bulk PCA, the sample nearest each centre; proxy, "
127
+ "not a rerun) gives a lower copy error than our 5-donor draws in Imperial, Giroux and Ji, where our draws hold "
128
+ "all visits of 5 donors and KMeans spreads the same number of samples over as many donors; equal or higher "
129
+ "in ImMicro and sepsis. Copy error: " + proxy + ". "
130
+ "Source: plans/paired_finetune_intradataset_20260927/scsemi/analysis/representative_dependence_20261002/.")
131
+ txt = {"title": "scSemiProfiler copies its representative", "layout": "full",
132
+ "figures": [str(FIGDIR / "sec09_scsemi_representative.png")], "keywords": kw,
133
+ "footnote_short": "Copy = composition of the one training sample scSemiProfiler assigns to each test sample.",
134
+ "footnote": full, "numbers": numbers}
135
+ out = {"section": "09-scsemi-representative", "scripts": [str(Path(__file__).resolve())],
136
+ "generated_from": "tools/sec09_scsemi_representative.py (rerun to refresh; do not edit by hand)",
137
+ "slides": [txt]}
138
+ (OUTDATA / "sec09_scsemi_representative_slide_text.json").write_text(json.dumps(out, indent=1, ensure_ascii=False))
139
+ print("\n".join(kw))
140
+ return 0
141
+
142
+
143
+ if __name__ == "__main__":
144
+ sys.exit(main())