Archive 4 checkpoints (1-4)
Browse files- .gitattributes +2 -0
- paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pdf +3 -0
- paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/PBISC-Diffusion_paper_summary_20260930.pptx +3 -0
- paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md +304 -0
- paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/fig23_healthy.py +509 -0
.gitattributes
CHANGED
|
@@ -106,3 +106,5 @@ paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-ti
|
|
| 106 |
paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/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
|
| 107 |
paper-releases/pbisc-diffusion/updates/20261008T121550Z-deck-fig4-rules-no-broadcast/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
|
| 108 |
paper-releases/pbisc-diffusion/updates/20261008T121550Z-deck-fig4-rules-no-broadcast/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
|
|
|
|
|
|
|
|
|
| 106 |
paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/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
|
| 107 |
paper-releases/pbisc-diffusion/updates/20261008T121550Z-deck-fig4-rules-no-broadcast/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
|
| 108 |
paper-releases/pbisc-diffusion/updates/20261008T121550Z-deck-fig4-rules-no-broadcast/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
|
| 109 |
+
paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/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
|
| 110 |
+
paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/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/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/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:d51d6c39c5fe52f5d42ea8d684f826bdbb65af54c43d1120cfefd2fb05667bf4
|
| 3 |
+
size 10945024
|
paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/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:2532c0637bf7623d69ab355f672afdc065e9e9438fc298cda477a8b6944c1825
|
| 3 |
+
size 11706231
|
paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PBISC-Diffusion paper summary deck (2026-09-30, r00; ordered by the six manuscript figures since 2026-10-06)
|
| 2 |
+
|
| 3 |
+
76-slide English deck, ordered by the six main figures of the Nature-style manuscript plan (user request 2026-10-06,
|
| 4 |
+
following `paper-release-20260928/reference-papers/Nature Style Manuscript Writing.pdf`):
|
| 5 |
+
- Title and outline: 6 figures, Supplementary, Appendix, Discussion.
|
| 6 |
+
- "Manuscript plan: six main figures": a table of each figure's claim and how many panels are ready.
|
| 7 |
+
- For each figure:
|
| 8 |
+
- a divider;
|
| 9 |
+
- a plan slide, a table of panel / content / evidence slide / status (Ready, Adapt, Draft, Build, Run, Plan);
|
| 10 |
+
- the existing slides that serve its panels, each labelled "Fig. 2c" etc. in the top-right corner.
|
| 11 |
+
- Supplementary: a plan slide plus the from-scratch results. Appendix: the modified scSemiProfiler run. Discussion: the
|
| 12 |
+
other-tissues outlook.
|
| 13 |
+
|
| 14 |
+
User decisions of 2026-10-06:
|
| 15 |
+
- No PBISC-VAE: scSemiProfiler, a VAE-based method, is the comparison (Fig. 3).
|
| 16 |
+
- Fig. 2 shows LoRA first on the healthy cohort (ImMicro) with the realism metrics (precision, coverage, classifier
|
| 17 |
+
AUROC, MMD, E_N); the disease-cohort comparison comes later.
|
| 18 |
+
- CYBERSORTx and other bulk deconvolution methods go to the Supplementary only (PBISC generates single cells).
|
| 19 |
+
- Figs 4 and 6 stay unplanned. Their existing slides are kept in the section as "Fig. 4 candidate" / "Fig. 6 candidate".
|
| 20 |
+
|
| 21 |
+
Only order, section labels, the agenda and new plan or draft slides changed. The new slides are "Overview draft (Nature
|
| 22 |
+
style)", the manuscript's candidate Fig. 1, and "Pretraining corpus", the Fig. 1d strip. No new result figures were
|
| 23 |
+
made.
|
| 24 |
+
- The plan lives in `data/figure_plan.json`.
|
| 25 |
+
- `tools/figure_plan.py` draws the plan tables and the slide text, and checks that every slide is placed exactly once.
|
| 26 |
+
- `tools/restructure_figure_order_20261006.py` rebuilds the order from the plan. It is rerun after every plan change and
|
| 27 |
+
keeps all slide fields.
|
| 28 |
+
- The earlier section order (10 sections, 45 slides) is in `_archive/2026-10-06_before_figure_order/`.
|
| 29 |
+
|
| 30 |
+
Short keyword lines only; the figures carry the results. Every slide that uses a published method, metric or
|
| 31 |
+
baseline has a one-line "References:" footer; full citations are in the speaker notes.
|
| 32 |
+
|
| 33 |
+
- `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
|
| 34 |
+
- `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
|
| 35 |
+
- `data/slides_spec.json`: slide order, titles, keywords, footnotes, references, speaker-note text
|
| 36 |
+
- `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
|
| 37 |
+
- `figures/`: exactly the figures the slides show (PNG + PDF), made by `tools/sec*.py`. Intermediate panels go to a
|
| 38 |
+
temporary folder; superseded figures are deleted, not kept (2026-10-02, user request; every deleted file was
|
| 39 |
+
checked to be in the paper archive by sha256 first).
|
| 40 |
+
- `data/sec*.csv` and `data/*_slide_text.json`: every plotted or quoted number with its source path
|
| 41 |
+
- `render/`: PDF and 70-dpi slide JPGs for checking
|
| 42 |
+
|
| 43 |
+
## Slide order
|
| 44 |
+
|
| 45 |
+
| section | slides |
|
| 46 |
+
|---|---|
|
| 47 |
+
| 1 Model overview | bulk in, cells out; denoiser |
|
| 48 |
+
| 2 Backbone | SDD → PBISC-Diffusion; bulk conditioning |
|
| 49 |
+
| 3 Architecture ablation | width & context (loss, benchmark); gene panel |
|
| 50 |
+
| 4 Metrics + SLE benchmark | **how we score generated cells** (metric table with references); SLE benchmark; per cell type; bulk broadcast baseline |
|
| 51 |
+
| 5 Real bulk vs pseudobulk | input shift; same shift in three cohorts; cells off-manifold; disease direction flips |
|
| 52 |
+
| 6 Paired fine-tuning | method; evaluation design |
|
| 53 |
+
| 7 LoRA ablations | full vs LoRA vs cond.-encoder-only; LoRA rank r = 4 / 16 / 64; K diversification |
|
| 54 |
+
| 8 Pairs needed | composition / coverage / steps (with scSemiProfiler at the same n); donor and disease signal; pairs from other cohorts; longer training on them (with training minutes) |
|
| 55 |
+
| 9 Paired validation | cohorts; 5 donors: cells, realism beyond P/C, P/C at k = 3 / 5 / 10, scSemiProfiler copies its representative, disease signal, CAT curves, time to apply; 5-fold CV (with scSemiProfiler on the same pairs); same training pairs: LoRA vs scSemiProfiler; 5-fold realism metrics |
|
| 56 |
+
| 10 Next steps | paired-subset cohorts (planned); other tissues from a few dozen pairs (Discussion framing of the from-scratch results) |
|
| 57 |
+
| Supplementary | no pretraining: same cohort, from scratch (pilot); no pretraining: other cohorts, from scratch (pilot); rare states: from scratch vs pretrained; deconvolution with the same pairs: composition; deconvolution with the same pairs: disease signal |
|
| 58 |
+
| Appendix | scSemiProfiler without its output threshold (sensitivity; modified read-out, not the official output) |
|
| 59 |
+
|
| 60 |
+
## Rebuild
|
| 61 |
+
|
| 62 |
+
Everything is CPU only; no GPU or checkpoint is touched.
|
| 63 |
+
|
| 64 |
+
```bash
|
| 65 |
+
# prerequisites (plan folder plans/paired_finetune_intradataset_20260927/, CPU):
|
| 66 |
+
# scsemi/tools/representative_dependence.py -> scsemi/analysis/representative_dependence_20261002/
|
| 67 |
+
# tools/contrast_extra.py (+ tools/contrast_extra_tables.py) -> scores_contrast/ (Spearman, ceiling, limma, CAT, RBO)
|
| 68 |
+
# tools/build_tpm_zeroshot.py + tools/score_tpm_zeroshot.sh -> scores/<ds>/zeroshot_tpm_20261002/pooled/
|
| 69 |
+
# (the length-corrected zero-shot arm needs one GPU sampling step: tools/sample_lockwait.sh, coordinator only)
|
| 70 |
+
cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
|
| 71 |
+
# shared helpers, not run directly: style.py, sec03_common.py, scsemi_results.py, fold_sizes.py
|
| 72 |
+
for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
|
| 73 |
+
sec04_metrics_overview sec04_sle_benchmark sec05_condition_space sec05_cells_offmanifold \
|
| 74 |
+
sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
|
| 75 |
+
sec07_k_aug sec07_rank_sweep sec08_pairs_needed sec08_cross_cohort sec09_paired_validation sec09_extra_metrics \
|
| 76 |
+
sec09_time_to_apply sec09_scsemi_representative sec09_cat_curves sec10_paired_subset_cohorts \
|
| 77 |
+
secA_scsemi_readout sec07_no_pretraining sec08_cross_scratch sec09_same_pairs \
|
| 78 |
+
secS_scratch_rare_states secS_deconvolution fig3_time_days fig4_disease fig23_healthy fig5_rare_states sec10_other_tissues figure_plan; do # keep this order (sec10 reads secS; figure_plan last)
|
| 79 |
+
python3 "tools/$f.py" || break
|
| 80 |
+
done
|
| 81 |
+
python3 tools/restructure_figure_order_20261006.py # order the slides by data/figure_plan.json
|
| 82 |
+
python3 tools/sync_sec09_text.py # copy every generated slide text (sec09_index / text_source) into the spec
|
| 83 |
+
python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
|
| 84 |
+
soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
|
| 85 |
+
pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
|
| 86 |
+
cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
`generate_deck.py` stops with an error if a figure is missing, a title does not fit on one line, a footnote needs
|
| 90 |
+
more than 2 lines (1 line when the slide has references), the reference line needs more than 1 line, or any text
|
| 91 |
+
contains Korean or placeholder words. `tools/restructure_20261002.py` is the one-off script that produced the current
|
| 92 |
+
slide order and the references (it refuses to run twice).
|
| 93 |
+
|
| 94 |
+
## Notes
|
| 95 |
+
|
| 96 |
+
- **No "all" label (2026-10-02).** The 5-fold arm trains each fold model on the other four folds minus 7–8
|
| 97 |
+
inner-validation donors; its test fold is never trained on (RUN.json `test_rows_never_loaded_for_training`). Figures
|
| 98 |
+
label it "5-fold CV (other 4 folds)" and learning-curve ticks show the training-pair count per fold (78–79 ImMicro,
|
| 99 |
+
58–59 sepsis), read by `tools/fold_sizes.py`.
|
| 100 |
+
- **Learning curve x = 0 uses no pairs (2026-10-02).** It shows the zero-shot model fed the real bulk as measured
|
| 101 |
+
and after exon-length correction (counts / Ensembl union-exon kb, then the same fixed-depth arithmetic;
|
| 102 |
+
`plans/.../tools/build_tpm_zeroshot.py`, scored in `scores/<ds>/zeroshot_tpm_20261002/pooled`). The old x = 0
|
| 103 |
+
calibration point, whose alpha used every training pair of the fold, is gone; calibration appears only fitted on the
|
| 104 |
+
same n pairs as the LoRA point (squares; `cal_budget_20261001`).
|
| 105 |
+
- **Disease metrics (2026-10-02).** Next to Pearson logFC r and the Welch top-50 DEG overlap: Spearman r, the
|
| 106 |
+
split-half ceiling (observed vs observed, Spearman–Brown), limma-voom top-50 DEG, each arm's chance overlap, and
|
| 107 |
+
CAT curves with the k / 2G chance line (`plans/.../scores_contrast/`, tools/contrast_extra.py; every Pearson r and
|
| 108 |
+
Welch count reproduced exactly). Repeated samples of one patient (Imperial, Giroux, Ji) count as separate samples in
|
| 109 |
+
both DE tests, as in the scorer (footnote).
|
| 110 |
+
- Section 9 text is generated: `tools/sec09_paired_validation.py`, `sec09_extra_metrics.py`, `sec07_rank_sweep.py`,
|
| 111 |
+
`sec09_time_to_apply.py`, `sec09_scsemi_representative.py`, `sec09_cat_curves.py` write slide text JSON; sync copies
|
| 112 |
+
it. Hand-written: the keywords of the two "Pairs needed" slides (section 8) and of every slide in sections 1–7 and 10.
|
| 113 |
+
- Giroux's disease metrics exclude 196 sex-linked genes (severity is confounded with sex), from
|
| 114 |
+
`plans/.../scores_nosex/`. The calibration comparator is "Zero-shot + calibration" (user decision 2026-10-01).
|
| 115 |
+
- Story rule (user decision 2026-09-30): no PBISC-VAE and no reference calibration (refcal). The exon-length-corrected
|
| 116 |
+
input is used only as the no-pair x = 0 point of the learning curve (user decision 2026-10-02).
|
| 117 |
+
`tools/sec04_immicro.py` (refcal vs scSemiProfiler on ImMicro) is kept but is not part of the deck or the rebuild.
|
| 118 |
+
- scSemiProfiler 5-fold and equal-budget results are picked up automatically when they appear (`tools/scsemi_results.py`;
|
| 119 |
+
arm `scsemi__raw` in `scores/<cohort>/scsemi_cv_20261002/pooled*/`, `scsemi_n{5,10,20,40}__raw` in
|
| 120 |
+
`scores/<cohort>/scsemi_budget_20261002/pooled*/`; same donors and reference cells as the main pooled call only).
|
| 121 |
+
Then rerun sections 8 and 9, sync, recheck the section 8 keywords and rebuild.
|
| 122 |
+
- Earlier versions: `_archive/2026-09-30_before_no_vae_refcal/`, `_archive/2026-10-01_before_extra_metrics/`,
|
| 123 |
+
`_archive/2026-10-02_before_time_to_apply/`, `_archive/2026-10-02_before_restructure/` (pptx, PDF, spec; their
|
| 124 |
+
figures are in the paper archive). `DRAFT_1150_*`: the copy shown at the 2026-09-30 12:00 meeting.
|
| 125 |
+
|
| 126 |
+
- Added 2026-10-03 (user decision: the cross-cohort experiment is reported at K = 1000 only and is the figure that explains
|
| 127 |
+
why PBISC fits LoRA on a few pairs of each cohort): slides 25-26 in section 8, `tools/sec08_cross_cohort.py`.
|
| 128 |
+
- Slide 25 "Pairs from other cohorts do not transfer": per held-out cohort, composition L1 / coverage / disease logFC r of
|
| 129 |
+
zero-shot, calibration fitted on the other cohorts, LoRA r16 / r64 / full fine-tune trained on the other cohorts
|
| 130 |
+
(+ Liu 2021) at step saturation, and LoRA on the cohort's own pairs (5-fold pooled).
|
| 131 |
+
- Slide 26 "Longer training on other cohorts" (": gap stays" since 2026-10-06): the same metrics at every 20k-step
|
| 132 |
+
milestone.
|
| 133 |
+
- Source plan: `plans/paired_crosscohort_20261002/` (README; same-reference and same-sample checks in the script).
|
| 134 |
+
Agenda item 8 now reads "How many pairs, and do other cohorts' pairs transfer". The deck has 37 slides.
|
| 135 |
+
Pre-update copy: `_archive/2026-10-03_before_cross_cohort/`.
|
| 136 |
+
|
| 137 |
+
## Sources
|
| 138 |
+
|
| 139 |
+
Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
|
| 140 |
+
`plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
|
| 141 |
+
`plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
|
| 142 |
+
`analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each `data/sec*.csv`. Reference PDFs:
|
| 143 |
+
`/home/sj_server_1/PBISC/paper-release-20260928/reference-papers/` (INDEX.md). Manuscript:
|
| 144 |
+
`/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
|
| 145 |
+
- 2026-10-04 appendix (user decision: supplementary, appendix only, because it changes scSemiProfiler's official
|
| 146 |
+
output). Slide 38 is the divider "Appendix" and slide 39 is "Appendix: scSemiProfiler without output threshold"
|
| 147 |
+
(`tools/secA_scsemi_readout.py`, `data/secA_scsemi_readout{.csv,_slide_text.json}`).
|
| 148 |
+
- Inputs: `plans/paired_finetune_intradataset_20260927/scsemi/analysis/output_variants_20261003/`. The script checks
|
| 149 |
+
that its LoRA-5 and official scSemiProfiler values equal the section 9 slide data draw by draw.
|
| 150 |
+
- Result: without upstream's output threshold, scSemiProfiler's coverage rises in 5/5 cohorts, and 23/23 LoRA-5
|
| 151 |
+
comparisons (coverage, precision, composition, logFC r, DEG) keep their winner.
|
| 152 |
+
- The outline keeps its 10 sections (the builder requires 10). The pre-change copy is in
|
| 153 |
+
`_archive/2026-10-04_before_appendix/`. The deck has 39 slides.
|
| 154 |
+
- 2026-10-05 update (user request: put the results so far into the deck). Pre-change copy: `_archive/2026-10-05_before_scratch_cv/`.
|
| 155 |
+
- New slide 23, "No pretraining: same cohort, from scratch" (`tools/sec07_no_pretraining.py`). Pilot on sepsis fold 0
|
| 156 |
+
(17 donors). Reads `fold0_scratch_20261005/` and the runs' RUN.json. The donor composition r is recomputed from
|
| 157 |
+
per_donor.csv and reproduces ablation_extra_donor.csv.
|
| 158 |
+
- New slide 28, "No pretraining: other cohorts, from scratch" (`tools/sec08_cross_scratch.py`). Held-out sepsis pilot.
|
| 159 |
+
Every arm is read from `paired_crosscohort_20261002/scores_masked/`: genes no training cohort measured are zeroed
|
| 160 |
+
in all arms, because the unmasked scratch arm puts 91–94 % of its UMI there (read from the generated_masked logs
|
| 161 |
+
since 2026-10-06).
|
| 162 |
+
- New slide 38, "Same training pairs: LoRA vs scSemiProfiler" (`tools/sec09_same_pairs.py`). scSemiProfiler 5-fold
|
| 163 |
+
CV with LoRA's own training pairs, plus GPU hours per fold from the receipts on either host. Cohorts that are still
|
| 164 |
+
running show "in progress"; rerun the script as they finish.
|
| 165 |
+
- These two slides now draw the scSemiProfiler CV / budget runs automatically:
|
| 166 |
+
- Slide 24, "Pairs needed" (diamonds; ImMicro so far): keyword 2 reworded, footnote extended.
|
| 167 |
+
- Slide 37, "5-fold CV" (yellow bar; ImMicro and Ji so far).
|
| 168 |
+
- `tools/sec09_paired_validation.py` reads the scSemiProfiler CV arm's Spearman / limma values from
|
| 169 |
+
`scores_contrast/<cohort>/scsemi_cv_20261002/pooled/` (contrast_extra.py --design scored). Pearson r and the Welch
|
| 170 |
+
DEG must match the scorer; the values stay blank until computed. Cohorts not yet run say "in progress".
|
| 171 |
+
- Agenda item 7 now reads "LoRA: compute, rank, K; training from scratch". The deck has 42 slides.
|
| 172 |
+
- New helper: `tools/grouped_bars.py`.
|
| 173 |
+
- 2026-10-06 update (user request: check that the cross-cohort LoRA / full FT, cross-cohort from-scratch and
|
| 174 |
+
same-cohort from-scratch (+ recipes) results, with benchmarks and training times, and the scratch-vs-pretrained rare
|
| 175 |
+
states are in the deck; user decision: the from-scratch results go to the paper's Supplementary and the Discussion
|
| 176 |
+
presents them as a route to other tissues). Pre-change copy: `_archive/2026-10-06_before_supplementary/`.
|
| 177 |
+
- **Supplementary block (new divider, slides 40-43).**
|
| 178 |
+
- "No pretraining: same cohort, from scratch" and "No pretraining: other cohorts, from scratch" moved here from
|
| 179 |
+
sections 7 and 8. Their content is unchanged; slide 42's notes now name the cross-cohort slides by title.
|
| 180 |
+
- New "Rare states: from scratch vs pretrained" (`tools/secS_scratch_rare_states.py`).
|
| 181 |
+
- It reads the rare-state screen (`plans/rare_states_screen_20261004/out/sepsis_fold0_*` and
|
| 182 |
+
`sepsis_loco_masked_*`).
|
| 183 |
+
- The cross-cohort arms use the masked scoring (46 never-measured genes zeroed in every arm).
|
| 184 |
+
- The donor bootstrap reproduces the verified analysis in `out/scratch_vs_lora_20261005/REPORT.md`.
|
| 185 |
+
- **Section 10 "Next steps".**
|
| 186 |
+
- New "Next: other tissues from a few dozen pairs" (`tools/sec10_other_tissues.py`): a comparison table, pretrained
|
| 187 |
+
+ LoRA vs from scratch.
|
| 188 |
+
- Every value is read from the deck's own source tables. The say text is the user's Discussion framing.
|
| 189 |
+
- **Slide 26 "Longer training on other cohorts".** The first keyword is now training minutes to saturation (RUN.json
|
| 190 |
+
wall seconds), with per-cohort minutes and steps in the notes (`tools/sec08_cross_cohort.py`).
|
| 191 |
+
- **Slide 34 "5 donors: time to apply".**
|
| 192 |
+
- The pretraining hours are read from `data/sec06_ft_method.csv`, no longer hard-coded.
|
| 193 |
+
- The note names the 'Fine-tuning with paired bulk + sc' slide by title. Its old "slide 15" pointed at the wrong
|
| 194 |
+
slide.
|
| 195 |
+
- Agenda items 7 and 10 updated. Spec change: `tools/restructure_20261006.py` (refuses to run twice). The deck has 45
|
| 196 |
+
slides; no Korean text.
|
| 197 |
+
- **Review pass (same day).** An independent 5-agent review of the changed slides confirmed 39 issues; all are
|
| 198 |
+
fixed. Pre-review copies of the touched scripts and the spec: `_archive/2026-10-06_before_supplementary/*.pre_review`.
|
| 199 |
+
- Slide 39: pretraining now reads 33.1 M train cells (`train_split_cells`; the 41.4 M corpus includes val/test).
|
| 200 |
+
The rare-state row follows the bootstrap verdicts on both sides (closer on ISG-high T / on DN2 B; labels and
|
| 201 |
+
states both arms miss by > 4-fold are not counted). "No corpus" became "come close": the scratch runs still took
|
| 202 |
+
the panel, value scaler and z-score constants from the PBMC checkpoint (RUN.json `kept_from_checkpoint`, now in
|
| 203 |
+
the notes). The say text carries the one-fold pilot qualifier; the footnote names both pilots.
|
| 204 |
+
- Slide 43: "no significant difference on average" (not "no difference"). Keyword 2 is the cycling T/NK count
|
| 205 |
+
(8 of 8 comparisons). The notes add the ISG-high T split by panel, the scratch-closer states (DN2 B, MS1), the
|
| 206 |
+
52-call tally, the fold-0 caveat (fold 0 is the own-pair LoRA's best fold for C1Q-high and cycling T/NK,
|
| 207 |
+
computed from `folds.csv`), label states unthinned, and "8 of 13 states shown".
|
| 208 |
+
- Slide 26: title "...: gap stays" and "drifts in Sepsis and Ji" are computed from the milestones (gap = no milestone
|
| 209 |
+
reaches the own-cohort coverage; drift = full fine-tune L1 up by >= 0.05). Minutes are in
|
| 210 |
+
`data/sec08_cross_cohort.csv` (wall_seconds, minutes, run_receipt) and in the numbers list.
|
| 211 |
+
- Slide 42: UMI share (94 %, 91–94 % across milestones), the observed share (0.014 %, from `cells_panel6k.npz`)
|
| 212 |
+
and both arms' stopping settings are read from the receipts; the "none" label sits inside the axes.
|
| 213 |
+
- Slide 34: keywords use the cohort means of the figure (17–59×, 57 min–4.1 h); the per-draw range 11–63× is in the
|
| 214 |
+
notes. The right panel shares the bars' rows and has a title.
|
| 215 |
+
- Talk text and pointers: slides 23, 25, 26, 45 (say), 22 (recipes description), 32 and 36 (slide pointers by
|
| 216 |
+
title), slide 1 subtitle "updated 2026-10-06".
|
| 217 |
+
- 2026-10-08 update (user request: put the BayesPrism, CIBERSORTx and scSemiProfiler 5-fold results into the deck).
|
| 218 |
+
Pre-change copy: `_archive/2026-10-08_before_deconvolution/`.
|
| 219 |
+
- **Two new Supplementary slides** (`tools/secS_deconvolution.py`, `data/secS_deconvolution{.csv,_slide_text.json}`):
|
| 220 |
+
"Deconvolution with the same pairs: composition" and "...: disease signal".
|
| 221 |
+
- Source: `plans/bayesprism_paired_20261006/` (README, `results/RESULTS_full.md`, `RESULTS_cibersortx.md`).
|
| 222 |
+
- BayesPrism (recommended genes) and official CIBERSORTx (Fractions S-mode + HiRes) use the same paired donors
|
| 223 |
+
as the reference and the test samples' real bulk as the mixture, with the benchmark's own truth and scorer.
|
| 224 |
+
- Keywords and notes are computed from the tables.
|
| 225 |
+
- **Supplementary plan.** The planned "Bulk deconvolution methods" row is replaced by the two Ready slides.
|
| 226 |
+
`tools/figure_plan.py` now takes an optional per-slide note (`supplementary.notes`) and drops "Planned:" when
|
| 227 |
+
nothing is planned.
|
| 228 |
+
- **New scSemiProfiler results picked up (server_1):**
|
| 229 |
+
- Sepsis and Giroux 5-fold CV. Giroux was finalized on server_1 from sha-checked copies of its fold NPZs, and
|
| 230 |
+
rescored without sex-linked genes in `scores_nosex/giroux2022/scsemi_cv_20261002/pooled`.
|
| 231 |
+
- Sepsis equal-budget n = 5/10/20/40.
|
| 232 |
+
- Imperial 5-fold: finished on server_2 at 13:45 and was finalized on server_1 from sha-checked fold copies.
|
| 233 |
+
scSemiProfiler 5-fold now covers all five cohorts.
|
| 234 |
+
- Spearman/limma extras for sepsis, Giroux and Imperial; realism extras for all five cohorts.
|
| 235 |
+
- **Text changes from the new results:**
|
| 236 |
+
- "Same training pairs": keywords are data-driven. LoRA leads on coverage and precision in 5/5 cohorts;
|
| 237 |
+
composition 4/5 and logFC r 3/4, where scSemiProfiler leads in Giroux. The GPU-time ratio is 19–62×.
|
| 238 |
+
- sec09_same_pairs.py now reads the sepsis fold-0 pilot queue tag (`sep_f0`). For Giroux it quotes DEG from
|
| 239 |
+
scores_nosex, and for older pooled LoRA calls from pooled_deg.
|
| 240 |
+
- "5-fold CV" keyword: logFC r 3/4.
|
| 241 |
+
- "Pairs needed" (hand-written): scSemiProfiler coverage 0.04 / 0.10. On sepsis disease logFC r,
|
| 242 |
+
scSemiProfiler at 5–40 pairs (0.52–0.58) is above LoRA (0.29–0.48), while its top-50 DEG stays at 2–6.
|
| 243 |
+
- 2026-10-08, new figure split (user decision; supersedes the 2026-10-06 split; pre-change copy
|
| 244 |
+
`_archive/2026-10-08_before_new_figure_plan/`).
|
| 245 |
+
- Fig. 2: LoRA fine-tuning with no disease metrics.
|
| 246 |
+
- Fig. 3: PBISC vs scSemiProfiler on healthy donors, with time as a main result.
|
| 247 |
+
- Fig. 4: disease benchmarks on the paired cohorts (PBISC versions, scSemiProfiler, and BayesPrism / CIBERSORTx
|
| 248 |
+
labelled as cell-type deconvolution; the deconvolution slides moved here from the Supplementary).
|
| 249 |
+
- Fig. 5: rare-cell fractions and detection.
|
| 250 |
+
- Fig. 6: new findings from the bulk-only sepsis and COVID samples (K = 1,000 and 4,000).
|
| 251 |
+
- The cross-cohort transfer slides moved to the Supplementary; their placement is open.
|
| 252 |
+
- New slide "Time: days for scSemiProfiler, minutes for LoRA" (`tools/fig3_time_days.py`, Fig. 3d).
|
| 253 |
+
- Inputs: GPU hours per 5-fold experiment from the receipts (`data/sec09_same_pairs.csv`, checked against
|
| 254 |
+
the scSemiProfiler event logs on both hosts), the 5-donor draws (`data/sec09_time_to_apply.csv`) and the
|
| 255 |
+
one-time pretraining (`data/sec06_ft_method.csv`).
|
| 256 |
+
- Results: ImMicro 24 h vs 1.2 h, sepsis 38 h vs 37 min. All runs: scSemiProfiler 184 h (7.7 days) vs PBISC
|
| 257 |
+
22 h including pretraining.
|
| 258 |
+
- The equal-budget scSemiProfiler runs are excluded: they reuse the 5-fold run's representative models.
|
| 259 |
+
- Panel status: Build / Run marks new slides or analyses still to do; Adapt marks slides to re-scope (healthy-only
|
| 260 |
+
Fig. 2-3, disease columns into Fig. 4).
|
| 261 |
+
- 2026-10-08, comparison rules (user decision; memory feedback_paper_comparison_rules):
|
| 262 |
+
- **Time.** Only per-cohort GPU work counts: no PBISC pretraining, no GPU queue waits. The time slide now shows the
|
| 263 |
+
5-donor draws (main) next to the 5-fold runs (separate). All runs: 7.7 GPU-days vs 5.7 h.
|
| 264 |
+
- **No bulk-broadcast baseline.** It is removed from the SLE benchmark, CAT, deconvolution and "Pairs needed"
|
| 265 |
+
figures.
|
| 266 |
+
- The "Bulk broadcast baseline" slide is gone. Its partial r panel is now on the SLE benchmark slide
|
| 267 |
+
(0.21 vs 0.17).
|
| 268 |
+
- Still to rebuild in their own phases: Fig. 2e (ImMicro only) and Fig. 6a.
|
| 269 |
+
- **Main comparison = 5 pairs** (LoRA-5 vs scSemiProfiler-5); 5-fold is reported separately. Partial r is
|
| 270 |
+
emphasised (bold panel titles).
|
| 271 |
+
- **New `tools/fig4_disease.py`**, which checks all 200 logFC r / DEG values against the section-9 tables:
|
| 272 |
+
- "Disease signal with 5 pairs: LoRA-5 vs others" (4b);
|
| 273 |
+
- "5-fold CV: disease signal" (4c);
|
| 274 |
+
- "Sepsis: fine-tuning variants" (details).
|
| 275 |
+
- The old "5 donors: LoRA vs scSemiProfiler — disease signal" slide is retired. `tools/sync_sec09_text.py` lists it
|
| 276 |
+
in RETIRED.
|
| 277 |
+
- The deconvolution slides are retitled "Cell-type deconvolution, same pairs: ...".
|
| 278 |
+
- 2026-10-08, healthy-only Figs 2-3 (`tools/fig23_healthy.py`).
|
| 279 |
+
- Eight ImMicro-only slides, re-plotted from the deck's own data tables; nothing is re-scored.
|
| 280 |
+
- Fig. 2 (no disease metrics):
|
| 281 |
+
- cells, realism, full / LoRA / condition encoder, pairs needed, rank and K;
|
| 282 |
+
- 5 donors (main) shown next to 5-fold (separate).
|
| 283 |
+
- Fig. 3 (vs scSemiProfiler):
|
| 284 |
+
- LoRA-5 vs scSemiProfiler-5 on 6 cell metrics: LoRA ahead on 6 of 6;
|
| 285 |
+
- the same pairs, 5 to all;
|
| 286 |
+
- scSemiProfiler copies its representative;
|
| 287 |
+
- time.
|
| 288 |
+
- The earlier all-cohort slides moved to the Supplementary (note "all five cohorts").
|
| 289 |
+
- "5-fold CV: train on the other 4 folds" is retired (it carried the broadcast; its content is now in Fig. 4c and
|
| 290 |
+
the healthy slides). It is listed in RETIRED of `tools/sync_sec09_text.py`.
|
| 291 |
+
- 2026-10-08, Fig. 5 rare cells (`tools/fig5_rare_states.py`).
|
| 292 |
+
- Source: new plan `plans/rare_states_paired_20261008` (README). It covers 4 paired disease cohorts, the 5-donor
|
| 293 |
+
draws and 5-fold, and the arms zero-shot, calibration, scSemiProfiler and LoRA. Each NPZ is sha-checked and the
|
| 294 |
+
benchmark's Poisson read-out and labels are reproduced cell by cell.
|
| 295 |
+
- Three slides:
|
| 296 |
+
- fraction (5a);
|
| 297 |
+
- donors and disease direction (5b);
|
| 298 |
+
- 5-fold, separate (5c).
|
| 299 |
+
- Results over 56 state × cohort pairs, 5 donors:
|
| 300 |
+
- LoRA-5 closer to the observed fraction than scSemiProfiler-5 in 51/56;
|
| 301 |
+
- within 2-fold: 19 vs 5;
|
| 302 |
+
- better donor ranking: 43/56;
|
| 303 |
+
- disease direction kept: 73% vs 61%.
|
| 304 |
+
- Fig. 6a no longer mentions the broadcast. No slide text mentions it now.
|
paper-releases/pbisc-diffusion/updates/20261008T125804Z-deck-fig2-3-healthy-fig5-rare/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/fig23_healthy.py
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Fig. 2 and Fig. 3 healthy-cohort slides of the 2026-09-30 paper-summary deck (2026-10-08; user decisions of that day:
|
| 3 |
+
Fig. 2 = LoRA fine-tuning without disease metrics; Fig. 3 = PBISC vs scSemiProfiler on healthy donors only (ImMicro,
|
| 4 |
+
107 donors); main comparison = 5 pairs (LoRA-5 vs scSemiProfiler with the same 5 donors as representatives); 5-fold
|
| 5 |
+
CV reported separately).
|
| 6 |
+
|
| 7 |
+
CPU only, plotting only. Every value is read from the deck's own data tables (written by the section tools, which read
|
| 8 |
+
the scorer outputs) and re-plotted for ImMicro alone; nothing is re-scored.
|
| 9 |
+
data/sec09_fewpair_cells.csv 5 donors x 5 draws: coverage, precision, composition L1 (zs_raw, zs_cal, scsemi5, lora)
|
| 10 |
+
data/sec09_extra_fewpair.csv 5 donors: classifier AUC (kNN), MMD^2, E_N (+ real-vs-real control)
|
| 11 |
+
data/sec09_extra_fivefold.csv 5-fold: the same realism metrics (zs_raw, zs_cal, sconly_cal, scsemi_all, lora)
|
| 12 |
+
data/sec07_ft_modes_accuracy.csv 5-fold pooled and fold-0 pilot: full FT, LoRA, cond.-encoder-only, sc-only, zero-shot
|
| 13 |
+
data/sec07_ft_modes_compute.csv trainable weights and wall minutes per fine-tuning mode
|
| 14 |
+
data/sec08_pairs_realism.csv composition L1, coverage vs training pairs (zero-shot, calibration, scSemi, LoRA)
|
| 15 |
+
data/sec08_pairs_signal.csv donor NK-fraction r vs training pairs
|
| 16 |
+
data/sec08_selected_steps_per_fold.csv early-stopping step per fold and pair count
|
| 17 |
+
data/sec07_rank_sweep.csv, data/sec07_k_aug.csv LoRA rank 4 / 16 / 64 and K choices
|
| 18 |
+
data/sec09_same_pairs.csv 5-fold pooled LoRA vs scSemiProfiler (same pairs)
|
| 19 |
+
data/sec09_scsemi_representative.csv scSemiProfiler vs copying its representative's composition
|
| 20 |
+
Outputs: figures/fig2_healthy_{cells,realism,modes,pairs,rank}.{png,pdf}, figures/fig3_healthy_{fewpair,pairs,copy}.
|
| 21 |
+
{png,pdf}, data/fig23_healthy.csv, data/fig23_healthy_slide_text.json
|
| 22 |
+
"""
|
| 23 |
+
from __future__ import annotations
|
| 24 |
+
|
| 25 |
+
import json
|
| 26 |
+
import os
|
| 27 |
+
import sys
|
| 28 |
+
from pathlib import Path
|
| 29 |
+
|
| 30 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "" # plotting only
|
| 31 |
+
|
| 32 |
+
import numpy as np
|
| 33 |
+
import pandas as pd
|
| 34 |
+
|
| 35 |
+
DECK = Path(__file__).resolve().parents[1]
|
| 36 |
+
sys.path.insert(0, str(DECK / "tools"))
|
| 37 |
+
import style as ST # noqa: E402
|
| 38 |
+
import matplotlib.pyplot as plt # noqa: E402
|
| 39 |
+
from matplotlib.lines import Line2D # noqa: E402
|
| 40 |
+
|
| 41 |
+
FIG, DAT = DECK / "figures", DECK / "data"
|
| 42 |
+
DS = "immicro"
|
| 43 |
+
C = {"zs_raw": ST.ARM["zs_raw"], "zs_cal": ST.ARM["zs_cal"], "sconly_cal": ST.ARM["sconly"], "scsemi": ST.ARM["scsemi"],
|
| 44 |
+
"lora": ST.ARM["lora"], "full": ST.ARM["full_ft"], "condenc": ST.ARM["other"]}
|
| 45 |
+
L = {"zs_raw": "Zero-shot, real bulk", "zs_cal": "Zero-shot + calibration", "sconly_cal": "sc-only fine-tune (+ cal.)",
|
| 46 |
+
"scsemi": "scSemiProfiler", "lora": "PBISC LoRA", "full": "Full fine-tune", "condenc": "Cond.-encoder-only"}
|
| 47 |
+
ROWS = []
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def rec(slide, metric, series, value, source, design="", extra=""):
|
| 51 |
+
ROWS.append({"slide": slide, "design": design, "metric": metric, "series": series, "value": float(value),
|
| 52 |
+
"extra": extra, "source": source})
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def rng(v) -> str:
|
| 56 |
+
"""'a–b', or one value when both ends round to the same number"""
|
| 57 |
+
a, b = f"{min(v):.2f}", f"{max(v):.2f}"
|
| 58 |
+
return a if a == b else f"{a}–{b}"
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def refs(short):
|
| 62 |
+
spec = json.loads((DAT / "slides_spec.json").read_text())["slides"]
|
| 63 |
+
full = {}
|
| 64 |
+
for s in spec:
|
| 65 |
+
for a, b in zip(s.get("refs", []), s.get("refs_full", [])):
|
| 66 |
+
full.setdefault(a, b)
|
| 67 |
+
return [full[k] for k in short]
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def fewpair_cells():
|
| 71 |
+
t = pd.read_csv(DAT / "sec09_fewpair_cells.csv")
|
| 72 |
+
t = t[(t.dataset == DS) & (t.kind == "draw")]
|
| 73 |
+
return {(m, s): t[(t.metric == m) & (t.series == s)].value.to_numpy() for m in ("coverage", "precision", "comp_l1")
|
| 74 |
+
for s in ("zs_raw", "zs_cal", "scsemi5", "lora")}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def fewpair_extra():
|
| 78 |
+
t = pd.read_csv(DAT / "sec09_extra_fewpair.csv")
|
| 79 |
+
t = t[t.dataset == DS]
|
| 80 |
+
return {(m, s): t[(t.metric == m) & (t.series == s)].value.to_numpy() for m in ("c2st_knn_auc", "mmd2_bw1", "en_all_sq")
|
| 81 |
+
for s in ("zs_raw", "zs_cal", "scsemi5", "lora", "ref_control")}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def fivefold_extra():
|
| 85 |
+
t = pd.read_csv(DAT / "sec09_extra_fivefold.csv")
|
| 86 |
+
t = t[t.dataset == DS]
|
| 87 |
+
return {(m, s): float(t[(t.metric == m) & (t.series == s)].value.iloc[0]) for m in ("c2st_knn_auc", "mmd2_bw1", "en_all_sq")
|
| 88 |
+
for s in ("zs_raw", "zs_cal", "sconly_cal", "scsemi_all", "lora", "ref_control")
|
| 89 |
+
if len(t[(t.metric == m) & (t.series == s)])}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def modes():
|
| 93 |
+
a = pd.read_csv(DAT / "sec07_ft_modes_accuracy.csv")
|
| 94 |
+
return a[a.dataset == DS].set_index(["call", "arm"])
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def bar_group(ax, x0, arms, vals, w=0.17, dots=None, fmt="{:.2f}", log=False):
|
| 98 |
+
"""bars for one design group centred on x0; vals: {arm: value}; dots: {arm: array}"""
|
| 99 |
+
k = len(arms)
|
| 100 |
+
for i, a in enumerate(arms):
|
| 101 |
+
x = x0 + (i - (k - 1) / 2) * w
|
| 102 |
+
v = vals[a]
|
| 103 |
+
ax.bar(x, v, w * 0.9, color=C[a], edgecolor="none", zorder=2)
|
| 104 |
+
if dots is not None and a in dots and len(dots[a]) > 1:
|
| 105 |
+
d = dots[a]
|
| 106 |
+
ax.scatter(np.full(len(d), x) + np.linspace(-w * 0.2, w * 0.2, len(d)), d, s=8, color="white",
|
| 107 |
+
edgecolor=ST.INK, linewidth=0.5, zorder=3)
|
| 108 |
+
ax.text(x, v * (1.15 if log else 1) + (0 if log else 0.012 * ax.get_ylim()[1]), fmt.format(v), ha="center",
|
| 109 |
+
va="bottom", fontsize=ST.FS - 7, color=ST.SUBINK, rotation=90)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def two_design_panel(ax, title, few, fold, few_arms, fold_arms, dots=None, ref=None, fmt="{:.2f}", log=False, ylim=None):
|
| 113 |
+
if log:
|
| 114 |
+
ax.set_yscale("log")
|
| 115 |
+
if ylim:
|
| 116 |
+
ax.set_ylim(*ylim)
|
| 117 |
+
bar_group(ax, 0, few_arms, few, dots=dots, fmt=fmt, log=log)
|
| 118 |
+
bar_group(ax, 1.15, fold_arms, fold, fmt=fmt, log=log)
|
| 119 |
+
if ref is not None:
|
| 120 |
+
ax.axhline(ref, color=ST.INK, ls=(0, (3, 2)), lw=1, zorder=1)
|
| 121 |
+
ax.set_xticks([0, 1.15], ["5 donors\n(main)", "5-fold CV\n(separate)"], fontsize=ST.FS - 3)
|
| 122 |
+
ax.set_title(title, fontsize=ST.FS - 1, loc="left")
|
| 123 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 124 |
+
ax.set_axisbelow(True)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def legend(fig, keys, extra=None, ncol=None):
|
| 128 |
+
h = [plt.Rectangle((0, 0), 1, 1, color=C[k]) for k in keys]
|
| 129 |
+
lab = [L[k] for k in keys]
|
| 130 |
+
if extra:
|
| 131 |
+
h += [e[0] for e in extra]
|
| 132 |
+
lab += [e[1] for e in extra]
|
| 133 |
+
fig.legend(h, lab, loc="lower center", ncol=ncol or len(h), bbox_to_anchor=(0.5, -0.08), fontsize=ST.FS - 3)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def main() -> int:
|
| 137 |
+
fc, fx, vx, md = fewpair_cells(), fewpair_extra(), fivefold_extra(), modes()
|
| 138 |
+
sp = pd.read_csv(DAT / "sec09_same_pairs.csv").set_index(["dataset", "arm"])
|
| 139 |
+
m5 = lambda m, s: float(fc[(m, s)].mean()) # noqa: E731
|
| 140 |
+
fold_cells = {m: {"zs_raw": md.loc[("pooled", "zs__raw"), m], "zs_cal": md.loc[("pooled", "zs__cal"), m],
|
| 141 |
+
"sconly_cal": md.loc[("pooled", "pseudo_full__cal"), m], "lora": md.loc[("pooled", "real_lora__raw"), m],
|
| 142 |
+
"scsemi": float(sp.loc[(DS, "scsemi"), m])} for m in ("coverage", "precision", "comp_l1")}
|
| 143 |
+
slides = []
|
| 144 |
+
# ================================================================ Fig. 2e cells (no scSemiProfiler: Fig. 3)
|
| 145 |
+
fig, axes = plt.subplots(1, 3, figsize=ST.FULL, gridspec_kw={"wspace": 0.3})
|
| 146 |
+
for ax, (m, lab, ylim) in zip(axes, (("coverage", "Coverage ↑", (0, 1.05)), ("precision", "Precision ↑", (0, 1.1)),
|
| 147 |
+
("comp_l1", "Composition L1 ↓", (0, 0.55)))):
|
| 148 |
+
few = {a: m5(m, s) for a, s in (("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("lora", "lora"))}
|
| 149 |
+
dots = {a: fc[(m, s)] for a, s in (("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("lora", "lora"))}
|
| 150 |
+
fold = {a: float(fold_cells[m][a]) for a in ("zs_raw", "zs_cal", "sconly_cal", "lora")}
|
| 151 |
+
two_design_panel(ax, lab, few, fold, ["zs_raw", "zs_cal", "lora"], ["zs_raw", "zs_cal", "sconly_cal", "lora"],
|
| 152 |
+
dots=dots, ylim=ylim)
|
| 153 |
+
for a, v in few.items():
|
| 154 |
+
rec("2e", m, a, v, "data/sec09_fewpair_cells.csv", "5 donors (mean of 5 draws)")
|
| 155 |
+
for a, v in fold.items():
|
| 156 |
+
rec("2e", m, a, v, "data/sec07_ft_modes_accuracy.csv", "5-fold pooled")
|
| 157 |
+
legend(fig, ["zs_raw", "zs_cal", "sconly_cal", "lora"])
|
| 158 |
+
ST.save(fig, "fig2_healthy_cells", FIG)
|
| 159 |
+
cov5, cov0 = m5("coverage", "lora"), m5("coverage", "zs_raw")
|
| 160 |
+
slides.append({"title": "Healthy cohort: LoRA cells cover the real ones", "figure": "fig2_healthy_cells",
|
| 161 |
+
"keywords": [f"5 donors: coverage {cov0:.2f} → {cov5:.2f}",
|
| 162 |
+
f"Precision {m5('precision', 'lora'):.2f}; composition L1 {m5('comp_l1', 'lora'):.2f}",
|
| 163 |
+
f"5-fold: coverage {fold_cells['coverage']['lora']:.2f}, L1 {fold_cells['comp_l1']['lora']:.2f}"],
|
| 164 |
+
"short": "ImMicro, 107 healthy donors. 5 donors: mean of 5 draws (dots); 5-fold CV shown separately.",
|
| 165 |
+
"full": ("ImMicro, 107 healthy donors (no disease metric on this slide). 5 donors: LoRA-5 fine-tuned on "
|
| 166 |
+
"5 paired donors, tested on the other 102, 5 draws (dots, bar = mean). 5-fold CV: every donor "
|
| 167 |
+
"generated by the fold model that never trained on it (pooled call), reported separately. "
|
| 168 |
+
"Coverage / precision: k = 10 nearest-neighbour balls on held-out real cells in the scorer's "
|
| 169 |
+
"PCA-50 (Kynkäänniemi 2019; Naeem 2020); composition L1 over six scANVI types. Values: "
|
| 170 |
+
+ "; ".join(f"{m} 5 donors " + ", ".join(f"{L[a]} {m5(m, s):.3f}" for a, s in
|
| 171 |
+
(("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("lora", "lora")))
|
| 172 |
+
+ "; 5-fold " + ", ".join(f"{L[a]} {float(fold_cells[m][a]):.3f}" for a in
|
| 173 |
+
("zs_raw", "zs_cal", "sconly_cal", "lora"))
|
| 174 |
+
for m in ("coverage", "precision", "comp_l1"))
|
| 175 |
+
+ ". Sources: data/sec09_fewpair_cells.csv, data/sec07_ft_modes_accuracy.csv."),
|
| 176 |
+
"refs": ["Kynkäänniemi 2019, NeurIPS", "Naeem 2020, ICML"]})
|
| 177 |
+
# ================================================================ Fig. 2f realism
|
| 178 |
+
fig, axes = plt.subplots(1, 3, figsize=ST.FULL, gridspec_kw={"wspace": 0.3})
|
| 179 |
+
specs = (("c2st_knn_auc", "Classifier AUC (kNN) ↓", False, (0.45, 1.06), "{:.2f}"),
|
| 180 |
+
("mmd2_bw1", "MMD² ↓", False, (0, 0.13), "{:.3f}"), ("en_all_sq", "E_N ↓ (log)", True, (0.2, 20), "{:.1f}"))
|
| 181 |
+
for ax, (m, lab, log, ylim, fmt) in zip(axes, specs):
|
| 182 |
+
few = {a: float(fx[(m, s)].mean()) for a, s in (("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("lora", "lora"))}
|
| 183 |
+
dots = {a: fx[(m, s)] for a, s in (("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("lora", "lora"))}
|
| 184 |
+
fold = {a: vx[(m, s)] for a, s in (("zs_raw", "zs_raw"), ("zs_cal", "zs_cal"), ("sconly_cal", "sconly_cal"),
|
| 185 |
+
("lora", "lora"))}
|
| 186 |
+
two_design_panel(ax, lab, few, fold, ["zs_raw", "zs_cal", "lora"], ["zs_raw", "zs_cal", "sconly_cal", "lora"],
|
| 187 |
+
dots=dots, ref=float(fx[(m, "ref_control")].mean()), fmt=fmt, log=log, ylim=ylim)
|
| 188 |
+
for a, v in few.items():
|
| 189 |
+
rec("2f", m, a, v, "data/sec09_extra_fewpair.csv", "5 donors (mean of 5 draws)")
|
| 190 |
+
for a, v in fold.items():
|
| 191 |
+
rec("2f", m, a, v, "data/sec09_extra_fivefold.csv", "5-fold pooled")
|
| 192 |
+
legend(fig, ["zs_raw", "zs_cal", "sconly_cal", "lora"], extra=[(Line2D([0], [0], ls=(0, (3, 2)), color=ST.INK),
|
| 193 |
+
"Real vs real (same donors)")])
|
| 194 |
+
ST.save(fig, "fig2_healthy_realism", FIG)
|
| 195 |
+
auc = float(fx[("c2st_knn_auc", "lora")].mean())
|
| 196 |
+
slides.append({"title": "Healthy cohort: realism beyond precision/coverage", "figure": "fig2_healthy_realism",
|
| 197 |
+
"keywords": [f"Every metric: LoRA best of the PBISC versions",
|
| 198 |
+
f"E_N {float(fx[('en_all_sq', 'lora')].mean()):.1f} vs zero-shot "
|
| 199 |
+
f"{float(fx[('en_all_sq', 'zs_raw')].mean()):.1f} (5 donors)",
|
| 200 |
+
f"Classifier AUC {auc:.2f}: still separable"],
|
| 201 |
+
"short": "ImMicro, 107 healthy donors. Dashed = real vs real cells of the same donors.",
|
| 202 |
+
"full": ("ImMicro. Classifier two-sample test (kNN, 5-fold CV ROC AUC; 0.5 = indistinguishable; "
|
| 203 |
+
"Lopez-Paz & Oquab 2017), MMD² (RBF, median bandwidth; Gretton 2012) and scSemiProfiler's E_N "
|
| 204 |
+
"(Wang 2024), all on the scorer's cells and embedding. Dashed: real vs real (held-out cells of "
|
| 205 |
+
"the same donors). 5 donors: mean of 5 draws (dots); 5-fold reported separately. "
|
| 206 |
+
"Source: data/sec09_extra_fewpair.csv, data/sec09_extra_fivefold.csv."),
|
| 207 |
+
"refs": ["Lopez-Paz 2017, ICLR", "Gretton 2012, JMLR"]})
|
| 208 |
+
if not all(float(fx[(m, "lora")].mean()) < min(float(fx[(m, s)].mean()) for s in ("zs_raw", "zs_cal"))
|
| 209 |
+
for m in ("c2st_knn_auc", "mmd2_bw1", "en_all_sq")):
|
| 210 |
+
slides[-1]["keywords"][0] = "LoRA best on most metrics (see notes)"
|
| 211 |
+
# ================================================================ Fig. 2g fine-tuning modes
|
| 212 |
+
cp = pd.read_csv(DAT / "sec07_ft_modes_compute.csv")
|
| 213 |
+
cp = cp[cp.dataset == DS].set_index("arm")
|
| 214 |
+
fig, axes = plt.subplots(1, 4, figsize=ST.FULL, gridspec_kw={"wspace": 0.42, "width_ratios": [1, 1, 1, 1.1]})
|
| 215 |
+
grp = [("pooled", ["real_full__raw", "real_lora__raw"], "5-fold"),
|
| 216 |
+
("fold0", ["real_full__raw", "real_lora__raw", "real_condenc__raw"], "fold 0")]
|
| 217 |
+
key = {"real_full__raw": "full", "real_lora__raw": "lora", "real_condenc__raw": "condenc"}
|
| 218 |
+
for ax, (m, lab, ylim) in zip(axes[:3], (("comp_l1", "Composition L1 ↓", (0, 0.26)), ("coverage", "Coverage ↑", (0, 1.05)),
|
| 219 |
+
("precision", "Precision ↑", (0, 1.1)))):
|
| 220 |
+
ax.set_ylim(*ylim)
|
| 221 |
+
for gi, (call, arms, glab) in enumerate(grp):
|
| 222 |
+
vals = {key[a]: float(md.loc[(call, a), m]) for a in arms}
|
| 223 |
+
bar_group(ax, gi * 1.1, [key[a] for a in arms], vals, w=0.24)
|
| 224 |
+
for a, v in vals.items():
|
| 225 |
+
rec("2g", m, a, v, "data/sec07_ft_modes_accuracy.csv", call)
|
| 226 |
+
ax.set_xticks([0, 1.1], ["5-fold\npooled", "fold-0\npilot"], fontsize=ST.FS - 3)
|
| 227 |
+
ax.set_title(lab, fontsize=ST.FS - 1, loc="left")
|
| 228 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 229 |
+
ax.set_axisbelow(True)
|
| 230 |
+
ax = axes[3]
|
| 231 |
+
for i, a in enumerate(["real_full__raw", "real_lora__raw", "real_condenc__raw"]):
|
| 232 |
+
v = float(cp.loc[a, "n_trainable"]) / 1e6
|
| 233 |
+
ax.barh(i, v, 0.6, color=C[key[a]], edgecolor="none")
|
| 234 |
+
ax.text(v * 1.2, i, f"{L[key[a]]}\n{v:.1f} M", va="center", fontsize=ST.FS - 5, color=ST.SUBINK)
|
| 235 |
+
rec("2g", "trainable_M", key[a], v, "data/sec07_ft_modes_compute.csv")
|
| 236 |
+
ax.set_xscale("log")
|
| 237 |
+
ax.set_xlim(0.5, 3000)
|
| 238 |
+
ax.set_yticks([])
|
| 239 |
+
ax.set_ylim(2.6, -0.6)
|
| 240 |
+
ax.set_title("Trainable weights", fontsize=ST.FS - 1, loc="left")
|
| 241 |
+
ax.tick_params(axis="y", length=0)
|
| 242 |
+
legend(fig, ["full", "lora", "condenc"])
|
| 243 |
+
ST.save(fig, "fig2_healthy_modes", FIG)
|
| 244 |
+
ratio = float(cp.loc["real_full__raw", "n_trainable"]) / float(cp.loc["real_lora__raw", "n_trainable"])
|
| 245 |
+
slides.append({"title": "Healthy cohort: full vs LoRA vs condition encoder", "figure": "fig2_healthy_modes",
|
| 246 |
+
"keywords": [f"LoRA ≈ full fine-tune with {ratio:.0f}× fewer weights",
|
| 247 |
+
f"LoRA coverage {md.loc[('pooled', 'real_lora__raw'), 'coverage']:.2f} vs full "
|
| 248 |
+
f"{md.loc[('pooled', 'real_full__raw'), 'coverage']:.2f} (5-fold)",
|
| 249 |
+
"Condition encoder alone falls short"],
|
| 250 |
+
"short": "ImMicro, 107 healthy donors; cond.-encoder-only ran on fold 0 (22 donors) only.",
|
| 251 |
+
"full": ("ImMicro. Full fine-tune trains all 54.2 M weights; LoRA r16 1.30 M; condition-encoder-only "
|
| 252 |
+
"9.48 M (fold 0 pilot only). Values: " + "; ".join(
|
| 253 |
+
f"{call} {L[key[a]]}: L1 {md.loc[(call, a), 'comp_l1']:.3f}, coverage "
|
| 254 |
+
f"{md.loc[(call, a), 'coverage']:.3f}, precision {md.loc[(call, a), 'precision']:.3f}"
|
| 255 |
+
for call, arms, _g in grp for a in arms)
|
| 256 |
+
+ ". Source: data/sec07_ft_modes_accuracy.csv, data/sec07_ft_modes_compute.csv."),
|
| 257 |
+
"refs": ["Hu 2022, ICLR"]})
|
| 258 |
+
# ================================================================ Fig. 2h pairs needed (ImMicro, no scSemiProfiler)
|
| 259 |
+
pr = pd.read_csv(DAT / "sec08_pairs_realism.csv", dtype={"pairs": str})
|
| 260 |
+
pr = pr[(pr.dataset == DS) & (pr.panel != "meta") & pr.pairs.notna()].copy()
|
| 261 |
+
pr["value"] = pr.value.astype(float)
|
| 262 |
+
ps = pd.read_csv(DAT / "sec08_pairs_signal.csv", dtype={"pairs": str})
|
| 263 |
+
ps = ps[(ps.dataset == DS) & (ps.panel == "nk_fraction_r") & ps.pairs.notna()].copy()
|
| 264 |
+
ps["value"] = ps.value.astype(float)
|
| 265 |
+
st = pd.read_csv(DAT / "sec08_selected_steps_per_fold.csv")
|
| 266 |
+
st = st[st.dataset == DS]
|
| 267 |
+
xs = {"0": 0, "5": 1, "10": 2, "20": 3, "40": 4, "all": 5}
|
| 268 |
+
fig, axes = plt.subplots(1, 4, figsize=ST.FULL, gridspec_kw={"wspace": 0.38})
|
| 269 |
+
for ax, (src, m, lab) in zip(axes[:3], ((pr, "comp_l1", "Composition L1 ↓"), (pr, "coverage", "Coverage ↑"),
|
| 270 |
+
(ps, "nk_fraction_r", "Donor NK fraction r ↑"))):
|
| 271 |
+
d = src[src.panel == m] if "panel" in src and m != "nk_fraction_r" else src
|
| 272 |
+
for ser, col, mk, lab2 in (("zero_shot", C["zs_raw"], "o", "zero-shot"), ("zs_cal_budget", C["zs_cal"], "s", "calibration"),
|
| 273 |
+
("lora", C["lora"], "o", "LoRA")):
|
| 274 |
+
q = d[d.series == ser]
|
| 275 |
+
x = [xs[str(p)] for p in q.pairs]
|
| 276 |
+
ax.plot(x, q.value, color=col, marker=mk, lw=2 if ser == "lora" else 1.5, ms=7, mec=ST.INK, mew=0.5)
|
| 277 |
+
for p, v in zip(q.pairs, q.value):
|
| 278 |
+
rec("2h", m, ser, v, "data/sec08_pairs_realism.csv" if m != "nk_fraction_r" else "data/sec08_pairs_signal.csv",
|
| 279 |
+
extra=f"pairs {p}")
|
| 280 |
+
ax.set_xticks(list(xs.values()), ["0", "5", "10", "20", "40", "78–79"], fontsize=ST.FS - 4)
|
| 281 |
+
ax.set_title(lab, fontsize=ST.FS - 1, loc="left")
|
| 282 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 283 |
+
ax.set_axisbelow(True)
|
| 284 |
+
ax = axes[3]
|
| 285 |
+
order = [("lora_n5", "5"), ("lora_n10", "10"), ("lora_n20", "20"), ("lora_n40", "40"), ("real_lora", "all")]
|
| 286 |
+
for a, p in order:
|
| 287 |
+
v = st[st.arm == a].selected_step.to_numpy() / 1000
|
| 288 |
+
ax.scatter(np.full(len(v), xs[p]) + np.linspace(-0.12, 0.12, len(v)), v, s=22, color=C["lora"], edgecolor=ST.INK,
|
| 289 |
+
lw=0.5, zorder=3)
|
| 290 |
+
ax.plot([xs[p] - 0.25, xs[p] + 0.25], [np.median(v)] * 2, color=ST.INK, lw=2)
|
| 291 |
+
rec("2h", "selected_step_median_k", "lora", float(np.median(v)), "data/sec08_selected_steps_per_fold.csv",
|
| 292 |
+
extra=f"pairs {p}")
|
| 293 |
+
ax.axhline(20, color=ST.GREY, ls=":", lw=1)
|
| 294 |
+
ax.set_xticks([xs[p] for _a, p in order], ["5", "10", "20", "40", "78–79"], fontsize=ST.FS - 4)
|
| 295 |
+
ax.set_ylim(0, 22)
|
| 296 |
+
ax.set_title("Selected step (×1,000)", fontsize=ST.FS - 1, loc="left")
|
| 297 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 298 |
+
fig.text(0.5, -0.02, "Training pairs per fold (0 = no pairs; each run +7 inner-val pairs for early stopping)",
|
| 299 |
+
ha="center", fontsize=ST.FS - 3)
|
| 300 |
+
h = [Line2D([0], [0], color=C[k], marker=mk, lw=2, mec=ST.INK, mew=0.5) for k, mk in (("zs_raw", "o"), ("zs_cal", "s"), ("lora", "o"))]
|
| 301 |
+
fig.legend(h, ["Zero-shot, real bulk", "Zero-shot + calibration (same pairs)", "PBISC LoRA"], loc="upper center",
|
| 302 |
+
ncol=3, bbox_to_anchor=(0.5, 1.07), fontsize=ST.FS - 3)
|
| 303 |
+
ST.save(fig, "fig2_healthy_pairs", FIG)
|
| 304 |
+
lc = pr[(pr.panel == "coverage") & (pr.series == "lora")].set_index("pairs").value
|
| 305 |
+
nk = ps[ps.series == "lora"].set_index("pairs").value
|
| 306 |
+
slides.append({"title": "Healthy cohort: how many pairs", "figure": "fig2_healthy_pairs",
|
| 307 |
+
"keywords": [f"5 pairs: coverage {lc.loc['5']:.2f} (zero-shot "
|
| 308 |
+
f"{float(pr[(pr.panel == 'coverage') & (pr.series == 'zero_shot')].value.iloc[0]):.2f})",
|
| 309 |
+
f"Donor NK fraction r {nk.loc['5']:.2f} → {nk.loc['all']:.2f} with more pairs",
|
| 310 |
+
"5 pairs stop early, near 3,000 steps"],
|
| 311 |
+
"short": "ImMicro, 107 donors, 5-fold CV pooled at each pair count. 0 = no pairs.",
|
| 312 |
+
"full": ("ImMicro, donor-level 5-fold CV, pooled scoring (107 donors); x = LoRA training pairs per fold "
|
| 313 |
+
"(the last point is every training donor of the fold, 78-79). Calibration fitted on exactly the "
|
| 314 |
+
"pairs the LoRA point saw. Selected step = early-stopping step on 7 inner-validation pairs (cap "
|
| 315 |
+
"20,000). Values: coverage LoRA " + " / ".join(f"{v:.2f}" for v in lc.values) + "; NK fraction r "
|
| 316 |
+
"LoRA " + " / ".join(f"{v:.2f}" for v in nk.values) + " at 5 / 10 / 20 / 40 / all pairs. "
|
| 317 |
+
"Source: data/sec08_pairs_realism.csv, data/sec08_pairs_signal.csv, "
|
| 318 |
+
"data/sec08_selected_steps_per_fold.csv.").replace("78-79", "78–79"),
|
| 319 |
+
"refs": ["Kynkäänniemi 2019, NeurIPS", "Naeem 2020, ICML"]})
|
| 320 |
+
# ================================================================ Fig. 2i rank and K
|
| 321 |
+
rk = pd.read_csv(DAT / "sec07_rank_sweep.csv")
|
| 322 |
+
rk = rk[(rk.dataset == DS) & rk.metric.isin(["comp_l1", "coverage", "precision"])]
|
| 323 |
+
ka = pd.read_csv(DAT / "sec07_k_aug.csv")
|
| 324 |
+
ka = ka[ka.dataset == DS].set_index("arm")
|
| 325 |
+
fig, axes = plt.subplots(1, 3, figsize=ST.FULL, gridspec_kw={"wspace": 0.3})
|
| 326 |
+
rc = {4: "#F3C9A8", 16: C["lora"], 64: "#7A2E00"}
|
| 327 |
+
for ax, (m, lab) in zip(axes, (("comp_l1", "Composition L1 ↓"), ("coverage", "Coverage ↑"), ("precision", "Precision ↑"))):
|
| 328 |
+
for r in (4, 16, 64):
|
| 329 |
+
q = rk[(rk["rank"] == r) & (rk.metric == m)]
|
| 330 |
+
x = [{"5": 0, "20": 1, "all": 2}[str(p)] for p in q.pairs]
|
| 331 |
+
ax.plot(x, q.value, color=rc[r], marker="o", lw=2.2 if r == 16 else 1.5, ms=7, mec=ST.INK, mew=0.5)
|
| 332 |
+
for p, v in zip(q.pairs, q.value):
|
| 333 |
+
rec("2i", m, f"lora_r{r}", v, "data/sec07_rank_sweep.csv", extra=f"pairs {p}")
|
| 334 |
+
for arm, mk in (("lora_multik__raw", "D"), ("lora_recipe__raw", "^")):
|
| 335 |
+
ax.scatter([2.15], [ka.loc[arm, m]], marker=mk, s=60, color="white", edgecolor=C["lora"], lw=1.5, zorder=4)
|
| 336 |
+
rec("2i", m, arm, float(ka.loc[arm, m]), "data/sec07_k_aug.csv", extra="pairs all")
|
| 337 |
+
ax.set_xticks([0, 1, 2], ["5", "20", "78–79"], fontsize=ST.FS - 3)
|
| 338 |
+
ax.set_xlim(-0.3, 2.4)
|
| 339 |
+
ax.set_title(lab, fontsize=ST.FS - 1, loc="left")
|
| 340 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 341 |
+
ax.set_axisbelow(True)
|
| 342 |
+
h = [Line2D([0], [0], color=rc[r], marker="o", lw=2, mec=ST.INK, mew=0.5) for r in (4, 16, 64)]
|
| 343 |
+
h += [Line2D([0], [0], marker=mk, ls="none", color="white", mec=C["lora"], mew=1.5, ms=8) for mk in ("D", "^")]
|
| 344 |
+
fig.legend(h, ["LoRA r = 4", "LoRA r = 16 (used)", "LoRA r = 64", "multi-K (all pairs)", "+ recipes (all pairs)"],
|
| 345 |
+
loc="lower center", ncol=5, bbox_to_anchor=(0.5, -0.08), fontsize=ST.FS - 3)
|
| 346 |
+
fig.text(0.5, 0.0, "Training pairs per fold (5-fold CV, pooled)", ha="center", fontsize=ST.FS - 3)
|
| 347 |
+
ST.save(fig, "fig2_healthy_rank", FIG)
|
| 348 |
+
rv = rk.set_index(["rank", "pairs", "metric"]).value
|
| 349 |
+
slides.append({"title": "Healthy cohort: LoRA rank and K", "figure": "fig2_healthy_rank",
|
| 350 |
+
"keywords": [f"r64 vs r16: coverage {rv.loc[(16, 'all', 'coverage')]:.2f} → {rv.loc[(64, 'all', 'coverage')]:.2f}",
|
| 351 |
+
f"r4 vs r16: L1 {rv.loc[(16, 'all', 'comp_l1')]:.3f} → {rv.loc[(4, 'all', 'comp_l1')]:.3f}",
|
| 352 |
+
"Multi-K, recipes: no gain; kept r16, K 1,000"],
|
| 353 |
+
"short": "ImMicro, 107 donors, 5-fold CV pooled. Open symbols: K choices with every training pair.",
|
| 354 |
+
"full": ("ImMicro, 5-fold CV pooled. LoRA rank 4 / 16 / 64 at 5, 20 and all training pairs; multi-K "
|
| 355 |
+
"(K = 250-4,000 conditions) and half-batch recipes with every training pair. Kept: r = 16, "
|
| 356 |
+
"K = 1,000. Source: data/sec07_rank_sweep.csv, data/sec07_k_aug.csv.").replace("250-4,000", "250–4,000"),
|
| 357 |
+
"refs": ["Hu 2022, ICLR"]})
|
| 358 |
+
# ================================================================ Fig. 3a 5 donors vs scSemiProfiler (healthy)
|
| 359 |
+
fig, axes = plt.subplots(1, 6, figsize=ST.FULL, gridspec_kw={"wspace": 0.55})
|
| 360 |
+
arms = [("zs_raw", "zs_raw"), ("scsemi", "scsemi5"), ("lora", "lora")]
|
| 361 |
+
panels = (("coverage", "Coverage ↑", fc, (0, 1.05), False, "{:.2f}"), ("precision", "Precision ↑", fc, (0, 1.1), False, "{:.2f}"),
|
| 362 |
+
("comp_l1", "Comp. L1 ↓", fc, (0, 0.55), False, "{:.2f}"),
|
| 363 |
+
("c2st_knn_auc", "Classifier AUC ↓", fx, (0.45, 1.06), False, "{:.2f}"),
|
| 364 |
+
("mmd2_bw1", "MMD² ↓", fx, (0, 0.24), False, "{:.3f}"), ("en_all_sq", "E_N ↓ (log)", fx, (0.2, 20), True, "{:.1f}"))
|
| 365 |
+
win = 0
|
| 366 |
+
for ax, (m, lab, src, ylim, log, fmt) in zip(axes, panels):
|
| 367 |
+
if log:
|
| 368 |
+
ax.set_yscale("log")
|
| 369 |
+
ax.set_ylim(*ylim)
|
| 370 |
+
vals = {a: float(src[(m, s)].mean()) for a, s in arms}
|
| 371 |
+
bar_group(ax, 0, [a for a, _ in arms], vals, w=0.28, dots={a: src[(m, s)] for a, s in arms}, fmt=fmt, log=log)
|
| 372 |
+
if m in ("c2st_knn_auc", "mmd2_bw1", "en_all_sq"):
|
| 373 |
+
ax.axhline(float(fx[(m, "ref_control")].mean()), color=ST.INK, ls=(0, (3, 2)), lw=1)
|
| 374 |
+
better = vals["lora"] > vals["scsemi"] if m in ("coverage", "precision") else vals["lora"] < vals["scsemi"]
|
| 375 |
+
win += int(better)
|
| 376 |
+
ax.set_xticks([])
|
| 377 |
+
ax.set_title(lab, fontsize=ST.FS - 2, loc="left")
|
| 378 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 379 |
+
ax.set_axisbelow(True)
|
| 380 |
+
for a, v in vals.items():
|
| 381 |
+
rec("3a", m, a, v, "data/sec09_fewpair_cells.csv" if src is fc else "data/sec09_extra_fewpair.csv",
|
| 382 |
+
"5 donors (mean of 5 draws)")
|
| 383 |
+
legend(fig, ["zs_raw", "scsemi", "lora"], extra=[(Line2D([0], [0], ls=(0, (3, 2)), color=ST.INK), "Real vs real")])
|
| 384 |
+
ST.save(fig, "fig3_healthy_fewpair", FIG)
|
| 385 |
+
slides.append({"title": "Healthy donors, 5 pairs: LoRA-5 vs scSemiProfiler-5", "figure": "fig3_healthy_fewpair",
|
| 386 |
+
"keywords": [f"LoRA-5 ahead on {win} of 6 metrics",
|
| 387 |
+
f"Coverage {m5('coverage', 'lora'):.2f} vs {m5('coverage', 'scsemi5'):.2f}",
|
| 388 |
+
f"E_N {float(fx[('en_all_sq', 'lora')].mean()):.1f} vs "
|
| 389 |
+
f"{float(fx[('en_all_sq', 'scsemi5')].mean()):.1f} (scSemiProfiler's own metric)"],
|
| 390 |
+
"short": "ImMicro, 107 healthy donors; same 5 donors for both methods, 5 draws (dots).",
|
| 391 |
+
"full": ("Main comparison on healthy donors: per draw, LoRA-5 and scSemiProfiler get the same 5 paired "
|
| 392 |
+
"donors (scSemiProfiler: as its representatives) and are tested on the other 102 from their real "
|
| 393 |
+
"bulk; 5 draws. Zero-shot (no pairs) shown for reference. Dashed: real vs real cells. Values "
|
| 394 |
+
"(LoRA-5 / scSemiProfiler-5): " + "; ".join(
|
| 395 |
+
f"{m} {float(src[(m, 'lora')].mean()):.3f} / {float(src[(m, 'scsemi5')].mean()):.3f}"
|
| 396 |
+
for m, _l, src, *_ in panels)
|
| 397 |
+
+ ". Source: data/sec09_fewpair_cells.csv, data/sec09_extra_fewpair.csv."),
|
| 398 |
+
"refs": ["Wang 2024, Nat Commun", "Lopez-Paz 2017, ICLR"]})
|
| 399 |
+
# ================================================================ Fig. 3b equal pairs 5..all (healthy)
|
| 400 |
+
fig, axes = plt.subplots(1, 3, figsize=ST.FULL, gridspec_kw={"wspace": 0.3})
|
| 401 |
+
xs2 = {"5": 0, "10": 1, "20": 2, "40": 3, "all": 4.2}
|
| 402 |
+
for ax, (src, m, lab) in zip(axes, ((pr, "comp_l1", "Composition L1 ↓"), (pr, "coverage", "Coverage ↑"),
|
| 403 |
+
(ps, "nk_fraction_r", "Donor NK fraction r ↑"))):
|
| 404 |
+
d = src[src.panel == m] if m != "nk_fraction_r" else src
|
| 405 |
+
for ser, col in (("scsemi", C["scsemi"]), ("lora", C["lora"])):
|
| 406 |
+
q = d[d.series == ser].set_index("pairs").value
|
| 407 |
+
q.index = q.index.astype(str)
|
| 408 |
+
x = [xs2[p] for p in ("5", "10", "20", "40")]
|
| 409 |
+
ax.plot(x, [q[p] for p in ("5", "10", "20", "40")], color=col, marker="D" if ser == "scsemi" else "o",
|
| 410 |
+
lw=2, ms=7, mec=ST.INK, mew=0.5)
|
| 411 |
+
ax.scatter([xs2["all"]], [q["all"]], marker="D" if ser == "scsemi" else "o", s=60, color="white",
|
| 412 |
+
edgecolor=col, lw=2, zorder=4)
|
| 413 |
+
for p, v in q.items():
|
| 414 |
+
rec("3b", m, ser, v, "data/sec08_pairs_realism.csv" if m != "nk_fraction_r" else "data/sec08_pairs_signal.csv",
|
| 415 |
+
extra=f"pairs {p}")
|
| 416 |
+
ax.axvline(3.6, color=ST.GREY, ls=":", lw=1)
|
| 417 |
+
ax.set_xticks(list(xs2.values()), ["5", "10", "20", "40", "all\n(5-fold)"], fontsize=ST.FS - 4)
|
| 418 |
+
ax.set_title(lab, fontsize=ST.FS - 1, loc="left")
|
| 419 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8)
|
| 420 |
+
ax.set_axisbelow(True)
|
| 421 |
+
h = [Line2D([0], [0], color=C["scsemi"], marker="D", lw=2, mec=ST.INK, mew=0.5),
|
| 422 |
+
Line2D([0], [0], color=C["lora"], marker="o", lw=2, mec=ST.INK, mew=0.5)]
|
| 423 |
+
fig.legend(h, ["scSemiProfiler, the same n pairs as representatives", "PBISC LoRA, n training pairs"],
|
| 424 |
+
loc="lower center", ncol=2, bbox_to_anchor=(0.5, -0.08), fontsize=ST.FS - 3)
|
| 425 |
+
ST.save(fig, "fig3_healthy_pairs", FIG)
|
| 426 |
+
sc_cov = pr[(pr.panel == "coverage") & (pr.series == "scsemi")].value
|
| 427 |
+
lo_cov = pr[(pr.panel == "coverage") & (pr.series == "lora")].value
|
| 428 |
+
slides.append({"title": "Healthy donors: the same pairs, 5 to all", "figure": "fig3_healthy_pairs",
|
| 429 |
+
"keywords": [f"Coverage at every n: LoRA {rng(lo_cov)}, scSemiProfiler {rng(sc_cov)}",
|
| 430 |
+
"Composition L1 lower for LoRA at every n",
|
| 431 |
+
f"5-fold: LoRA {float(sp.loc[(DS, 'lora'), 'comp_l1']):.2f} vs "
|
| 432 |
+
f"{float(sp.loc[(DS, 'scsemi'), 'comp_l1']):.2f} L1"],
|
| 433 |
+
"short": "ImMicro, 107 donors, 5-fold CV design; scSemiProfiler gets exactly LoRA's pairs.",
|
| 434 |
+
"full": ("ImMicro, donor-level 5-fold CV pooled at each pair count: for every fold, scSemiProfiler's "
|
| 435 |
+
"representatives are exactly the n pairs LoRA trained on (plus the inner-validation pairs); "
|
| 436 |
+
"'all' (open symbols, right of the dotted line) = every training donor of the fold, i.e. the "
|
| 437 |
+
"5-fold result, reported separately from the 5-pair comparison. Source: data/sec08_pairs_realism.csv, "
|
| 438 |
+
"data/sec08_pairs_signal.csv, data/sec09_same_pairs.csv."),
|
| 439 |
+
"refs": ["Wang 2024, Nat Commun"]})
|
| 440 |
+
if not all(pr[(pr.panel == "comp_l1") & (pr.series == "lora")].set_index("pairs").value.astype(float)
|
| 441 |
+
< pr[(pr.panel == "comp_l1") & (pr.series == "scsemi")].set_index("pairs").value.astype(float)):
|
| 442 |
+
slides[-1]["keywords"][1] = "Composition L1: see notes"
|
| 443 |
+
# ================================================================ Fig. 3c copies its representative (healthy)
|
| 444 |
+
rp = pd.read_csv(DAT / "sec09_scsemi_representative.csv")
|
| 445 |
+
rp = rp[rp.cohort == DS]
|
| 446 |
+
a_ = rp[rp.panel == "a"]
|
| 447 |
+
b_ = rp[rp.panel == "b"].set_index("series").value
|
| 448 |
+
fig, (a1, a2) = plt.subplots(1, 2, figsize=ST.FULL, gridspec_kw={"wspace": 0.35, "width_ratios": [1.3, 1]})
|
| 449 |
+
a1.set_ylim(0, 0.3)
|
| 450 |
+
cc = {"copy": ST.GREY, "scsemi": C["scsemi"], "lora": C["lora"]}
|
| 451 |
+
for i, s in enumerate(("copy", "scsemi", "lora")):
|
| 452 |
+
v = a_[a_.series == s].value.to_numpy()
|
| 453 |
+
a1.bar(i, v.mean(), 0.6, color=cc[s], edgecolor="none")
|
| 454 |
+
a1.scatter(np.full(len(v), i) + np.linspace(-0.1, 0.1, len(v)), v, s=14, color="white", edgecolor=ST.INK, lw=0.5,
|
| 455 |
+
zorder=3)
|
| 456 |
+
a1.text(i, v.mean() + 0.008, f"{v.mean():.3f}", ha="center", fontsize=ST.FS - 4, color=ST.SUBINK)
|
| 457 |
+
rec("3c", "comp_l1", s, v.mean(), "data/sec09_scsemi_representative.csv", "5 donors (mean of 5 draws)")
|
| 458 |
+
a1.set_xticks(range(3), ["Copy the\nrepresentative", "scSemiProfiler", "PBISC LoRA"], fontsize=ST.FS - 3)
|
| 459 |
+
a1.set_title("Composition L1 ↓ (5 donors)", fontsize=ST.FS - 1, loc="left")
|
| 460 |
+
for i, s in enumerate(("scsemi", "lora")):
|
| 461 |
+
a2.barh(i, b_[s], 0.55, color=cc[s], edgecolor="none")
|
| 462 |
+
a2.text(b_[s] + 0.02, i, f"{b_[s]:.2f}", va="center", fontsize=ST.FS - 4, color=ST.SUBINK)
|
| 463 |
+
rec("3c", "spearman_with_copy_error", s, b_[s], "data/sec09_scsemi_representative.csv")
|
| 464 |
+
a2.set_yticks([0, 1], ["scSemiProfiler", "PBISC LoRA"], fontsize=ST.FS - 3)
|
| 465 |
+
a2.set_xlim(0, 1)
|
| 466 |
+
a2.set_ylim(1.6, -0.6)
|
| 467 |
+
a2.set_title("Error tracks the copy's error (Spearman)", fontsize=ST.FS - 1, loc="left")
|
| 468 |
+
for ax in (a1, a2):
|
| 469 |
+
ax.grid(axis="y" if ax is a1 else "x", color="#E3E3E3", linewidth=0.8)
|
| 470 |
+
ax.set_axisbelow(True)
|
| 471 |
+
ST.save(fig, "fig3_healthy_copy", FIG)
|
| 472 |
+
cm = {s: float(a_[a_.series == s].value.mean()) for s in ("copy", "scsemi", "lora")}
|
| 473 |
+
slides.append({"title": "Healthy donors: scSemiProfiler copies its representative", "figure": "fig3_healthy_copy",
|
| 474 |
+
"keywords": [f"scSemiProfiler {cm['scsemi']:.3f} vs copying {cm['copy']:.3f} (L1)",
|
| 475 |
+
f"Its error tracks the copy's: ρ {b_['scsemi']:.2f}",
|
| 476 |
+
f"LoRA-5 below the copy: {cm['lora']:.3f}"],
|
| 477 |
+
"short": "ImMicro, 102 test donors per draw, 5 draws. Copy = the assigned representative's composition.",
|
| 478 |
+
"full": ("ImMicro, 5 donors. scSemiProfiler assigns each test sample one representative; 'copy' uses that "
|
| 479 |
+
"representative's observed composition as the prediction. Right: Spearman over test samples "
|
| 480 |
+
"between each method's composition error and the copy's error. Source: "
|
| 481 |
+
"data/sec09_scsemi_representative.csv (scsemi/analysis/representative_dependence_20261002)."),
|
| 482 |
+
"refs": ["Wang 2024, Nat Commun"]})
|
| 483 |
+
# ------------------------------------------------------------------ text
|
| 484 |
+
out_slides = []
|
| 485 |
+
for s in slides:
|
| 486 |
+
if len(s["short"]) > 110:
|
| 487 |
+
raise SystemExit(f"short footnote too long: {s['title']}")
|
| 488 |
+
out_slides.append({"title": s["title"], "layout": "full", "figures": [str(FIG / f"{s['figure']}.png")],
|
| 489 |
+
"keywords": s["keywords"], "footnote_short": s["short"], "footnote": s["full"],
|
| 490 |
+
"refs": s["refs"], "refs_full": refs(s["refs"]),
|
| 491 |
+
"numbers": [{"value": "; ".join(f"{r['design'] or r['extra']} {r['metric']} {r['series']} "
|
| 492 |
+
f"{r['value']:.4g}" for r in ROWS if r["slide"] == sl),
|
| 493 |
+
"source": "data/fig23_healthy.csv"}
|
| 494 |
+
for sl in [{"fig2_healthy_cells": "2e", "fig2_healthy_realism": "2f",
|
| 495 |
+
"fig2_healthy_modes": "2g", "fig2_healthy_pairs": "2h",
|
| 496 |
+
"fig2_healthy_rank": "2i", "fig3_healthy_fewpair": "3a",
|
| 497 |
+
"fig3_healthy_pairs": "3b", "fig3_healthy_copy": "3c"}[s["figure"]]]]})
|
| 498 |
+
pd.DataFrame(ROWS).to_csv(DAT / "fig23_healthy.csv", index=False, float_format="%.6g")
|
| 499 |
+
(DAT / "fig23_healthy_slide_text.json").write_text(json.dumps(
|
| 500 |
+
{"section": "fig23-healthy", "scripts": [str(Path(__file__).resolve())],
|
| 501 |
+
"generated_from": "tools/fig23_healthy.py (rerun to refresh; do not edit by hand)", "slides": out_slides},
|
| 502 |
+
indent=1, ensure_ascii=False))
|
| 503 |
+
for s in out_slides:
|
| 504 |
+
print(s["title"], "|", " | ".join(s["keywords"]))
|
| 505 |
+
return 0
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
if __name__ == "__main__":
|
| 509 |
+
sys.exit(main())
|