Protein Counterfactuals via Diffusion-Guided Latent Optimization
Organizations: Machine Learning Group, Technische Universität Berlin, Berlin, Germany · Berlin Institute for the Foundations of Learning and Data (BIFOLD) · BASF Digital Solutions GmbH, Ludwigshafen am Rhein, Germany
Abstract
Deep learning models can predict protein properties with unprecedented accuracy but rarely offer mechanistic insight or actionable guidance for engineering improved variants. When a model flags an antibody as unstable, the protein engineer is left without recourse: which mutations would rescue stability while preserving function? We introduce Manifold-Constrained Counterfactual Optimization for Proteins (MCCOP), a framework that computes minimal, biologically plausible sequence edits that flip a model's prediction to a desired target state. MCCOP operates in a continuous joint sequence-structure latent space and employs a pretrained diffusion model as a manifold prior, balancing three objectives: validity (achieving the target property), proximity (minimizing mutations), and plausibility (producing foldable proteins). We evaluate MCCOP on three protein engineering tasks - GFP fluorescence rescue, thermodynamic stability enhancement, and E3 ligase activity recovery - and show that it generates sparser, more plausible counterfactuals than both discrete and continuous baselines. The recovered mutations align with known biophysical mechanisms, including chromophore packing and hydrophobic core consolidation, establishing MCCOP as a tool for both model interpretation and hypothesis-driven protein design. Our code is publicly available at github.com/weroks/mccop.
Figures & tables
| Dataset | AUROC ( ) | Avg. norm ( ) | ||
|---|---|---|---|---|
| Before | After | Before | After | |
| Fluorescence | ||||
| Stability | ||||
| Activity | ||||
| Dataset | Method | Success Rate ( ) | Adv. Rate ( ) | Edit Dist. ( ) |
|---|---|---|---|---|
| Stability | Genetic Algorithm | |||
| Gradient Descent † | ||||
| Stochastic Hill Climb | ||||
| MCCOP (ours) | ||||
| Fluorescence | Genetic Algorithm | |||
| Gradient Descent † |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Description | Fluorescence | Stability | Activity |
|---|---|---|---|---|
| Top- masked positions | 5 | 5 | 5 | |
| distance weight | 0.1 | 0.1 | 0.1 | |
| Margin in | 2.2 | 2.2 | 2.2 | |
| Projection strength | 0.3 | 0.3 | 0.3 | |
| Diffusion noise level | 100 | 100 | 100 | |
| Learning rate |
| Hyperparameter | Symbol | Value |
|---|---|---|
| Learning rate | ||
| Gradient steps | ||
| Confidence threshold | ||
| Optimizer | – | Adam |
| Loss function | BCEWithLogitsLoss |
| Hyperparameter | Symbol | Value |
|---|---|---|
| Maximum steps | ||
| Confidence threshold | ||
| Amino acid alphabet | Standard 20 | |
| Mutations per step | – |
| Hyperparameter | Symbol | Value |
|---|---|---|
| Population size | ||
| Generations | ||
| Crossover rate | ||
| Edit distance penalty | ||
| Confidence threshold | ||
| Elite fraction | – |
| Dataset | Sequences | Positive | Negative | Avg. Length | Binarization |
|---|---|---|---|---|---|
| Fluorescence | 54,025 | 30,697 | 23,328 | 236.96 | Bimodal split |
| Stability | 45,901 | 22,694 | 23,207 | 45.06 | Remove middle 33% |
| Activity | 60,692 | 30,293 | 30,399 | 102 | Remove middle 33% |