SKILL.md
Version Compatibility
Reference examples tested with: MHCflurry 2.1+, numpy 1.26+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Immunogenicity Scoring
"Rank my neoantigen candidates by immunogenicity" → Score and prioritize epitopes using multi-factor models combining MHC binding, proteasomal processing, expression level, and sequence foreignness for vaccine candidate selection.
- Python:
mhcflurryfor binding + processing predictions, custom scoring pipeline
Multi-Factor Scoring
Goal: Calculate a composite immunogenicity score from multiple weighted factors (binding, agretopicity, processing, expression, clonality, foreignness).
Approach: Score each factor on a 0-1 scale, then combine via weighted sum with domain-informed weights.
import pandas as pd
import numpy as np
def calculate_immunogenicity_score(peptide_data):
'''Calculate composite immunogenicity score
Factors considered:
1. MHC binding affinity (IC50)
2. Agretopicity (MT vs WT binding ratio)
3. Proteasomal processing
4. TAP transport
5. Expression level
6. Clonality (VAF for neoantigens)
7. Self-similarity (avoid tolerance)
Each factor scored 0-1, then weighted and combined.
'''
scores = {}
# 1. Binding affinity (lower IC50 = better)
# Transform to 0-1: 1 at 0nM, 0 at 5000nM
ic50 = peptide_data.get('ic50_nM', 500)
scores['binding'] = 1 - min(ic50 / 5000, 1)
# 2. Agretopicity (MT binds better than WT)
# Ratio of WT/MT IC50, capped at 10
agretopicity = peptide_data.get('agretopicity', 1.0)
scores['agretopicity'] = min(agretopicity / 10, 1)
# 3. Processing score (from MHCflurry)
processing = peptide_data.get('processing_score', 0.5)
scores['processing'] = processing
# 4. Expression (log scale, capped)
expression = peptide_data.get('expression_tpm', 10)
scores['expression'] = min(np.log10(expression + 1) / 3, 1)
# 5. Clonality (for neoantigens)
vaf = peptide_data.get('vaf', 0.5)
scores['clonality'] = vaf
# 6. Self-similarity (lower = better, less tolerance)
self_sim = peptide_data.get('self_similarity', 0.5)
scores['foreignness'] = 1 - self_sim
# Weighted combination
weights = {
'binding': 0.25,
'agretopicity': 0.20,
'processing': 0.10,
'expression': 0.15,
'clonality': 0.15,
'foreignness': 0.15
}
total = sum(scores[k] * weights[k] for k in weights)
return total, scores
