|
| 1 | +# 2023 Retraining Notebook Audit |
| 2 | + |
| 3 | +This audits the copied notebook bundle in `notebooks/2023-retraining/` against |
| 4 | +the maintained release scripts and 2.3.x evaluation commands. The notebooks are |
| 5 | +valuable source material, but they include generated data, checkpoint notebooks, |
| 6 | +old imports, and local paths, so they should be ported into scripts rather than |
| 7 | +committed as the workflow. |
| 8 | + |
| 9 | +## What The Notebooks Cover |
| 10 | + |
| 11 | +- Benchmark assembly: joins `data_evaluation` sample shards into wide |
| 12 | + monoallelic and multiallelic benchmark tables with MHCflurry, NetMHCpan, and |
| 13 | + MixMHCpred columns. |
| 14 | +- Accuracy scoring: per-sample and per-length AUC / PPV tables, percent-change |
| 15 | + columns against NetMHCpan BA, NetMHCpan EL, MixMHCpred, and older MHCflurry. |
| 16 | +- Figure generation: paper-style scatter panels, score bars, processing motifs, |
| 17 | + processing-vs-affinity correlation plots, and presentation coefficient plots. |
| 18 | +- Supplemental outputs: sample tables, benchmark data files, model-selection |
| 19 | + accuracy workbook, antigen-processing motif workbook, and supplementary data |
| 20 | + CSV/XLSX files. |
| 21 | +- Exploratory analyses: novel-allele analysis, proteasome mass-spec analysis, |
| 22 | + and an immunogenicity experiment depending on external local files. |
| 23 | + |
| 24 | +## Differences From Maintained Workflows |
| 25 | + |
| 26 | +- Data curation is split differently. Current maintained scripts use |
| 27 | + `downloads-generation/` to build raw downloads and `scripts/training/` to build |
| 28 | + release models. The notebooks start from already-generated downloads and create |
| 29 | + analysis artifacts under `notebooks/2023-retraining/artifacts/`. |
| 30 | +- The current `data_evaluation` download generates train-excluded benchmark |
| 31 | + files and sample shards. The notebooks additionally join those shards into |
| 32 | + wide analysis tables and include an abandoned no-exclude-train path. |
| 33 | +- The notebooks label recent multiallelic samples using PMIDs `31844290` and |
| 34 | + `31154438`. Current presentation training excludes `31844290`, `31495665`, and |
| 35 | + `31154438`; this needs one named holdout policy before new public weights are |
| 36 | + trained and evaluated. |
| 37 | +- The notebooks use old notebook-era dependencies and names (`keras`, |
| 38 | + `tensorflow`, `mhcnames` in places). Ports should use the current PyTorch code, |
| 39 | + `mhcgnomes` / existing allele normalization helpers, and maintained CLI |
| 40 | + commands. |
| 41 | +- Current `mhcflurry compare-models` covers affinity and presentation regression |
| 42 | + metrics, and `mhcflurry plot-model-comparison` renders generic plots. It does |
| 43 | + not yet recreate the paper-style benchmark tables, sample-group comparisons, |
| 44 | + model-selection workbook, motif workbook, or supplemental figures. |
| 45 | +- The current full training script trains processing `no_flank` and |
| 46 | + `short_flanks` variants, then uses `short_flanks` as the with-flank processing |
| 47 | + component for presentation. Older download-generation trained a separate |
| 48 | + `models.selected.with_flanks` variant. That semantic difference should be |
| 49 | + resolved explicitly before publishing 2.3.0 weights. |
| 50 | +- Historical runplz files in `jobs/` patched scripts in place for one experiment |
| 51 | + and called deleted comparison scripts. Remote execution is now represented by |
| 52 | + maintained scripts instead of patching a remote copy. |
| 53 | + |
| 54 | +## Missing Figure And Table Ports |
| 55 | + |
| 56 | +- Predictor metadata / aesthetics: convert `0 aesthetics.ipynb` into a small |
| 57 | + `predictor_info.csv` generator with stable labels, colors, and descriptions. |
| 58 | +- Wide benchmark tables: port the monoallelic and multiallelic shard-join logic |
| 59 | + from `1 prepare benchmark dataset*.ipynb`. |
| 60 | +- Accuracy score tables: port the AUC / PPV / percent-change tables from |
| 61 | + `2 monoallelic accuracy plots.ipynb` and `2 multiallelic accuracy.ipynb`. |
| 62 | +- Monoallelic figures: BA/EL/MixMHCpred scatter panels, training-count vs AUC, |
| 63 | + and novel-allele comparison tables / plots. |
| 64 | +- Multiallelic figures: PPV/AUC scatter panels comparing NetMHCpan BA, |
| 65 | + NetMHCpan EL, MixMHCpred, older MHCflurry, and presentation score variants, |
| 66 | + including recent-vs-old sample grouping. |
| 67 | +- Model-selection evidence: port the unselected-model held-out decoy AUC workbook |
| 68 | + and HLA locus score bars. |
| 69 | +- Processing evidence: port antigen-processing motif count/PWM workbook, |
| 70 | + processing logo figure, and processing-vs-affinity correlation plots. |
| 71 | +- Supplemental outputs: port sample table, supplemental sample table with |
| 72 | + accuracies, benchmark supplemental CSVs, and proteasome mass-spec additional |
| 73 | + file generation. |
| 74 | +- Immunogenicity experiment: defer until external source files are located and |
| 75 | + licensed; do not make this a release gate yet. |
| 76 | + |
| 77 | +## Porting Plan |
| 78 | + |
| 79 | +1. Add `scripts/analysis/` for reusable release-analysis scripts. Keep notebooks |
| 80 | + out of the maintained path; use them only as references. |
| 81 | +2. Extract shared metric helpers: PPV@N, sign normalization, bootstrap intervals, |
| 82 | + percent-change calculations, and sample/length grouping. |
| 83 | +3. Add a benchmark-assembly script that consumes a `data_evaluation` directory |
| 84 | + and writes wide monoallelic/multiallelic analysis CSVs from the group files. |
| 85 | +4. Add an accuracy-table script that writes the notebook-style |
| 86 | + `accuracy_scores.*.csv` tables from those wide benchmarks. |
| 87 | +5. Add figure scripts that consume the generated tables and produce stable PNG / |
| 88 | + PDF outputs under a release-analysis directory. |
| 89 | +6. Add processing-motif generation from the presentation benchmark and trained |
| 90 | + processing predictors. This should be scriptable without `logomaker` unless |
| 91 | + the logo plot is explicitly requested; the workbook can be generated first. |
| 92 | +7. Decide the 2.3.0 holdout policy in one place: PMIDs, pMHC overlap removal, |
| 93 | + and whether evaluation data is filtered out of affinity / processing / |
| 94 | + presentation training. Move any useful logic from `jobs/filter_training...` |
| 95 | + into maintained scripts after that decision. |
| 96 | +8. Resolve the processing variant naming: either train a real |
| 97 | + `models.selected.with_flanks` variant again or document and test that |
| 98 | + `short_flanks` is the canonical with-flank presentation input for 2.3.x. |
| 99 | +9. Make the release gate one command: |
| 100 | + `scripts/release/retrain_evaluate_deploy.sh` trains, evaluates, plots, and |
| 101 | + runs deployment validation. It supports local, runplz/Brev, and SSH-backed |
| 102 | + remote machines. |
| 103 | + |
| 104 | +## Current Single-Command Entry Point |
| 105 | + |
| 106 | +Local: |
| 107 | + |
| 108 | +```bash |
| 109 | +scripts/release/retrain_evaluate_deploy.sh \ |
| 110 | + --run-dir /path/to/release-run \ |
| 111 | + --release 2.3.0 \ |
| 112 | + --backend local \ |
| 113 | + --deploy-mode dry-run |
| 114 | +``` |
| 115 | + |
| 116 | +Brev through runplz: |
| 117 | + |
| 118 | +```bash |
| 119 | +scripts/release/retrain_evaluate_deploy.sh \ |
| 120 | + --run-dir /path/to/release-run \ |
| 121 | + --release 2.3.0 \ |
| 122 | + --backend runplz \ |
| 123 | + --deploy-mode dry-run |
| 124 | +``` |
| 125 | + |
| 126 | +Generic SSH machine: |
| 127 | + |
| 128 | +```bash |
| 129 | +scripts/release/retrain_evaluate_deploy.sh \ |
| 130 | + --run-dir /path/to/local-copy \ |
| 131 | + --release 2.3.0 \ |
| 132 | + --backend ssh \ |
| 133 | + --remote user@host \ |
| 134 | + --remote-repo /path/to/mhcflurry \ |
| 135 | + --remote-run-dir /path/to/remote-release-run \ |
| 136 | + --deploy-mode dry-run |
| 137 | +``` |
0 commit comments