Archive 4 checkpoints (1-4)
Browse files- .gitattributes +2 -0
- 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.pdf +3 -0
- 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 +3 -0
- paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md +260 -0
- paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/fig3_time_days.py +194 -0
.gitattributes
CHANGED
|
@@ -102,3 +102,5 @@ paper-releases/pbisc-diffusion/updates/20261008T022410Z-deconv-scsemi-deck/diffu
|
|
| 102 |
paper-releases/pbisc-diffusion/updates/20261008T022410Z-deconv-scsemi-deck/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
|
| 103 |
paper-releases/pbisc-diffusion/updates/20261008T050202Z-scsemi-imperial-deck/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
|
| 104 |
paper-releases/pbisc-diffusion/updates/20261008T050202Z-scsemi-imperial-deck/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
|
|
|
|
|
|
|
|
|
| 102 |
paper-releases/pbisc-diffusion/updates/20261008T022410Z-deconv-scsemi-deck/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
|
| 103 |
paper-releases/pbisc-diffusion/updates/20261008T050202Z-scsemi-imperial-deck/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
|
| 104 |
paper-releases/pbisc-diffusion/updates/20261008T050202Z-scsemi-imperial-deck/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
|
| 105 |
+
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.pdf 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
|
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.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:486e79f898c1787f15b587a8c45917824e799191e86e17cb42c093419388835a
|
| 3 |
+
size 9495220
|
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
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5621810db8844be7a617b204d5bc2788a48d35e93e83067d487643c142b5c75
|
| 3 |
+
size 10427532
|
paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PBISC-Diffusion paper summary deck (2026-09-30, r00; ordered by the six manuscript figures since 2026-10-06)
|
| 2 |
+
|
| 3 |
+
65-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 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).
|
paper-releases/pbisc-diffusion/updates/20261008T060837Z-deck-new-figure-split-time/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/fig3_time_days.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Fig. 3 time slide of the 2026-09-30 paper-summary deck: what one experiment costs, scSemiProfiler vs PBISC LoRA
|
| 3 |
+
(2026-10-08; user request: time is a main result, scSemiProfiler takes days per experiment, show it in numbers).
|
| 4 |
+
|
| 5 |
+
CPU only, plotting only. Same GB10 GPU type for both methods, every step alone on the GPU.
|
| 6 |
+
5-fold CV per cohort data/sec09_same_pairs.csv (tools/sec09_same_pairs.py): GPU hours per fold model, mean over
|
| 7 |
+
the 5 folds (LoRA = fine-tune + sampling 1,500 cells per test sample; scSemiProfiler = every
|
| 8 |
+
representative's two pretraining stages + one model per test sample, from its receipts).
|
| 9 |
+
One experiment = the 5 fold models (mean x 5).
|
| 10 |
+
5-donor draws data/sec09_time_to_apply.csv (tools/sec09_time_to_apply.py), minutes per draw, 5 draws.
|
| 11 |
+
PBISC pretraining data/sec06_ft_method.csv pretrain_wall_hours: done once, reused by every cohort.
|
| 12 |
+
scSemiProfiler running time (wall clock, CPU steps included): scsemi/work/<cohort>/cv/fold<k>/events.jsonl on the
|
| 13 |
+
host that ran each fold; gaps over 30 min between events (waiting for the GPU lock) excluded.
|
| 14 |
+
Not counted on either side: data preparation before the runs, scoring. The equal-pair-budget scSemiProfiler runs are
|
| 15 |
+
left out: they reuse the representative models of the 5-fold run, so their receipts understate a fresh run.
|
| 16 |
+
Outputs: figures/fig3_time_days.{png,pdf}, data/fig3_time_days.csv, data/fig3_time_days_slide_text.json
|
| 17 |
+
"""
|
| 18 |
+
from __future__ import annotations
|
| 19 |
+
|
| 20 |
+
import json
|
| 21 |
+
import os
|
| 22 |
+
import subprocess
|
| 23 |
+
import sys
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "" # plotting only
|
| 27 |
+
|
| 28 |
+
import numpy as np
|
| 29 |
+
import pandas as pd
|
| 30 |
+
|
| 31 |
+
DECK = Path(__file__).resolve().parents[1]
|
| 32 |
+
sys.path.insert(0, str(DECK / "tools"))
|
| 33 |
+
import style as ST # noqa: E402
|
| 34 |
+
import matplotlib.pyplot as plt # noqa: E402
|
| 35 |
+
|
| 36 |
+
T = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/plans/paired_finetune_intradataset_20260927")
|
| 37 |
+
FIGDIR, OUTDATA = DECK / "figures", DECK / "data"
|
| 38 |
+
ORDER = ["immicro", "ye2026_sepsis", "imperial_eskd", "giroux2022", "ji2025_chili"]
|
| 39 |
+
NAME = {"immicro": "ImMicro (healthy)", "ye2026_sepsis": "Sepsis", "imperial_eskd": "Imperial", "giroux2022": "Giroux",
|
| 40 |
+
"ji2025_chili": "Ji (whole blood)"}
|
| 41 |
+
COL = {"scsemi": ST.ARM["scsemi"], "lora": ST.ARM["lora"], "pretrain": "#F2B48C"}
|
| 42 |
+
WAIT_S = 1800
|
| 43 |
+
|
| 44 |
+
COLLECT = r'''
|
| 45 |
+
import glob, json, os, sys
|
| 46 |
+
from datetime import datetime
|
| 47 |
+
T = sys.argv[1]; WAIT = float(sys.argv[2]); out = {}
|
| 48 |
+
for p in glob.glob(os.path.join(T, "scsemi", "work", "*", "cv", "fold*", "events.jsonl")):
|
| 49 |
+
ev = []
|
| 50 |
+
for line in open(p):
|
| 51 |
+
try: ev.append(json.loads(line))
|
| 52 |
+
except Exception: pass
|
| 53 |
+
if not ev or ev[-1]["event"] != "infer_call_done": continue
|
| 54 |
+
ts = [datetime.fromisoformat(e["at"]) for e in ev]
|
| 55 |
+
gaps = [(b - a).total_seconds() for a, b in zip(ts, ts[1:])]
|
| 56 |
+
rel = os.path.relpath(os.path.dirname(p), os.path.join(T, "scsemi", "work"))
|
| 57 |
+
out[rel] = {"active_s": sum(g for g in gaps if g <= WAIT), "waits_s": sum(g for g in gaps if g > WAIT),
|
| 58 |
+
"gpu_s": sum(e.get("elapsed_seconds", 0) for e in ev if e["event"] in ("pretrain_complete", "target_complete"))}
|
| 59 |
+
print(json.dumps(out))
|
| 60 |
+
'''
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def collect(host: str) -> dict:
|
| 64 |
+
cmd = ["python3", "-", str(T), str(WAIT_S)]
|
| 65 |
+
if host != "server_1":
|
| 66 |
+
cmd = ["ssh", "spark-0110"] + cmd
|
| 67 |
+
return json.loads(subprocess.run(cmd, input=COLLECT, capture_output=True, text=True, check=True).stdout)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def fmt_h(h: float) -> str:
|
| 71 |
+
if h >= 20:
|
| 72 |
+
d = h / 24
|
| 73 |
+
return f"{h:.0f} h ({d:.1f} day{'' if round(d, 1) == 1.0 else 's'})"
|
| 74 |
+
return f"{h:.1f} h" if h >= 1 else f"{h * 60:.0f} min"
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def main() -> int:
|
| 78 |
+
sp = pd.read_csv(OUTDATA / "sec09_same_pairs.csv").set_index(["dataset", "arm"])
|
| 79 |
+
ta = pd.read_csv(OUTDATA / "sec09_time_to_apply.csv").set_index(["cohort", "method"])
|
| 80 |
+
ft = pd.read_csv(OUTDATA / "sec06_ft_method.csv").set_index("key")
|
| 81 |
+
pre_h = float(ft.loc["pretrain_wall_hours", "value"])
|
| 82 |
+
runs = {}
|
| 83 |
+
for h in ("server_1", "server_2"):
|
| 84 |
+
for k, v in collect(h).items():
|
| 85 |
+
if k in runs:
|
| 86 |
+
raise SystemExit(f"{k}: finished on both hosts")
|
| 87 |
+
runs[k] = v
|
| 88 |
+
rows = []
|
| 89 |
+
for ds in ORDER:
|
| 90 |
+
folds = [runs.get(f"{ds}/cv/fold{k}") for k in range(5)]
|
| 91 |
+
if any(f is None for f in folds):
|
| 92 |
+
raise SystemExit(f"{ds}: scSemiProfiler 5-fold not complete on either host")
|
| 93 |
+
gpu_ev = sum(f["gpu_s"] for f in folds) / 3600
|
| 94 |
+
sc_cv = 5 * float(sp.loc[(ds, "scsemi"), "hours"])
|
| 95 |
+
if abs(gpu_ev - sc_cv) > 0.02 * sc_cv: # same receipts, two read-outs
|
| 96 |
+
raise SystemExit(f"{ds}: event GPU time {gpu_ev:.2f} h differs from sec09_same_pairs {sc_cv:.2f} h")
|
| 97 |
+
rows.append({"cohort": ds, "cv_scsemi_gpu_h": sc_cv, "cv_lora_gpu_h": 5 * float(sp.loc[(ds, "lora"), "hours"]),
|
| 98 |
+
"cv_scsemi_running_h": sum(f["active_s"] for f in folds) / 3600,
|
| 99 |
+
"cv_scsemi_gpu_waits_excluded_h": sum(f["waits_s"] for f in folds) / 3600,
|
| 100 |
+
"draws_scsemi_gpu_h": float(ta.loc[(ds, "scsemi"), "total_min_mean"]) * 5 / 60,
|
| 101 |
+
"draws_lora_gpu_h": float(ta.loc[(ds, "lora"), "total_min_mean"]) * 5 / 60})
|
| 102 |
+
tab = pd.DataFrame(rows)
|
| 103 |
+
tab["cv_ratio"] = tab.cv_scsemi_gpu_h / tab.cv_lora_gpu_h
|
| 104 |
+
tot_sc = tab.cv_scsemi_gpu_h.sum() + tab.draws_scsemi_gpu_h.sum()
|
| 105 |
+
tot_lo = tab.cv_lora_gpu_h.sum() + tab.draws_lora_gpu_h.sum()
|
| 106 |
+
tab.to_csv(OUTDATA / "fig3_time_days.csv", index=False, float_format="%.4g")
|
| 107 |
+
|
| 108 |
+
# ------------------------------------------------------------------ figure
|
| 109 |
+
fig, (a1, a2) = plt.subplots(1, 2, figsize=ST.FULL, gridspec_kw={"width_ratios": [1.65, 1], "wspace": 0.45})
|
| 110 |
+
y = np.arange(len(ORDER))
|
| 111 |
+
h = 0.36
|
| 112 |
+
for i, r in tab.iterrows():
|
| 113 |
+
for k, (arm, v) in enumerate((("scsemi", r.cv_scsemi_gpu_h), ("lora", r.cv_lora_gpu_h))):
|
| 114 |
+
yy = y[i] + (k - 0.5) * h
|
| 115 |
+
a1.barh(yy, v, h * 0.9, color=COL[arm], edgecolor="none")
|
| 116 |
+
a1.text(v * 1.12, yy, fmt_h(v), va="center", fontsize=ST.FS - 4, color=ST.SUBINK)
|
| 117 |
+
for d, lab in ((24, "1 day"), (48, "2 days")):
|
| 118 |
+
a1.axvline(d, color="#BBBBBB", linestyle=":", linewidth=1, zorder=0)
|
| 119 |
+
a1.text(d, -0.62, lab, ha="center", va="center", fontsize=ST.FS - 5, color=ST.SUBINK)
|
| 120 |
+
a1.set_xscale("log")
|
| 121 |
+
a1.set_xlim(0.1, 400)
|
| 122 |
+
a1.set_xticks([0.1, 1, 10, 100], ["0.1", "1", "10", "100"])
|
| 123 |
+
a1.minorticks_off()
|
| 124 |
+
a1.set_yticks(y, [NAME[d] for d in ORDER], fontsize=ST.FS - 2)
|
| 125 |
+
a1.set_ylim(len(ORDER) - 0.5, -0.75)
|
| 126 |
+
a1.set_xlabel("GPU hours for one 5-fold experiment (log)")
|
| 127 |
+
a1.set_title("One cohort, 5-fold CV (5 fold models)", fontsize=ST.FS - 1, loc="left")
|
| 128 |
+
# right: everything run for this paper (5-fold + 5-donor draws, 5 cohorts)
|
| 129 |
+
bars = [("scSemiProfiler", [(tot_sc, COL["scsemi"])]),
|
| 130 |
+
("PBISC", [(tot_lo, COL["lora"]), (pre_h, COL["pretrain"])])]
|
| 131 |
+
for i, (lab, parts) in enumerate(bars):
|
| 132 |
+
left = 0.0
|
| 133 |
+
for v, c in parts:
|
| 134 |
+
a2.barh(i, v, 0.55, left=left, color=c, edgecolor="none")
|
| 135 |
+
left += v
|
| 136 |
+
a2.text(left + 3, i, fmt_h(left), va="center", fontsize=ST.FS - 4, color=ST.SUBINK)
|
| 137 |
+
a2.text(tot_lo + pre_h + 3, 1.22, f"LoRA {tot_lo:.1f} h + pretraining {pre_h:.1f} h (once)", ha="left",
|
| 138 |
+
va="center", fontsize=ST.FS - 5, color=ST.SUBINK)
|
| 139 |
+
a2.set_yticks([0, 1], [b[0] for b in bars], fontsize=ST.FS - 2)
|
| 140 |
+
a2.set_ylim(1.6, -0.6)
|
| 141 |
+
a2.set_xlim(0, tot_sc * 1.45)
|
| 142 |
+
a2.set_xlabel("GPU hours, all runs (linear)")
|
| 143 |
+
a2.set_title("All runs for this paper", fontsize=ST.FS - 1, loc="left")
|
| 144 |
+
for ax in (a1, a2):
|
| 145 |
+
ax.grid(axis="x", color="#E3E3E3", linewidth=0.8)
|
| 146 |
+
ax.set_axisbelow(True)
|
| 147 |
+
ax.tick_params(axis="y", length=0)
|
| 148 |
+
handles = [plt.Rectangle((0, 0), 1, 1, color=COL[k]) for k in ("scsemi", "lora", "pretrain")]
|
| 149 |
+
fig.legend(handles, ["scSemiProfiler", "PBISC LoRA (fine-tune + sampling)", "PBISC pretraining, once"],
|
| 150 |
+
loc="lower center", ncol=3, bbox_to_anchor=(0.5, -0.07), fontsize=ST.FS - 3)
|
| 151 |
+
ST.save(fig, "fig3_time_days", FIGDIR)
|
| 152 |
+
|
| 153 |
+
# ------------------------------------------------------------------ text
|
| 154 |
+
im = tab.set_index("cohort").loc["immicro"]
|
| 155 |
+
worst = tab.loc[tab.cv_scsemi_gpu_h.idxmax()]
|
| 156 |
+
kw = [f"Healthy 5-fold: {im.cv_scsemi_gpu_h / 24:.1f} GPU-day vs {im.cv_lora_gpu_h:.1f} h",
|
| 157 |
+
f"Up to {worst.cv_scsemi_gpu_h / 24:.1f} days per cohort ({NAME[worst.cohort]})",
|
| 158 |
+
f"All runs: {tot_sc / 24:.1f} days vs {tot_lo + pre_h:.0f} h with pretraining"]
|
| 159 |
+
run_txt = "; ".join(f"{NAME[r.cohort]} {r.cv_scsemi_running_h:.0f} h" for r in tab.itertuples())
|
| 160 |
+
full = ("GPU time on one GB10 GPU with every step alone on the GPU, from each run's receipts. One 5-fold experiment "
|
| 161 |
+
"= the five fold models, every usable sample tested once by the model that never trained on it. "
|
| 162 |
+
"scSemiProfiler = pretraining of every representative (two stages) + one model per test sample "
|
| 163 |
+
"(upstream c2aea02, default settings); PBISC LoRA = fine-tune + sampling 1,500 cells per test sample. "
|
| 164 |
+
f"Ratio per cohort: {tab.cv_ratio.min():.0f}-{tab.cv_ratio.max():.0f}x. scSemiProfiler running time "
|
| 165 |
+
f"including its CPU steps (waits for the GPU excluded): {run_txt}. All runs = 5-fold + the 25 five-donor "
|
| 166 |
+
f"draws: scSemiProfiler {tot_sc:.0f} h, LoRA {tot_lo:.1f} h; PBISC's pretraining ({pre_h:.1f} h, 33.1 M "
|
| 167 |
+
"cells) is done once and reused by every cohort. Not counted on either side: data preparation and scoring. "
|
| 168 |
+
"The equal-pair-budget scSemiProfiler runs are not included (they reuse the 5-fold run's representative "
|
| 169 |
+
"models). Sources: data/sec09_same_pairs.csv, data/sec09_time_to_apply.csv, data/sec06_ft_method.csv, "
|
| 170 |
+
"scsemi/work/<cohort>/cv/fold<k>/events.jsonl.").replace("-", "–")
|
| 171 |
+
numbers = [{"value": "; ".join(f"{NAME[r.cohort]}: 5-fold scSemiProfiler {r.cv_scsemi_gpu_h:.1f} GPU h "
|
| 172 |
+
f"({r.cv_scsemi_gpu_h / 24:.2f} days, running {r.cv_scsemi_running_h:.1f} h) vs LoRA "
|
| 173 |
+
f"{r.cv_lora_gpu_h:.2f} h ({r.cv_ratio:.0f}x); 5-donor draws {r.draws_scsemi_gpu_h:.1f}"
|
| 174 |
+
f" h vs {r.draws_lora_gpu_h:.2f} h" for r in tab.itertuples()),
|
| 175 |
+
"source": "data/fig3_time_days.csv"},
|
| 176 |
+
{"value": f"all runs: scSemiProfiler {tot_sc:.1f} GPU h ({tot_sc / 24:.2f} days); PBISC LoRA {tot_lo:.2f} h"
|
| 177 |
+
f" + pretraining {pre_h:.1f} h once", "source": "data/fig3_time_days.csv"}]
|
| 178 |
+
slides = [{"title": "Time: days for scSemiProfiler, minutes for LoRA", "layout": "full",
|
| 179 |
+
"figures": [str(FIGDIR / "fig3_time_days.png")], "keywords": kw,
|
| 180 |
+
"footnote_short": "One GB10 GPU, job alone on it. GPU time from receipts; waits for the GPU excluded.",
|
| 181 |
+
"footnote": full, "numbers": numbers}]
|
| 182 |
+
if len(slides[0]["footnote_short"]) > 110:
|
| 183 |
+
raise SystemExit("short footnote too long")
|
| 184 |
+
out = {"section": "fig3-time", "scripts": [str(Path(__file__).resolve())],
|
| 185 |
+
"generated_from": "tools/fig3_time_days.py (rerun to refresh; do not edit by hand)", "slides": slides}
|
| 186 |
+
(OUTDATA / "fig3_time_days_slide_text.json").write_text(json.dumps(out, indent=1, ensure_ascii=False))
|
| 187 |
+
print("\n".join(kw))
|
| 188 |
+
print(tab.round(2).to_string(index=False))
|
| 189 |
+
print(f"all runs: scSemi {tot_sc:.1f} h, LoRA {tot_lo:.2f} h, pretraining {pre_h:.1f} h")
|
| 190 |
+
return 0
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
if __name__ == "__main__":
|
| 194 |
+
sys.exit(main())
|