Archive 4 checkpoints (1-4)
Browse files- .gitattributes +2 -0
- paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/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/20261005T133325Z-deck-scratch-samepairs-tracking/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/20261005T133325Z-deck-scratch-samepairs-tracking/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md +144 -0
- paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/grouped_bars.py +38 -0
.gitattributes
CHANGED
|
@@ -85,3 +85,5 @@ paper-releases/pbisc-diffusion/updates/20261003T105229Z-deck-cross-cohort-loco-k
|
|
| 85 |
paper-releases/pbisc-diffusion/updates/20261003T105229Z-deck-cross-cohort-loco-k1000/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
|
| 86 |
paper-releases/pbisc-diffusion/updates/20261003T224927Z-deck-appendix-scsemi-readout/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
|
| 87 |
paper-releases/pbisc-diffusion/updates/20261003T224927Z-deck-appendix-scsemi-readout/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
|
|
|
|
|
|
|
|
|
| 85 |
paper-releases/pbisc-diffusion/updates/20261003T105229Z-deck-cross-cohort-loco-k1000/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
|
| 86 |
paper-releases/pbisc-diffusion/updates/20261003T224927Z-deck-appendix-scsemi-readout/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
|
| 87 |
paper-releases/pbisc-diffusion/updates/20261003T224927Z-deck-appendix-scsemi-readout/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
|
| 88 |
+
paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/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
|
| 89 |
+
paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/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/20261005T133325Z-deck-scratch-samepairs-tracking/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:ee373e8bbf66bab2697af532504156d18cd42066f729fb7c8c82fa9b2806145d
|
| 3 |
+
size 7094531
|
paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/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:0ce186f1809c81ede30420d7e702e1d875d75ab9958203d5fed35723b2632634
|
| 3 |
+
size 7878809
|
paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PBISC-Diffusion paper summary deck (2026-09-30, r00; restructured 2026-10-02)
|
| 2 |
+
|
| 3 |
+
42-slide English summary of the PBISC-Diffusion (Model 8) paper experiments: title, outline, 10 sections and an
|
| 4 |
+
appendix (divider + 1 slide). There is no Backup section: every main slide sits in the section it supports. The
|
| 5 |
+
appendix (user decision 2026-10-04) holds only supplementary results that use a modified method and must not be
|
| 6 |
+
read as main evidence. Short keyword lines
|
| 7 |
+
only; the figures carry the results. Every slide that uses a published method, metric or baseline has a one-line
|
| 8 |
+
"References:" footer; full citations are in the speaker notes. Section 10 is planned work.
|
| 9 |
+
|
| 10 |
+
- `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
|
| 11 |
+
- `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
|
| 12 |
+
- `data/slides_spec.json`: slide order, titles, keywords, footnotes, references, speaker-note text
|
| 13 |
+
- `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
|
| 14 |
+
- `figures/`: exactly the figures the slides show (PNG + PDF), made by `tools/sec*.py`. Intermediate panels go to a
|
| 15 |
+
temporary folder; superseded figures are deleted, not kept (2026-10-02, user request; every deleted file was
|
| 16 |
+
checked to be in the paper archive by sha256 first).
|
| 17 |
+
- `data/sec*.csv` and `data/*_slide_text.json`: every plotted or quoted number with its source path
|
| 18 |
+
- `render/`: PDF and 70-dpi slide JPGs for checking
|
| 19 |
+
|
| 20 |
+
## Slide order
|
| 21 |
+
|
| 22 |
+
| section | slides |
|
| 23 |
+
|---|---|
|
| 24 |
+
| 1 Model overview | bulk in, cells out; denoiser |
|
| 25 |
+
| 2 Backbone | SDD → PBISC-Diffusion; bulk conditioning |
|
| 26 |
+
| 3 Architecture ablation | width & context (loss, benchmark); gene panel |
|
| 27 |
+
| 4 Metrics + SLE benchmark | **how we score generated cells** (metric table with references); SLE benchmark; per cell type; bulk broadcast baseline |
|
| 28 |
+
| 5 Real bulk vs pseudobulk | input shift; same shift in three cohorts; cells off-manifold; disease direction flips |
|
| 29 |
+
| 6 Paired fine-tuning | method; evaluation design |
|
| 30 |
+
| 7 LoRA ablations | full vs LoRA vs cond.-encoder-only; LoRA rank r = 4 / 16 / 64; K diversification; no pretraining, same cohort (pilot) |
|
| 31 |
+
| 8 Pairs needed | composition / coverage / steps (with scSemiProfiler at the same n); donor and disease signal; pairs from other cohorts; longer training on them; no pretraining, other cohorts (pilot) |
|
| 32 |
+
| 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 |
|
| 33 |
+
| 10 Paired-subset cohorts | planned |
|
| 34 |
+
| Appendix | scSemiProfiler without its output threshold (sensitivity; modified read-out, not the official output) |
|
| 35 |
+
|
| 36 |
+
## Rebuild
|
| 37 |
+
|
| 38 |
+
Everything is CPU only; no GPU or checkpoint is touched.
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
# prerequisites (plan folder plans/paired_finetune_intradataset_20260927/, CPU):
|
| 42 |
+
# scsemi/tools/representative_dependence.py -> scsemi/analysis/representative_dependence_20261002/
|
| 43 |
+
# tools/contrast_extra.py (+ tools/contrast_extra_tables.py) -> scores_contrast/ (Spearman, ceiling, limma, CAT, RBO)
|
| 44 |
+
# tools/build_tpm_zeroshot.py + tools/score_tpm_zeroshot.sh -> scores/<ds>/zeroshot_tpm_20261002/pooled/
|
| 45 |
+
# (the length-corrected zero-shot arm needs one GPU sampling step: tools/sample_lockwait.sh, coordinator only)
|
| 46 |
+
cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
|
| 47 |
+
# shared helpers, not run directly: style.py, sec03_common.py, scsemi_results.py, fold_sizes.py
|
| 48 |
+
for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
|
| 49 |
+
sec04_metrics_overview sec04_sle_benchmark sec05_condition_space sec05_cells_offmanifold \
|
| 50 |
+
sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
|
| 51 |
+
sec07_k_aug sec07_rank_sweep sec08_pairs_needed sec08_cross_cohort sec09_paired_validation sec09_extra_metrics \
|
| 52 |
+
sec09_time_to_apply sec09_scsemi_representative sec09_cat_curves sec10_paired_subset_cohorts \
|
| 53 |
+
secA_scsemi_readout sec07_no_pretraining sec08_cross_scratch sec09_same_pairs; do
|
| 54 |
+
python3 "tools/$f.py" || break
|
| 55 |
+
done
|
| 56 |
+
python3 tools/sync_sec09_text.py # copy every generated slide text (sec09_index / text_source) into the spec
|
| 57 |
+
python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
|
| 58 |
+
soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
|
| 59 |
+
pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
|
| 60 |
+
cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
`generate_deck.py` stops with an error if a figure is missing, a title does not fit on one line, a footnote needs
|
| 64 |
+
more than 2 lines (1 line when the slide has references), the reference line needs more than 1 line, or any text
|
| 65 |
+
contains Korean or placeholder words. `tools/restructure_20261002.py` is the one-off script that produced the current
|
| 66 |
+
slide order and the references (it refuses to run twice).
|
| 67 |
+
|
| 68 |
+
## Notes
|
| 69 |
+
|
| 70 |
+
- **No "all" label (2026-10-02).** The 5-fold arm trains each fold model on the other four folds minus 7–8
|
| 71 |
+
inner-validation donors; its test fold is never trained on (RUN.json `test_rows_never_loaded_for_training`). Figures
|
| 72 |
+
label it "5-fold CV (other 4 folds)" and learning-curve ticks show the training-pair count per fold (78–79 ImMicro,
|
| 73 |
+
58–59 sepsis), read by `tools/fold_sizes.py`.
|
| 74 |
+
- **Learning curve x = 0 uses no pairs (2026-10-02).** It shows the zero-shot model fed the real bulk as measured
|
| 75 |
+
and after exon-length correction (counts / Ensembl union-exon kb, then the same fixed-depth arithmetic;
|
| 76 |
+
`plans/.../tools/build_tpm_zeroshot.py`, scored in `scores/<ds>/zeroshot_tpm_20261002/pooled`). The old x = 0
|
| 77 |
+
calibration point, whose alpha used every training pair of the fold, is gone; calibration appears only fitted on the
|
| 78 |
+
same n pairs as the LoRA point (squares; `cal_budget_20261001`).
|
| 79 |
+
- **Disease metrics (2026-10-02).** Next to Pearson logFC r and the Welch top-50 DEG overlap: Spearman r, the
|
| 80 |
+
split-half ceiling (observed vs observed, Spearman–Brown), limma-voom top-50 DEG, each arm's chance overlap, and
|
| 81 |
+
CAT curves with the k / 2G chance line (`plans/.../scores_contrast/`, tools/contrast_extra.py; every Pearson r and
|
| 82 |
+
Welch count reproduced exactly). Repeated samples of one patient (Imperial, Giroux, Ji) count as separate samples in
|
| 83 |
+
both DE tests, as in the scorer (footnote).
|
| 84 |
+
- Section 9 text is generated: `tools/sec09_paired_validation.py`, `sec09_extra_metrics.py`, `sec07_rank_sweep.py`,
|
| 85 |
+
`sec09_time_to_apply.py`, `sec09_scsemi_representative.py`, `sec09_cat_curves.py` write slide text JSON; sync copies
|
| 86 |
+
it. Hand-written: the keywords of the two "Pairs needed" slides (section 8) and of every slide in sections 1–7 and 10.
|
| 87 |
+
- Giroux's disease metrics exclude 196 sex-linked genes (severity is confounded with sex), from
|
| 88 |
+
`plans/.../scores_nosex/`. The calibration comparator is "Zero-shot + calibration" (user decision 2026-10-01).
|
| 89 |
+
- Story rule (user decision 2026-09-30): no PBISC-VAE and no reference calibration (refcal). The exon-length-corrected
|
| 90 |
+
input is used only as the no-pair x = 0 point of the learning curve (user decision 2026-10-02).
|
| 91 |
+
`tools/sec04_immicro.py` (refcal vs scSemiProfiler on ImMicro) is kept but is not part of the deck or the rebuild.
|
| 92 |
+
- scSemiProfiler 5-fold and equal-budget results are picked up automatically when they appear (`tools/scsemi_results.py`;
|
| 93 |
+
arm `scsemi__raw` in `scores/<cohort>/scsemi_cv_20261002/pooled*/`, `scsemi_n{5,10,20,40}__raw` in
|
| 94 |
+
`scores/<cohort>/scsemi_budget_20261002/pooled*/`; same donors and reference cells as the main pooled call only).
|
| 95 |
+
Then rerun sections 8 and 9, sync, recheck the section 8 keywords and rebuild.
|
| 96 |
+
- Earlier versions: `_archive/2026-09-30_before_no_vae_refcal/`, `_archive/2026-10-01_before_extra_metrics/`,
|
| 97 |
+
`_archive/2026-10-02_before_time_to_apply/`, `_archive/2026-10-02_before_restructure/` (pptx, PDF, spec; their
|
| 98 |
+
figures are in the paper archive). `DRAFT_1150_*`: the copy shown at the 2026-09-30 12:00 meeting.
|
| 99 |
+
|
| 100 |
+
- Added 2026-10-03 (user decision: the cross-cohort experiment is reported at K = 1000 only and is the figure that explains
|
| 101 |
+
why PBISC fits LoRA on a few pairs of each cohort): slides 25-26 in section 8, `tools/sec08_cross_cohort.py`.
|
| 102 |
+
- Slide 25 "Pairs from other cohorts do not transfer": per held-out cohort, composition L1 / coverage / disease logFC r of
|
| 103 |
+
zero-shot, calibration fitted on the other cohorts, LoRA r16 / r64 / full fine-tune trained on the other cohorts
|
| 104 |
+
(+ Liu 2021) at step saturation, and LoRA on the cohort's own pairs (5-fold pooled).
|
| 105 |
+
- Slide 26 "Longer training on other cohorts: no gain": the same metrics at every 20k-step milestone.
|
| 106 |
+
- Source plan: `plans/paired_crosscohort_20261002/` (README; same-reference and same-sample checks in the script).
|
| 107 |
+
Agenda item 8 now reads "How many pairs, and do other cohorts' pairs transfer". The deck has 37 slides.
|
| 108 |
+
Pre-update copy: `_archive/2026-10-03_before_cross_cohort/`.
|
| 109 |
+
|
| 110 |
+
## Sources
|
| 111 |
+
|
| 112 |
+
Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
|
| 113 |
+
`plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
|
| 114 |
+
`plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
|
| 115 |
+
`analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each `data/sec*.csv`. Reference PDFs:
|
| 116 |
+
`/home/sj_server_1/PBISC/paper-release-20260928/reference-papers/` (INDEX.md). Manuscript:
|
| 117 |
+
`/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
|
| 118 |
+
- 2026-10-04 appendix (user decision: supplementary, appendix only, because it changes scSemiProfiler's official
|
| 119 |
+
output). Slide 38 is the divider "Appendix" and slide 39 is "Appendix: scSemiProfiler without output threshold"
|
| 120 |
+
(`tools/secA_scsemi_readout.py`, `data/secA_scsemi_readout{.csv,_slide_text.json}`).
|
| 121 |
+
- Inputs: `plans/paired_finetune_intradataset_20260927/scsemi/analysis/output_variants_20261003/`. The script checks
|
| 122 |
+
that its LoRA-5 and official scSemiProfiler values equal the section 9 slide data draw by draw.
|
| 123 |
+
- Result: without upstream's output threshold, scSemiProfiler's coverage rises in 5/5 cohorts, and 23/23 LoRA-5
|
| 124 |
+
comparisons (coverage, precision, composition, logFC r, DEG) keep their winner.
|
| 125 |
+
- The outline keeps its 10 sections (the builder requires 10). The pre-change copy is in
|
| 126 |
+
`_archive/2026-10-04_before_appendix/`. The deck has 39 slides.
|
| 127 |
+
- 2026-10-05 update (user request: put the results so far into the deck). Pre-change copy: `_archive/2026-10-05_before_scratch_cv/`.
|
| 128 |
+
- New slide 23, "No pretraining: same cohort, from scratch" (`tools/sec07_no_pretraining.py`). Pilot on sepsis fold 0
|
| 129 |
+
(17 donors). Reads `fold0_scratch_20261005/` and the runs' RUN.json. The donor composition r is recomputed from
|
| 130 |
+
per_donor.csv and reproduces ablation_extra_donor.csv.
|
| 131 |
+
- New slide 28, "No pretraining: other cohorts, from scratch" (`tools/sec08_cross_scratch.py`). Held-out sepsis pilot.
|
| 132 |
+
Every arm is read from `paired_crosscohort_20261002/scores_masked/`: genes no training cohort measured are zeroed
|
| 133 |
+
in all arms, because the unmasked scratch arm puts ~91 % of its UMI there.
|
| 134 |
+
- New slide 38, "Same training pairs: LoRA vs scSemiProfiler" (`tools/sec09_same_pairs.py`). scSemiProfiler 5-fold
|
| 135 |
+
CV with LoRA's own training pairs, plus GPU hours per fold from the receipts on either host. Cohorts that are still
|
| 136 |
+
running show "in progress"; rerun the script as they finish.
|
| 137 |
+
- These two slides now draw the scSemiProfiler CV / budget runs automatically:
|
| 138 |
+
- Slide 24, "Pairs needed" (diamonds; ImMicro so far): keyword 2 reworded, footnote extended.
|
| 139 |
+
- Slide 37, "5-fold CV" (yellow bar; ImMicro and Ji so far).
|
| 140 |
+
- `tools/sec09_paired_validation.py` reads the scSemiProfiler CV arm's Spearman / limma values from
|
| 141 |
+
`scores_contrast/<cohort>/scsemi_cv_20261002/pooled/` (contrast_extra.py --design scored). Pearson r and the Welch
|
| 142 |
+
DEG must match the scorer; the values stay blank until computed. Cohorts not yet run say "in progress".
|
| 143 |
+
- Agenda item 7 now reads "LoRA: compute, rank, K; training from scratch". The deck has 42 slides.
|
| 144 |
+
- New helper: `tools/grouped_bars.py`.
|
paper-releases/pbisc-diffusion/updates/20261005T133325Z-deck-scratch-samepairs-tracking/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/grouped_bars.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Grouped vertical bars for the 2026-10-05 slides (no-pretraining ablations, same-pairs scSemiProfiler).
|
| 2 |
+
|
| 3 |
+
Shared helper of the 2026-09-30 paper-summary deck (not run directly). CPU only, plotting only.
|
| 4 |
+
"""
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def grouped_bars(ax, groups, arms, value, fs, edge="#333333", sub="#595959", na_text="n/a", fmt=None, log=False,
|
| 11 |
+
width=0.8):
|
| 12 |
+
"""groups: x labels; arms: [(key, label, colour, hatch)]; value(group_index, arm_key) -> float (nan = no bar).
|
| 13 |
+
fmt: optional callable(v) -> str printed above each bar."""
|
| 14 |
+
n = len(arms)
|
| 15 |
+
w = width / n
|
| 16 |
+
x = np.arange(len(groups))
|
| 17 |
+
tops = []
|
| 18 |
+
for k, (key, _lab, col, hatch) in enumerate(arms):
|
| 19 |
+
xs = x + (k - (n - 1) / 2) * w
|
| 20 |
+
for i, xi in enumerate(xs):
|
| 21 |
+
v = value(i, key)
|
| 22 |
+
if v is None or np.isnan(v):
|
| 23 |
+
ax.text(xi, 0.5, na_text, transform=ax.get_xaxis_transform(), ha="center", va="center",
|
| 24 |
+
fontsize=fs - 5, color=sub, rotation=90)
|
| 25 |
+
continue
|
| 26 |
+
ax.bar(xi, v, w * 0.92, color=col, edgecolor=edge if hatch else "none", linewidth=0.6, hatch=hatch,
|
| 27 |
+
zorder=2)
|
| 28 |
+
tops.append(v)
|
| 29 |
+
if fmt is not None:
|
| 30 |
+
ax.text(xi, v * (1.08 if log else 1.0) + (0 if log else 0.01), fmt(v), ha="center", va="bottom",
|
| 31 |
+
fontsize=fs - 6, color=sub, rotation=0)
|
| 32 |
+
ax.set_xticks(x, groups, fontsize=fs - 3)
|
| 33 |
+
if log:
|
| 34 |
+
ax.set_yscale("log")
|
| 35 |
+
ax.tick_params(axis="y", labelsize=fs - 3)
|
| 36 |
+
ax.grid(axis="y", color="#E3E3E3", linewidth=0.8, zorder=0)
|
| 37 |
+
ax.set_axisbelow(True)
|
| 38 |
+
return tops
|