Add TLimmuno2 class-II (CD4) immunogenicity predictor (#249) - #252
Merged
Conversation
TLimmuno2 (Wang et al., Briefings in Bioinformatics 2023) is a transfer-learned model that scores class-II peptide immunogenicity to CD4+ T cells. It is the first class-II immunogenicity predictor in mhctools — Calis, PRIME, BigMHC_IM, and DeepImmuno are all class-I / CD8 — so it fills a real gap in the taxonomy, emitting one Kind.immunogenicity prediction per (peptide, allele). TLimmuno2 ships weights in-repo but loads them with a Keras 2 / TensorFlow stack, and its upstream license is ambiguous (an Apache-2.0 README badge with no LICENSE file), so mhctools does NOT vendor it: the wrapper shells out to its Python/TLimmuno2.py CLI in a user-provided checkout (TLIMMUNO2_HOME) via a user-provided interpreter (TLIMMUNO2_PYTHON) — the DeepImmuno/DeepTAP pattern. On newer TensorFlow the interpreter only needs the tf-keras shim; the wrapper sets TF_USE_LEGACY_KERAS=1 for the subprocess so the Keras-2 SavedModels load. - class-II allele handling: native NetMHCIIpan keys pass through (DRB1_0803, HLA-DPA10103-DPB10101, H-2-IAb); common DR forms convert; the mhctools canonical DRA/DRB pair collapses to the beta chain. TLimmuno2's file mode inner-joins on allele and silently drops unknowns, so we validate against its own pseudosequence list and fail loudly instead. - surfaces both the raw score and the %Rank (rescaled 0-1 -> 0-100, lower = more immunogenic). %Rank is scored against ~90k background peptides per distinct allele, so a call costs ~a minute per allele — documented. - 21-residue hard peptide cap (the (21,21) encoder limit); reject longer. - register as "tlimmuno2" in the CLI; export from the package - tests: parser + allele-mapping + construction/validation offline, end-to-end gated on TLIMMUNO2_HOME (verified locally: FHTMWHVTRGAVLMY/DRB1_0803 = 0.9874) - README + kind_support table; bump 3.30.0 -> 3.31.0 Verified end-to-end against a local TLimmuno2 checkout on TF 2.17 + tf-keras. Claude-Session: https://claude.ai/code/session_01LZahFhBSCiehXTESCYQ7wG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #249.
Adds TLimmuno2 (Wang et al., Briefings in Bioinformatics 2023) — a transfer-learned model for class-II (CD4+) peptide immunogenicity. It's the first class-II immunogenicity predictor in mhctools;
Calis,PRIME,BigMHC_IM, andDeepImmunoare all class-I / CD8, so this fills a real gap in the taxonomy. Emits oneKind.immunogenicityprediction per (peptide, allele).Design
Python/TLimmuno2.pyin a user-provided checkout (TLIMMUNO2_HOME) via a user-provided interpreter (TLIMMUNO2_PYTHON). On newer TensorFlow the interpreter only needs thetf-kerasshim; the wrapper setsTF_USE_LEGACY_KERAS=1for the subprocess so the Keras-2 SavedModels load.DRB1_0803,HLA-DPA10103-DPB10101,H-2-IAb); common DR forms convert (HLA-DRB1*08:03→DRB1_0803); the mhctools-canonical DRA/DRB pair collapses to its beta chain. TLimmuno2's file mode inner-joins on allele and silently drops unknowns, so the wrapper validates against the checkout's own pseudosequence list and fails loudly instead.score(0–1, higher = more immunogenic) andpercentile_rank(TLimmuno2's %Rank, rescaled 0–1 → 0–100, lower = more immunogenic).(21,21)encoder limit).TLimmuno2's %Rank is computed against ~90,000 background peptides per distinct allele, so a call takes ~a minute per allele regardless of how many peptides you pass. Documented in the docstring, README, and a
logger.infowhen >1 allele. (The end-to-end test takes ~5 min for this reason and is gated onTLIMMUNO2_HOME.)Verification
Confirmed end-to-end against a local TLimmuno2 checkout on TF 2.17 + tf-keras:
FHTMWHVTRGAVLMY/DRB1_0803= 0.9874 (%Rank 0.19). Offline tests (parser, allele-mapping, construction/validation) run in CI.ruffclean.Version bump 3.30.0 → 3.31.0.
https://claude.ai/code/session_01LZahFhBSCiehXTESCYQ7wG