| # `immunogenicity/` β sources, provenance, filtering and a complete audit |
|
|
| General immunogenicity corpora: **is this presented peptide seen by a T cell?** Neoantigen datasets |
| moved to [`../neoantigens/`](../neoantigens/SOURCES.md) β this directory no longer holds NCI, |
| `neoag_*` or any tumour-specific screen. |
|
|
| Every citation resolved against **PubMed**; PMIDs and DOIs given. Audit regenerated by |
| `bench/neoag/audit_pmhc_data.py` in `2026-mhcmatch-benchmark`; corpora rebuilt by |
| `bench/neoag/corpus_chowell.py` + `bench/neoag/deposit_corpora.py`. |
|
|
| Written 2026-08-17. |
|
|
| --- |
|
|
| ## Complete audit |
|
|
| Measured from the files, not copied from any prior description. |
|
|
| | file | rows | distinct peptides | pos | neg | prevalence | HLA alleles | length | |
| |---|--:|--:|--:|--:|--:|--:|:--:| |
| | `chowell_rebuilt.tsv.gz` | 511,301 | 315,191 | 19,866 | 491,435 | 0.0389 | 210 | 8β11 | |
| | `chowell_rebuilt_hla_matched.tsv.gz` | 115,592 | 99,763 | 19,866 | 95,726 | 0.1719 | 183 | 8β11 | |
| | `kesmir_rebuilt.tsv.gz` | 65,737 | 36,155 | 22,613 | 43,124 | 0.3440 | 196 | 8β11 | |
| | `kesmir_rebuilt_hla_matched.tsv.gz` | 59,941 | 35,202 | 22,613 | 37,328 | 0.3773 | 188 | 8β11 | |
| | `iedb_labeled.tsv.gz` | 790,868 | 516,092 | 34,362 | 756,506 | 0.0435 | 250 | 2β50 | |
| | `hla_pop_freqs.tsv.gz` | 7,171 | β | β | β | β | 4,234 | β | |
|
|
| No donor/patient identifier exists in any file here β these are peptide-level corpora aggregated |
| over studies, not per-donor cohorts. (Donor counts are meaningful in `../neoantigens/` and are |
| reported there.) |
|
|
| --- |
|
|
| ## `chowell_rebuilt.tsv.gz` β immunogenic vs presented **self** |
| |
| Chowell's construction, rebuilt from the current IEDB dump rather than read off the 2015 |
| spreadsheet, which is copyrighted supplementary material and frozen at 2015. |
| |
| > Chowell D, Krishna S, Becker PD, Cocita C, Shu J, Tan X, Greenberg PD, Klavinskis LS, |
| > Blattman JN, Anderson KS. **TCR contact residue hydrophobicity is a hallmark of immunogenic CD8+ |
| > T cell epitopes.** *Proc Natl Acad Sci USA* 2015;112(14):E1754β62. |
| > PMID [25831525](https://pubmed.ncbi.nlm.nih.gov/25831525/) Β· |
| > doi:[10.1073/pnas.1500973112](https://doi.org/10.1073/pnas.1500973112) |
| |
| ### Filtering procedure, in order |
| |
| 1. **Source** β `iedb_labeled.tsv.gz` (see below), itself an IEDB export. |
| 2. **Class** β `mhc_class == "MHCI"`. |
| 3. **Host** β `host_species β {human, mouse}`; kept as a column and **never pooled**. The two hosts |
| have different MHC and different thymic repertoires, so a fit across them without the split is |
| fitting a mixture. |
| 4. **Peptide** β uppercased, whitespace-stripped; length **8β11**; canonical 20 amino acids only. |
| 5. **Exclusions** β `SLLMWITQV`, `KLGGALQAK` (NY-ESO-1 / MAGE-A3 epitopes that appear on both sides |
| of the literature with contradictory annotation). |
| 6. **Positives** β any peptide with a positive T-cell assay (`dataset_origin == "iedb_tcell"`). |
| 7. **Negatives** β eluted ligands whose `source_species` equals the **host** (self), plus the HLA |
| Ligand Atlas thymus immunopeptidome for the human arm. |
| 8. **Label is a property of the (peptide, host), not the row.** 1,075 peptides are both eluted and |
| positively assayed. Elution is evidence of *presentation*; it is never evidence against a T-cell |
| response. Assigning per row makes the same sequence positive under one allele and negative under |
| another β it sits on both sides of the fit. Computing the positive set once per (peptide, host) |
| and applying it everywhere raised self-sourced positives by **57%**. |
| 9. **Aggregation** β one row per `(peptide, allele, host_species)`, label = max. |
|
|
| ### Not controlled, deliberately |
|
|
| **Allele and length.** Immunogenic and eluted sets genuinely differ in both: some HLAs are |
| protective and some are not, and immunogenic peptides have a real length distribution that differs |
| from bulk ligands. Matching those away removes effects, not confounds. `allele` and `length` ship |
| as columns so a stratified analysis is a filter, not a rebuild β and the HLA-matched variant below |
| exists for when allele composition *is* the thing to remove. |
|
|
| --- |
|
|
| ## `kesmir_rebuilt.tsv.gz` β immunogenic vs presented **non-self** |
| |
| The Calis/Kesmir contrast. Same shape, same rules, one difference: negatives are eluted ligands |
| from a source organism that is **not** the host. |
| |
| > Calis JJA, Maybeno M, Greenbaum JA, Weiskopf D, De Silva AD, Sette A, KeΕmir C, Peters B. |
| > **Properties of MHC class I presented peptides that enhance immunogenicity.** |
| > *PLoS Comput Biol* 2013;9(10):e1003266. |
| > PMID [24204222](https://pubmed.ncbi.nlm.nih.gov/24204222/) Β· |
| > doi:[10.1371/journal.pcbi.1003266](https://doi.org/10.1371/journal.pcbi.1003266) |
| |
| **This arm requires `../ligandome/viral_foreign_iedb.tsv.gz`, and is wrong without it.** Every |
| eluted-ligand negative in the IEDB table itself is self-sourced β 449,449 human-self and 41,986 |
| mouse-self against 149 + 63 cross-species, and zero from any other organism. Filtering |
| `source_species != "human"` on a **mouse** host therefore selects mouse *self* ligands and rebuilds |
| Chowell under another name. The foreign ligandome supplies 41,294 genuine human non-self negatives. |
|
|
| Kesmir removes the self/non-self axis that Chowell confounds with immunogenicity, and is the harder |
| problem: prevalence 0.344 against Chowell's 0.039, and every negative is a foreign peptide that was |
| presented and still not attacked. |
|
|
| --- |
|
|
| ## The HLA-matched variants |
|
|
| `*_rebuilt_hla_matched.tsv.gz`, built by `deposit_corpora.py --ratio 5 --seed 20260817`. |
|
|
| There are 5β25Γ more negatives than positives and the two sides do not share an allele |
| distribution, so a classifier can separate them on **allele composition alone**. For each allele, |
| negatives are drawn without replacement to **5 per positive of that same allele**: |
|
|
| * alleles with no positives contribute **no** negatives β keeping them would reintroduce exactly the |
| imbalance being removed; |
| * alleles with too few negatives contribute all they have, and the shortfall stays visible in the |
| per-allele counts rather than being topped up from another allele; |
| * the draw is seeded (`20260817`), so the file is reproducible rather than one sample. |
|
|
| Effect: Chowell 491,435 β 95,726 negatives, 210 β 183 alleles, prevalence 0.039 β 0.172. Kesmir |
| 43,124 β 37,328, 196 β 189 alleles. |
|
|
| Use the matched file when the question is about peptide sequence; use the full file when allele |
| composition is part of the signal you want. Neither is "the" corpus. |
|
|
| --- |
|
|
| ## Two residue-level artefacts, measured |
|
|
| Both are properties of how the data was generated. A model will fit either as if it were biology. |
|
|
| | corpus | Cys % positives | Cys % negatives | ratio | C-term R/K % pos | C-term R/K % neg | |
| |---|--:|--:|--:|--:|--:| |
| | `chowell_rebuilt` | 10.69 | **1.55** | **6.9Γ** | 9.21 | 9.50 | |
| | `kesmir_rebuilt` | 10.94 | 14.50 | 0.8Γ | 9.91 | **20.33** | |
| | `iedb_labeled` | 14.56 | **2.52** | **5.8Γ** | 10.90 | 13.98 | |
|
|
| ### Cysteine β an MS detection artefact, and it hits Chowell hardest |
|
|
| Cysteine is systematically **under-detected in mass-spectrometry immunopeptidomics** unless samples |
| are alkylated. Where positives are T-cell-assayed (synthetic peptides, no MS step) and negatives are |
| MS-eluted, the corpus carries a Cys gradient with no biological content. Chowell shows **6.9Γ**; |
| finer-grained, the thymus MS subset runs at 0.17% against 11.59% in the assayed positives. |
|
|
| Fitted freely on the Chowell corpus, Cys took the **single largest coefficient** in a position-role |
| naive Bayes (+1.84 anchor / +2.05 TCR-facing). Masking it costs grouped-CV AUROC 0.712 β 0.690 and |
| *improves* transfer to neoantigen cohorts. The shipped `mhcmatch.posbayes` tables zero it. |
|
|
| **`kesmir_rebuilt` does not have this problem** (0.8Γ) β its negatives are IEDB-curated foreign |
| ligands rather than a single MS pipeline. That makes it the safer corpus for fitting residue-level |
| terms, and is a reason to run both. |
| |
| ### C-terminal Arg/Lys β genuine anchor preference, or tryptic carry-over |
| |
| A basic C-terminus is the real anchor preference of **HLA-A\*03, A\*11, A\*31, A\*68 and B\*27** β |
| and Arg/Lys are exactly the residues **trypsin cleaves after**. An elevated rate can be either, and |
| the two are **not separable from sequence alone**. |
| |
| `kesmir_rebuilt` negatives run at **20.33%** against 9.91% in positives β a 2Γ gradient in the |
| corpus that is otherwise the cleaner of the two. Before attributing anything to a C-terminal basic |
| residue on this corpus, stratify by allele: if the effect survives within A\*03/A\*11/B\*27 and |
| within non-basic-preferring alleles separately, it is anchor preference; if it only appears pooled, |
| it is composition or contamination. |
| |
| --- |
| |
| ## `iedb_labeled.tsv.gz` |
| |
| The IEDB export both corpora are built from. **This is also the `ipred` training set**, so any |
| `ipred` figure quoted on it is in-sample. |
| |
| 790,868 rows Β· 516,092 distinct peptides Β· 34,362 immunogenic Β· 250 alleles Β· lengths 2β50 |
| (unfiltered β the 8β11 restriction is applied downstream). |
| |
| > Vita R, Mahajan S, Overton JA, Dhanda SK, Martini S, Cantrell JR, Wheeler DK, Sette A, Peters B. |
| > **The Immune Epitope Database (IEDB): 2018 update.** *Nucleic Acids Res* 2019;47(D1):D339βD343. |
| > PMID [30357391](https://pubmed.ncbi.nlm.nih.gov/30357391/) Β· |
| > doi:[10.1093/nar/gky1006](https://doi.org/10.1093/nar/gky1006) |
|
|
| Provenance: **experimental** β curated T-cell assay and MHC-ligand records. Raw export kept at |
| `raw/immunogenicity/iedb_tcell_assays_29032026.tsv.gz`. |
|
|
| Thymus negatives come from the HLA Ligand Atlas (`thymus/thymus_immunopeptidome.tsv.gz`); its |
| `mhc_a` is null by design β the deposit is not allele-deconvolved. |
|
|
| --- |
|
|
| ## `hla_pop_freqs.tsv.gz` |
|
|
| Class-I allele frequencies (A/B/C) for EUR/ASN/AFR populations, 7,171 rows over 4,234 distinct |
| alleles. Source: Allele Frequency Net Database (AFND), <http://www.allelefrequencies.net>. |
| Provenance: **experimental** (population genotyping), aggregated. |
|
|
| --- |
|
|
| ## Regenerate |
|
|
| # in ~/vcs/projects/2026-mhcmatch-benchmark |
| python bench/neoag/corpus_chowell.py # plain build (Chowell arm) |
| python bench/neoag/corpus_chowell.py --with-viral # + foreign ligandome (Kesmir arm) |
| python bench/neoag/deposit_corpora.py --ratio 5 --seed 20260817 |
| python bench/neoag/audit_pmhc_data.py |
| |
| `corpus_chowell.parquet` must keep its exact row counts (human 464,310 / 14,712 pos; mouse 47,203 / |
| 5,154) β the shipped `mhcmatch.posbayes` tables are fitted on it, and folding extra sources into it |
| in place breaks that provenance silently. That is why `--with-viral` writes a separate file. |
|
|
| ## `chowell_iedb_full.tsv.gz` / `chowell_iedb_full_matched.tsv.gz` (2026-08-18) |
| |
| Rebuilt from the **full** IEDB export (build 2026-08-11) rather than `iedb_labeled.tsv.gz`. That |
| harmonised table kept only *positive* T-cell assays, so its `assay_type` is perfectly collinear with |
| its label and it cannot supply a measured negative at all; the full export carries 361,962 negative |
| T-cell assay rows, for mouse as well as human. |
|
|
| `chowell_rebuilt.tsv.gz` and `kesmir_rebuilt.tsv.gz` are **unchanged and still current** β the |
| shipped `mhcmatch.complement` and `posbayes` tables are fitted on them, they are named in the |
| library's `REFERENCE_FILES`, and every AUROC in `bench/results/complementarity.md` belongs to them. |
| These two files are additional, not replacements. |
|
|
| ### The rules, in the order applied |
|
|
| 1. MHC class I. |
| 2. Host β {human, mouse}; a column, never pooled. |
| 3. Length 8β11, canonical 20 amino acids. |
| 4. Exclude `SLLMWITQV`, `KLGGALQAK`. |
| 5. **Immunogenic** β the peptide has β₯1 positive T-cell assay in that host (`Positive`, |
| `Positive-Low`, `-High`, `-Intermediate`). |
| 6. **Non-immunogenic** β an eluted **self** ligand appearing in no positive T-cell assay in any |
| host. 2,086 rows are eluted but positive elsewhere and are excluded from the negatives rather |
| than counted as such. |
| 7. The label is a property of `(peptide, host)`, never of an assay row. |
| 8. The restriction is resolved, and **no row is dropped for lacking one**: 1,677,439 of 3,278,355 |
| surviving class-I rows name only `HLA class I`. netMHCpan-4.2 picks the best `%Rank_EL` among |
| whatever the recorded string still permits β an allele group or serotype restricts to that |
| group, an H-2 haplotype to the molecules it carries, a bare `HLA class I` to a 30-allele |
| population panel built per locus. A **known** non-human/non-mouse MHC on a human or mouse host |
| (2,812 rows) is a curation error, not a missing value, and is excluded rather than imputed. |
| 9. One row per `(peptide, allele group, host)`, label = max. The key is the allele **group** |
| (`HLA-A*02`), which is what lets serotype-only records join. |
|
|
| ### Counts |
|
|
| | file | rows | positive | negative | peptides | allele groups | |
| |---|--:|--:|--:|--:|--:| |
| | `chowell_iedb_full` (human) | 789,047 | 24,293 | 764,754 | 579,322 | 75 | |
| | `chowell_iedb_full` (mouse) | 65,472 | 7,187 | 58,285 | 49,253 | 43 | |
| | `chowell_iedb_full_matched` (human) | 20,360 | 10,180 | 10,180 | 17,181 | 18 | |
| | `chowell_iedb_full_matched` (mouse) | 9,132 | 4,566 | 4,566 | 7,969 | 25 | |
|
|
| Columns add `allele_2f`, `allele_group`, `allele_source` β {`reported`, `imputed_group`, |
| `imputed_panel`} and `allele_rank_el`, so an analysis can exclude imputed restrictions and say how |
| much sample it lost. Human: 375,462 reported against 413,585 imputed; mouse 51,003 against 14,469. |
|
|
| The matched arm resamples both classes to one profile at 1:1 so the allele group carries no signal |
| about the label β human to population frequency from `hla_pop_freqs.tsv.gz`, mouse to the positives' |
| own profile, there being no H-2 frequency table. It is **small**: 52 of 75 human allele groups are |
| too scarce to fill their population weight and are dropped, which is the cost of the matching, not a |
| bug. |
|
|
| Regenerate, in `~/vcs/projects/2026-mhcmatch-benchmark`: |
|
|
| python immunogenicity/fetch.py # stage the export from ~/hf/pmhc_data/dump |
| bench/neoag/corpus_iedb.py --workers 12 # ~55 min, 14.7M netMHCpan predictions |
| bench/neoag/deposit_arms.py |
| |
| Arm counts, the filter cascade and the selection tree are `bench/results/corpus_arms.md`. |
|
|
| **Caveat carried forward.** These negatives are still *inferred* β an eluted ligand nobody has |
| tested is assumed non-immunogenic. 38,322 rows in the rebuild have a measured negative T-cell assay |
| instead, held under evidence `tcell_negative` and deliberately **not** merged into the arm: swapping |
| the negative definition changes what every AUROC recorded on these corpora means. |
|
|
| ### `immunogenicity_legacy_arms.tsv.gz` (2026-08-19) |
|
|
| The published deposits and the legacy KeΕ‘mir arms in one table, keyed `corpus` β {`chowell_vanilla`, |
| `kesmir_S1`, `kesmir_S2`, `kesmir_S3`}, so a held-out evaluation can be reproduced without the |
| copyrighted spreadsheets. 15,991 rows. |
|
|
| **Species is keyed on the restricting allele, not on the deposit's own `Species` column.** The two |
| disagree on 777 of the 2,508 Calis rows (31%), which carry `Species = Mus` with an HLA restriction β |
| HLA-transgenic mice, murine host and human restricting molecule. Both readings describe the |
| experiment; they build different corpora. Keyed on the host, the Calis human arm is 1,113 |
| immunogenic against **one** non-immunogenic; keyed on the allele it is **1,619 against 272** and the |
| mouse arm is H-2 throughout. The reported host is retained as `host_reported`. |
|
|
| Regenerate with `bench/neoag/corpus_legacy.py` then `deposit_arms.py`. |
|
|
| ### What the recognition model is fitted on |
|
|
| `chowell_iedb_full` is the training arm for `mhcmatch.recognition` (0.15.0). Two choices were made |
| by measurement and are recorded in `bench/results/recognition_model.md` and |
| `feature_importance.md`: |
|
|
| - **The unmatched arm ships.** Resampling negatives to match population HLA usage costs 0.019 |
| (human) and 0.058 (mouse) AUROC on held-out published deposits. |
| - **ESM2 and the physicochemical features are both kept.** ESM2 adds +0.022/+0.042 over physchem |
| alone; physchem adds +0.009/+0.019 over ESM2 alone. Permutation importance on held-out data ranks |
| the two ESM face-pools first (0.19β0.27), then `kf_tcr`; the whole-peptide Kidera aggregate is |
| worth 0.0165/0.0012 and is not shipped, being exactly the sum of the two role columns. |
|
|
| ## `staged/` β the IEDB full export, as staged (2026-08-19) |
|
|
| The **root of the provenance chain**. Every rebuilt corpus in this directory |
| (`chowell_iedb_full*`, `immunogenicity_legacy_arms`) is derived from these two tables, and until |
| now they lived only in a gitignored working directory β one bad checkout from being unreproducible. |
| Deposited so the chain closes without re-downloading 450 MB from IEDB. |
|
|
| | file | provenance | rows | |
| |---|---|--:| |
| | `staged/iedb_tcell.parquet` | **experimental** β IEDB `tcell_full_v3_tsv.zip`, build 2026-08-11, downloaded 2026-08-18 | 570,434 linear-peptide rows, 233,636 distinct peptides | |
| | `staged/iedb_ligand.parquet` | **experimental** β IEDB `mhc_ligand_full_tsv.zip`, same build | 5,773,495 linear-peptide rows, 1,704,996 distinct peptides | |
| | `staged/fetch.py` | the script that produced both | β | |
| | `staged/FETCH.md` | its record: zip mtimes, export row counts, alignment failures, class and qualitative-measurement breakdowns | β | |
|
|
| Ten columns are kept from each export; nothing is filtered beyond `Linear peptide` and a non-empty |
| name, because length, alphabet, class and host filters are corpus-construction rules and belong |
| where they can be stated as rules. **0 rows failed to align** in either table β IEDB ships two |
| header lines and embedded newlines in comment fields, so `fetch.py` reads with `csv.reader` rather |
| than splitting on tabs, and reports the misalignment count rather than assuming it is zero. |
|
|
| The T-cell export is what makes a *measured* negative possible: 361,962 `Negative` rows across all |
| hosts, where the older harmonised `iedb_labeled.tsv.gz` keeps only positive T-cell assays and its |
| `assay_type` is therefore perfectly collinear with its label. |
|
|
| Regenerate (needs `~/hf/pmhc_data/dump`, which is gitignored β the raw zips are not deposited): |
|
|
| ```zsh |
| python immunogenicity/staged/fetch.py |
| ``` |
|
|
| ## `corpus_iedb_mhc2.parquet` β the MHC class-II arm (2026-08-19) |
|
|
| **Derived/computed**, from `staged/iedb_tcell.parquet` and `staged/iedb_ligand.parquet` β the same |
| IEDB build 2026-08-11 export the class-I corpus is built from, by the same rules, so the two arms are |
| comparable by construction rather than by assertion. This is what the shipped class-II |
| complementarity model (`mhcmatch.complement`, `cls="mhc2"`, v0.16.0) is fitted on. |
|
|
| | field | value | |
| |---|--:| |
| | rows (peptide, allele group, host) | 1,096,034 | |
| | distinct peptides | 643,744 | |
| | immunogenic peptides | 77,943 | |
| | human rows | 1,036,041 | |
| | human positives | 65,486 | |
| | human distinct peptides | 603,781 | |
| | human allele groups | 121 | |
| | mouse rows | 59,993 | |
| | mouse positives | 12,457 | |
| | mouse distinct peptides | 50,258 | |
| | mouse allele groups | 40 | |
| | peptide length | 11β25, median 15 | |
|
|
| Three rules differ from the class-I arm and nothing else does: |
|
|
| - **Length** is 11β25 rather than 8β11. |
| - **Restriction is parsed, never imputed.** Class-II restriction is written a dozen ways across IEDB |
| (`HLA-DRB1*15:01`, `HLA-DPA1*01:03/DPB1*04:01`, `HLA-DR15`, serotypes, `H2-IAb`), so the corpus |
| carries a parser and keeps whatever it cannot resolve as an explicit `unresolved` group rather than |
| guessing an allele. It parses **1,003,554 / 1,974,413 rows (50.8 %)**; the remainder are retained, |
| not dropped, because the complementarity fit reads only peptide and label. There is therefore **one |
| class-II arm where class I has two** β no HLA-matched variant is built, since matching needs a |
| resolved allele on both sides. |
| - **Rule 8** (pathogen epitopes) is applied by parsing the source organism rather than by set-match. |
|
|
| `evidence` records why each row is what it is: `eluted_but_positive_elsewhere=5,305`, |
| `eluted_foreign=103,351`, `eluted_self=1,156,574`, `eluted_unknown=440,458`, `tcell_negative=110,312`, |
| `tcell_positive=158,413`. |
|
|
| `corpus_iedb_mhc2.log` is the generator's own run record, deposited beside it; the counts in the table |
| above are read from it. The build is deterministic β regenerated 2026-08-19 from a clean checkout, every |
| count reproduced exactly. |
|
|
| Regenerate (needs this mirror at `$MHCMATCH_PMHC_DIR`, and the benchmark repo): |
|
|
| ```zsh |
| python bench/neoag/corpus_iedb.py --cls mhc2 |
| ``` |
|
|