Spaces:
Running on Zero
Running on Zero
Sync 67 change(s) from the repository
Browse files- .gitignore +3 -0
- CITATION.cff +1 -0
- README.md +7 -2
- paper/DeepMutate-3D_pdf.pdf +0 -3
- paper/DeepMutate-3D_preprint.md +0 -512
- paper/DeepMutate-3D_preprint.pdf +0 -3
- paper/SUBMISSION_FIELDS.txt +0 -49
- paper/build_manuscript.py +0 -121
- paper/figures/figure1_interface.pdf +0 -3
- paper/figures/figure1_interface.png +0 -3
- paper/figures/figure2_model_size.pdf +0 -0
- paper/figures/figure2_model_size.png +0 -3
- paper/figures/figure3_lysozyme.pdf +0 -0
- paper/figures/figure3_lysozyme.png +0 -3
- paper/make_figure1.py +0 -92
- paper/make_figures.py +0 -164
- paper/panels/panelA_interface.png +0 -3
- paper/panels/panelB_table.png +0 -3
- paper/panels/panelC_structure.png +0 -3
- scripts/sync_space.py +14 -4
.gitignore
CHANGED
|
@@ -63,3 +63,6 @@ images/DeepMutate-3D_light.zip
|
|
| 63 |
# Built manuscript outputs (regenerate with paper/build_manuscript.py)
|
| 64 |
paper/*.docx
|
| 65 |
paper/*.html
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
# Built manuscript outputs (regenerate with paper/build_manuscript.py)
|
| 64 |
paper/*.docx
|
| 65 |
paper/*.html
|
| 66 |
+
|
| 67 |
+
# The manuscript lives on Zenodo (DOI 10.5281/zenodo.22679613), not in the code repo
|
| 68 |
+
paper/
|
CITATION.cff
CHANGED
|
@@ -23,6 +23,7 @@ keywords:
|
|
| 23 |
- variant effect prediction
|
| 24 |
- deep mutational scanning
|
| 25 |
- structural bioinformatics
|
|
|
|
| 26 |
license: Apache-2.0
|
| 27 |
version: 0.1.0
|
| 28 |
date-released: "2026-09-07"
|
|
|
|
| 23 |
- variant effect prediction
|
| 24 |
- deep mutational scanning
|
| 25 |
- structural bioinformatics
|
| 26 |
+
doi: "10.5281/zenodo.22679613"
|
| 27 |
license: Apache-2.0
|
| 28 |
version: 0.1.0
|
| 29 |
date-released: "2026-09-07"
|
README.md
CHANGED
|
@@ -36,6 +36,7 @@ damaging. Blue marks positions that tolerate change.
|
|
| 36 |
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License"></a>
|
| 37 |
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10%2B-blue.svg" alt="Python"></a>
|
| 38 |
<a href="https://huggingface.co/spaces/ras1992/DeepMutate-3D"><img src="https://img.shields.io/badge/%F0%9F%A4%97-Live%20Demo-yellow" alt="Live Demo"></a>
|
|
|
|
| 39 |
</p>
|
| 40 |
|
| 41 |
## Contents
|
|
@@ -146,8 +147,12 @@ python examples/use_cases.py
|
|
| 146 |
|
| 147 |
## Citation
|
| 148 |
|
| 149 |
-
If you use DeepMutate-3D, please cite
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
- Lin, Z. et al. Evolutionary-scale prediction of atomic-level protein structure with a language model. Science 379, 1123-1130 (2023).
|
| 153 |
- Meier, J. et al. Language models enable zero-shot prediction of the effects of mutations on protein function. NeurIPS (2021).
|
|
|
|
| 36 |
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License"></a>
|
| 37 |
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.10%2B-blue.svg" alt="Python"></a>
|
| 38 |
<a href="https://huggingface.co/spaces/ras1992/DeepMutate-3D"><img src="https://img.shields.io/badge/%F0%9F%A4%97-Live%20Demo-yellow" alt="Live Demo"></a>
|
| 39 |
+
<a href="https://doi.org/10.5281/zenodo.22679613"><img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.22679613-blue" alt="DOI"></a>
|
| 40 |
</p>
|
| 41 |
|
| 42 |
## Contents
|
|
|
|
| 147 |
|
| 148 |
## Citation
|
| 149 |
|
| 150 |
+
If you use DeepMutate-3D, please cite the preprint:
|
| 151 |
+
|
| 152 |
+
> Karim, R. DeepMutate-3D: interactive protein language model mutation scanning
|
| 153 |
+
> on predicted structures. Zenodo (2026). https://doi.org/10.5281/zenodo.22679613
|
| 154 |
+
|
| 155 |
+
and the underlying resources. AlphaFold data is CC-BY-4.0 and requires attribution.
|
| 156 |
|
| 157 |
- Lin, Z. et al. Evolutionary-scale prediction of atomic-level protein structure with a language model. Science 379, 1123-1130 (2023).
|
| 158 |
- Meier, J. et al. Language models enable zero-shot prediction of the effects of mutations on protein function. NeurIPS (2021).
|
paper/DeepMutate-3D_pdf.pdf
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b6934a4cd354344166a0e302863d4227418799d2a77cdaed1c2c339dfdacea75
|
| 3 |
-
size 1750295
|
|
|
|
|
|
|
|
|
|
|
|
paper/DeepMutate-3D_preprint.md
DELETED
|
@@ -1,512 +0,0 @@
|
|
| 1 |
-
# DeepMutate-3D: interactive protein language model mutation scanning on predicted structures
|
| 2 |
-
|
| 3 |
-
**Rashid Karim**
|
| 4 |
-
|
| 5 |
-
Independent Researcher, Cambridge, MA, USA
|
| 6 |
-
|
| 7 |
-
Correspondence: rashidsaadman@gmail.com
|
| 8 |
-
|
| 9 |
-
ORCID: https://orcid.org/0000-0002-5179-5259
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
## Abstract
|
| 13 |
-
|
| 14 |
-
**Motivation.** Variant effect predictions are most interpretable when read
|
| 15 |
-
against structure, and this is already available for human proteins: the
|
| 16 |
-
AlphaFold database displays AlphaMissense pathogenicity as a residue-level heat
|
| 17 |
-
map on the predicted fold [8], and proteome-wide language model predictions have
|
| 18 |
-
been published with web portals [9]. Those resources are precomputed for the human proteome, and the
|
| 19 |
-
AlphaMissense weights are not publicly released, so they cannot be applied to
|
| 20 |
-
other organisms at all. AlphaFold models are available for essentially all of them, spanning over 214
|
| 21 |
-
million sequences across UniProt [4], but no precomputed variant scores
|
| 22 |
-
accompany those structures. A researcher working on a bacterial enzyme, a
|
| 23 |
-
viral protein or an engineered variant must therefore assemble model,
|
| 24 |
-
structure and visualisation themselves.
|
| 25 |
-
|
| 26 |
-
**Results.** DeepMutate-3D scores all 19 possible substitutions at every
|
| 27 |
-
position of a protein using ESM-2 log-likelihood ratios, condenses them into a
|
| 28 |
-
per-residue sensitivity score, retrieves the matching AlphaFold model, and
|
| 29 |
-
paints the scores onto the structure as an interactive heat map in a web
|
| 30 |
-
browser. Predictions are zero-shot. On the ProteinGym substitution benchmark
|
| 31 |
-
(217 assays, 696,311 measured variants) it reaches a mean Spearman correlation
|
| 32 |
-
of 0.425, within the range reported for ESM-2 650M. On 38,901 ClinVar variants
|
| 33 |
-
across 2,011 proteins it separates pathogenic from benign substitutions with a
|
| 34 |
-
mean per-protein AUROC of 0.881. Applied to proteins with independent ground
|
| 35 |
-
truth, it places the six TP53 cancer hotspots among the most constrained
|
| 36 |
-
positions of the DNA-binding domain (permutation p = 0.009) and ranks all eight
|
| 37 |
-
cysteines of lysozyme C's four disulfide bridges within the ten most constrained
|
| 38 |
-
of 147 positions (hypergeometric p = 1.0e-11).
|
| 39 |
-
|
| 40 |
-
Two comparisons made during validation generalise beyond this tool. Increasing
|
| 41 |
-
model capacity buys more than refining the scoring protocol: ESM-2 650M under
|
| 42 |
-
single-pass scoring exceeds ESM-2 150M under per-residue masked scoring while
|
| 43 |
-
using two orders of magnitude less computation. And benchmark rank correlation
|
| 44 |
-
does not predict functional-site recovery: two scoring modes separated by 0.007
|
| 45 |
-
mean Spearman on ProteinGym differ markedly on the case studies, recovering
|
| 46 |
-
eight versus six of the lysozyme disulfide cysteines.
|
| 47 |
-
|
| 48 |
-
**Availability.** https://huggingface.co/spaces/ras1992/DeepMutate-3D runs in a
|
| 49 |
-
browser with no installation or account, on shared NVIDIA hardware. Source,
|
| 50 |
-
validation scripts and all result files are at
|
| 51 |
-
https://github.com/Saadman/DeepMutate-3D under Apache-2.0.
|
| 52 |
-
|
| 53 |
-
**Keywords:** protein language model, variant effect prediction, deep mutational
|
| 54 |
-
scanning, AlphaFold, structural bioinformatics, ESM-2, web application
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
## 1. Introduction
|
| 58 |
-
|
| 59 |
-
Determining which residues in a protein tolerate mutation is a recurring
|
| 60 |
-
question in variant interpretation, enzyme engineering, and functional
|
| 61 |
-
annotation. Deep mutational scanning answers it experimentally but requires
|
| 62 |
-
months of work per protein. Computational predictors offer a fast alternative,
|
| 63 |
-
and protein language models in particular have proven capable of zero-shot
|
| 64 |
-
variant effect prediction: trained only to reconstruct masked residues across
|
| 65 |
-
evolutionary sequence data, they implicitly learn the constraints that shape
|
| 66 |
-
protein families [1, 2].
|
| 67 |
-
|
| 68 |
-
The practical bottleneck is not accuracy but access and interpretation. A
|
| 69 |
-
predictor returns a score per substitution. Interpreting that score requires
|
| 70 |
-
knowing where the residue sits in the fold. A position scoring as highly
|
| 71 |
-
constrained is only actionable once one knows it lines a catalytic pocket rather
|
| 72 |
-
than a disordered terminus. Structural prediction has become universally
|
| 73 |
-
available [3, 4], yet in practice the score and the structure are produced by
|
| 74 |
-
different tools and joined by hand.
|
| 75 |
-
|
| 76 |
-
DeepMutate-3D closes that gap in a single interface. It is not a new scoring
|
| 77 |
-
method. The underlying computation is the masked-marginal log-likelihood ratio
|
| 78 |
-
of Meier et al. [2] applied to ESM-2 [1]. The contribution is integration and
|
| 79 |
-
accessibility: a scan that requires no installation, no model weights, and no
|
| 80 |
-
scripting, returning a structure that can be rotated and interrogated residue by
|
| 81 |
-
residue, together with exportable tables and coordinate files.
|
| 82 |
-
|
| 83 |
-
This combination is not new for human proteins. AlphaMissense [8] provides
|
| 84 |
-
pathogenicity predictions for the human proteome, and the AlphaFold database
|
| 85 |
-
renders them as an interactive residue-level heat map on the predicted
|
| 86 |
-
structure, so a researcher studying a human gene can already obtain
|
| 87 |
-
structure-contextualised variant scores in a browser. Brandes et al. [9]
|
| 88 |
-
similarly published ESM1b predictions for all human missense variants through a
|
| 89 |
-
web portal. Many further predictors are evaluated in ProteinGym [5].
|
| 90 |
-
|
| 91 |
-
Three gaps remain, and they define what this tool is for. First, those resources
|
| 92 |
-
cover the human proteome only. The AlphaMissense trained weights are not
|
| 93 |
-
publicly released, so the method cannot be applied to another organism even in
|
| 94 |
-
principle, although AlphaFold models exist for essentially all of them. ESM-2 is
|
| 95 |
-
distributed with open weights and runs on any input. Second, the human
|
| 96 |
-
predictions are precomputed over reference gene models, so an isolate variant,
|
| 97 |
-
a laboratory construct or any sequence absent from the reference proteome cannot
|
| 98 |
-
be scored. Third, AlphaMissense predictions are released under a non-commercial
|
| 99 |
-
licence, whereas ESM-2 is MIT-licensed, which matters for industrial use and for
|
| 100 |
-
redistribution.
|
| 101 |
-
|
| 102 |
-
These resources also answer a different question. AlphaMissense estimates the
|
| 103 |
-
probability that a variant causes human disease, a clinical endpoint. Ranking
|
| 104 |
-
positions by evolutionary constraint asks whether a residue tolerates
|
| 105 |
-
substitution at all, which is the question behind mutagenesis design, library
|
| 106 |
-
construction and functional site discovery. The two correlate but are not
|
| 107 |
-
interchangeable: a substitution can be clinically benign while still disrupting
|
| 108 |
-
an enzyme in vitro, and a residue can be constrained without any associated
|
| 109 |
-
disease phenotype.
|
| 110 |
-
|
| 111 |
-
One boundary should be stated plainly, because it follows from what the model
|
| 112 |
-
estimates. ESM-2 will return a score for any amino acid string, but the quantity
|
| 113 |
-
it estimates is evolutionary constraint inferred from UniRef50. The scores are
|
| 114 |
-
therefore informative for natural proteins from any organism, and for engineered
|
| 115 |
-
variants of natural proteins, which retain their family's evolutionary signal.
|
| 116 |
-
They are not informative for de novo designed sequences with no evolutionary
|
| 117 |
-
relatives, and Section 6 reports that such sequences score near zero at every
|
| 118 |
-
model size. The extension offered here is across organisms and across sequences
|
| 119 |
-
related to natural proteins, not across arbitrary strings.
|
| 120 |
-
|
| 121 |
-
DeepMutate-3D therefore does not compete on accuracy with human-specific
|
| 122 |
-
predictors, and no head-to-head comparison is attempted here. It extends
|
| 123 |
-
structure-contextualised, browser-based variant scanning to natural proteins of
|
| 124 |
-
any organism and to variants of them, under a permissive licence.
|
| 125 |
-
|
| 126 |
-
Because the tool wraps an established method, its value depends on the wrapper
|
| 127 |
-
being faithful. This note therefore reports validation on two independent
|
| 128 |
-
benchmarks, an ablation across model sizes, a comparison of scoring protocols,
|
| 129 |
-
and three case studies against ground truth that was established independently
|
| 130 |
-
of this work.
|
| 131 |
-
|
| 132 |
-
## 2. Implementation
|
| 133 |
-
|
| 134 |
-
### 2.1 Scoring
|
| 135 |
-
|
| 136 |
-
For a sequence of length L, position i, and candidate residue m, the model
|
| 137 |
-
computes a log-likelihood ratio against the wild-type residue:
|
| 138 |
-
|
| 139 |
-
```
|
| 140 |
-
LLR(i, m) = log P(m | context) - log P(wt_i | context)
|
| 141 |
-
```
|
| 142 |
-
|
| 143 |
-
Values near zero indicate that the model finds the substitution as plausible as
|
| 144 |
-
the wild-type residue; strongly negative values indicate a substitution the
|
| 145 |
-
model regards as unlikely given the evolutionary context. Because the quantity
|
| 146 |
-
is a ratio, it is insensitive to positions at which the model is uniformly
|
| 147 |
-
uncertain.
|
| 148 |
-
|
| 149 |
-
The 19 non-wild-type ratios at each position are averaged into a single Residue
|
| 150 |
-
Sensitivity Score:
|
| 151 |
-
|
| 152 |
-
```
|
| 153 |
-
S_i = (1/19) * sum over m != wt_i of LLR(i, m)
|
| 154 |
-
```
|
| 155 |
-
|
| 156 |
-
Two scoring protocols are provided. *Masked marginals* replaces position i with
|
| 157 |
-
a mask token before each forward pass, following Meier et al. [2], and costs one
|
| 158 |
-
forward pass per residue. *Wild-type marginals* uses a single forward pass over
|
| 159 |
-
the intact sequence, reading the output distribution at every position. Three
|
| 160 |
-
ESM-2 sizes are selectable (35M, 150M, 650M parameters).
|
| 161 |
-
|
| 162 |
-
### 2.2 Sequences longer than the model context
|
| 163 |
-
|
| 164 |
-
ESM-2 has a 1,024-token context, which after special tokens accommodates 1,022
|
| 165 |
-
residues. Longer proteins are covered with overlapping windows of 1,022 residues
|
| 166 |
-
at a stride of 766. Log-probabilities are accumulated in sequence space and
|
| 167 |
-
divided by a per-position visit count, so that every interior residue is scored
|
| 168 |
-
in two different contexts and averaged. The overlap avoids the systematic error
|
| 169 |
-
that arises when a residue falls at a hard window boundary with no downstream
|
| 170 |
-
context.
|
| 171 |
-
|
| 172 |
-
### 2.3 Structure retrieval and mapping
|
| 173 |
-
|
| 174 |
-
The predicted structure is retrieved from the AlphaFold Protein Structure
|
| 175 |
-
Database [4] by UniProt accession, queried through the prediction API so that
|
| 176 |
-
the current model version is used rather than a hard-coded filename. Sensitivity
|
| 177 |
-
scores are written into the B-factor column of the PDB record, replacing pLDDT,
|
| 178 |
-
which allows 3Dmol.js [6] to colour the cartoon representation by a numeric
|
| 179 |
-
property without server-side rendering. The colour scale is a red-white-blue gradient with
|
| 180 |
-
symmetric limits, placing the neutral midpoint at exactly zero so that colour is
|
| 181 |
-
comparable across proteins. Exported coordinate files carry REMARK records
|
| 182 |
-
documenting that the B-factor column no longer contains pLDDT.
|
| 183 |
-
|
| 184 |
-
### 2.4 Interface and deployment
|
| 185 |
-
|
| 186 |
-
The application is a single-file Gradio program. Hovering any point on the
|
| 187 |
-
structure reports the residue's sensitivity score, its categorical verdict, and
|
| 188 |
-
its most damaging and most tolerated substitutions. Results are exportable as a
|
| 189 |
-
CSV table and as a scored PDB file that opens directly in PyMOL or ChimeraX.
|
| 190 |
-
|
| 191 |
-
The deployed instance runs on Hugging Face Spaces using dynamically allocated
|
| 192 |
-
NVIDIA hardware, with GPU time reserved per request in proportion to the size of
|
| 193 |
-
the job. The same source runs unmodified on CUDA, Apple Silicon, or CPU.
|
| 194 |
-
|
| 195 |
-
## 3. Validation
|
| 196 |
-
|
| 197 |
-
All evaluations are zero-shot. No experimental or clinical measurement is shown
|
| 198 |
-
to the model at any point.
|
| 199 |
-
|
| 200 |
-
### 3.1 Mutation effect prediction
|
| 201 |
-
|
| 202 |
-
ProteinGym [5] aggregates deep mutational scanning experiments into a common
|
| 203 |
-
benchmark. Predictions were generated for every measured single substitution and
|
| 204 |
-
correlated with experimental fitness per assay using Spearman's rho.
|
| 205 |
-
|
| 206 |
-
**Table 1.** ProteinGym substitution benchmark, 217 assays, 696,311 variants,
|
| 207 |
-
wild-type marginal scoring.
|
| 208 |
-
|
| 209 |
-
| Model | Mean rho | Median rho | rho > 0.3 | rho > 0.5 | Compute |
|
| 210 |
-
| --- | --- | --- | --- | --- | --- |
|
| 211 |
-
| ESM-2 35M | 0.291 | 0.321 | 51% | 19% | 17 s |
|
| 212 |
-
| ESM-2 150M | 0.383 | 0.430 | 70% | 35% | 19 s |
|
| 213 |
-
| ESM-2 650M | **0.425** | 0.477 | 77% | 44% | 47 s |
|
| 214 |
-
|
| 215 |
-
The deployed configuration (650M) reaches 0.425. Published values for ESM-2
|
| 216 |
-
650M on this benchmark are in the region of 0.41 to 0.42. The present figure is
|
| 217 |
-
therefore in the expected range, but it should not be read as outperforming
|
| 218 |
-
those reports: scoring protocol, assay filtering, and aggregation scheme all
|
| 219 |
-
differ between published evaluations, and the comparison here is indicative
|
| 220 |
-
rather than exact. The purpose of Table 1 is to establish that the wrapper does
|
| 221 |
-
not degrade the underlying method, not to claim an improvement over it.
|
| 222 |
-
|
| 223 |
-
### 3.2 Scoring protocol
|
| 224 |
-
|
| 225 |
-
Masked and wild-type marginal scoring were compared pairwise on an identical
|
| 226 |
-
subset of 197 assays at 150M parameters.
|
| 227 |
-
|
| 228 |
-
**Table 2.** Paired comparison of scoring protocols, 197 assays, ESM-2 150M.
|
| 229 |
-
|
| 230 |
-
| Protocol | Mean rho | Median rho | Compute |
|
| 231 |
-
| --- | --- | --- | --- |
|
| 232 |
-
| Wild-type marginals | 0.392 | 0.441 | 11 s |
|
| 233 |
-
| Masked marginals | 0.399 | 0.453 | 4,903 s |
|
| 234 |
-
|
| 235 |
-
Masked marginals is superior on 72.1% of assays, but the paired mean difference
|
| 236 |
-
is +0.0069 (95% CI +0.0050 to +0.0089) for 434 times the compute. The
|
| 237 |
-
theoretically preferable protocol therefore buys a real but very small
|
| 238 |
-
improvement at large cost.
|
| 239 |
-
|
| 240 |
-
Read alongside Table 1, this yields the practically useful observation that
|
| 241 |
-
compute is better spent on model capacity than on scoring protocol: ESM-2 650M
|
| 242 |
-
under wild-type marginals (rho 0.425) exceeds ESM-2 150M under masked marginals
|
| 243 |
-
(rho 0.399) while using two orders of magnitude less computation. This
|
| 244 |
-
comparison was performed at 150M; the corresponding measurement at 650M was not
|
| 245 |
-
made, and the claim is not generalised beyond the model size tested.
|
| 246 |
-
|
| 247 |
-
### 3.3 Clinical variant classification
|
| 248 |
-
|
| 249 |
-
An independent task on independent data. Using the ClinVar substitution set
|
| 250 |
-
curated within ProteinGym, variants of each protein were ranked by predicted
|
| 251 |
-
damage and scored by AUROC against their pathogenic or benign annotation.
|
| 252 |
-
|
| 253 |
-
**Table 3.** ClinVar classification, 2,011 proteins, 38,901 variants
|
| 254 |
-
(22,669 pathogenic), ESM-2 650M.
|
| 255 |
-
|
| 256 |
-
| Metric | Value |
|
| 257 |
-
| --- | --- |
|
| 258 |
-
| Mean per-protein AUROC | **0.881** |
|
| 259 |
-
| Median per-protein AUROC | 0.931 |
|
| 260 |
-
| Proteins with AUROC > 0.7 | 89.4% |
|
| 261 |
-
| Pooled AUROC, per-protein z-scored | 0.771 |
|
| 262 |
-
| Pooled AUROC, raw scores | 0.868 |
|
| 263 |
-
|
| 264 |
-
Per-protein AUROC is the primary metric because it matches the clinical
|
| 265 |
-
question: given the variants observed in one gene, which are most likely to be
|
| 266 |
-
damaging. Raw scores are not comparable between proteins, so pooled analysis
|
| 267 |
-
requires per-protein standardisation; the pooled figure is lower than the mean
|
| 268 |
-
per-protein figure because pooling mixes proteins of differing discriminability.
|
| 269 |
-
Section 6 discusses the limitations of ClinVar as a benchmark.
|
| 270 |
-
|
| 271 |
-
### 3.4 Runtime
|
| 272 |
-
|
| 273 |
-
**Table 4.** Inference time, ESM-2 650M, identical proteins. CPU and Apple
|
| 274 |
-
Silicon measured on an Apple M3 (6 threads for CPU); NVIDIA figures from
|
| 275 |
-
dynamically allocated Hugging Face hardware, taking the minimum of repeated
|
| 276 |
-
calls to exclude allocation overhead.
|
| 277 |
-
|
| 278 |
-
| Protein | Length | Protocol | M3 CPU | M3 GPU (mps) | NVIDIA |
|
| 279 |
-
| --- | --- | --- | --- | --- | --- |
|
| 280 |
-
| Haemoglobin alpha | 142 | wild-type | 0.41 s | 0.09 s | 0.18 s |
|
| 281 |
-
| Haemoglobin alpha | 142 | masked | 30.98 s | 7.82 s | 1.45 s |
|
| 282 |
-
| p53 | 393 | wild-type | 0.78 s | 0.18 s | 0.18 s |
|
| 283 |
-
| p53 | 393 | masked | 236.19 s | 62.27 s | 10.99 s |
|
| 284 |
-
| SARS-CoV-2 spike | 1,273 | wild-type | 3.50 s | 0.87 s | 0.31 s |
|
| 285 |
-
| SARS-CoV-2 spike | 1,273 | masked | not run | not run | 152.33 s |
|
| 286 |
-
|
| 287 |
-
Wild-type marginal scoring is fast on all hardware; the complete 1,273-residue
|
| 288 |
-
spike protein is scored in 3.50 s on CPU and under a second on either GPU. GPU acceleration
|
| 289 |
-
matters for masked marginal scoring, where it delivers a 5.4 to 5.7-fold
|
| 290 |
-
speed-up at matched protein length and where the advantage grows with length
|
| 291 |
-
because attention cost scales quadratically. On small jobs under the fast
|
| 292 |
-
protocol, dynamically allocated GPUs are slower than a laptop, because a fixed
|
| 293 |
-
allocation overhead of approximately one second dominates.
|
| 294 |
-
|
| 295 |
-
## 4. Worked examples
|
| 296 |
-
|
| 297 |
-
Benchmarks establish that the scores are calibrated. These three examples test
|
| 298 |
-
whether they answer questions a researcher would pose, each against ground
|
| 299 |
-
truth established independently of this work.
|
| 300 |
-
|
| 301 |
-
Both scoring modes are reported. This turns out to matter: Section 3.2 showed
|
| 302 |
-
the two modes differ by only 0.007 mean Spearman on ProteinGym, yet they differ
|
| 303 |
-
substantially here. Rank correlation across a whole deep mutational scan and
|
| 304 |
-
recovery of a handful of functional residues are not the same task, and a
|
| 305 |
-
benchmark that measures the first does not settle the second.
|
| 306 |
-
|
| 307 |
-
### 4.1 Prioritising positions for mutagenesis
|
| 308 |
-
|
| 309 |
-
Tumour sequencing has identified six positions accounting for a large share of
|
| 310 |
-
TP53 missense mutations. Scanning the sequence alone, with no cancer data,
|
| 311 |
-
places those six at a median constraint percentile of 92.5 under masked
|
| 312 |
-
marginals and 93.4 under wildtype marginals, with four of six in the most
|
| 313 |
-
constrained tenth of the protein under either mode.
|
| 314 |
-
|
| 315 |
-
Against 20,000 random six-position draws from the DNA-binding domain, where all
|
| 316 |
-
six hotspots lie, p = 0.009 (masked). Drawing from the whole protein gives
|
| 317 |
-
p = 0.0007, but that null is too permissive: TP53's disordered terminal regions
|
| 318 |
-
are trivially unconstrained, so the domain-restricted value is the one to cite.
|
| 319 |
-
|
| 320 |
-
For a gene with an established hotspot catalogue the tool recovers what is
|
| 321 |
-
already known. For one without, the same ranking provides a prioritised
|
| 322 |
-
shortlist for panel design or functional follow-up.
|
| 323 |
-
|
| 324 |
-
### 4.2 Locating functional sites in uncharacterised proteins
|
| 325 |
-
|
| 326 |
-
Six enzymes were selected before scoring on two criteria: curated UniProt active
|
| 327 |
-
site or binding site annotations, and a length within the model context. No
|
| 328 |
-
enzyme was examined and then discarded.
|
| 329 |
-
|
| 330 |
-
| Mode | Panel median percentile | Enzymes at p < 0.01 |
|
| 331 |
-
| --- | --- | --- |
|
| 332 |
-
| Masked marginals | 86.8 | 4 of 6 |
|
| 333 |
-
| Wildtype marginals | 80.6 | 3 of 6 |
|
| 334 |
-
|
| 335 |
-
Under masked marginals, TEM-1 beta-lactamase reaches p = 0.0001,
|
| 336 |
-
phosphoglycerate kinase 1 p = 0.00005, GAPDH p = 0.00015 and carbonic anhydrase
|
| 337 |
-
2 p = 0.005. Two enzymes fail in both modes. Lysozyme C has three annotated
|
| 338 |
-
sites, too few for significance however well they rank. Cationic trypsin
|
| 339 |
-
(p = 0.081 masked) has an annotation set mixing substrate-binding with catalytic
|
| 340 |
-
residues, and binding residues sit under weaker evolutionary constraint than
|
| 341 |
-
catalytic ones.
|
| 342 |
-
|
| 343 |
-
Carbonic anhydrase 2 illustrates the mode dependence: significant under masked
|
| 344 |
-
marginals (p = 0.005) but not under wildtype (p = 0.101). Users pursuing
|
| 345 |
-
functional site discovery should select masked marginals rather than accept the
|
| 346 |
-
default.
|
| 347 |
-
|
| 348 |
-
### 4.3 Selecting positions for library design
|
| 349 |
-
|
| 350 |
-
Directed evolution requires the inverse question answered: which positions
|
| 351 |
-
tolerate substitution. Lysozyme C, 147 residues, provides a check at the
|
| 352 |
-
constrained end, because UniProt annotates four disulfide bridges
|
| 353 |
-
(C24-C145, C48-C133, C82-C98, C94-C112) whose eight cysteines should be
|
| 354 |
-
essentially unsubstitutable.
|
| 355 |
-
|
| 356 |
-
| Mode | Disulfide cysteines in the ten most constrained positions | Exact p |
|
| 357 |
-
| --- | --- | --- |
|
| 358 |
-
| Masked marginals | 8 of 8 | 1.0e-11 |
|
| 359 |
-
| Wildtype marginals | 6 of 8 | 4.4e-07 |
|
| 360 |
-
|
| 361 |
-
Under masked marginals the remaining two positions are a buried glycine and a
|
| 362 |
-
conserved tryptophan in the substrate-binding cleft. The model received sequence
|
| 363 |
-
alone: no structure, no annotation, no experimental data.
|
| 364 |
-
|
| 365 |
-
One qualification applies. Cysteines are constrained as a class, reaching a
|
| 366 |
-
median constraint percentile of 96.6 in lysozyme and 90.2 in trypsin against a
|
| 367 |
-
non-cysteine median near 48, so part of this effect is generic rather than
|
| 368 |
-
specific to disulfide bonding. A partial control exists in carbonic anhydrase 2,
|
| 369 |
-
whose single cysteine forms no disulfide bond and reaches only the 40.5
|
| 370 |
-
percentile, below the protein median. This suggests the model distinguishes
|
| 371 |
-
bonded from free cysteines rather than merely conserving the residue type, but
|
| 372 |
-
with a single control it remains suggestive rather than established.
|
| 373 |
-
|
| 374 |
-
The tolerant end of the ranking carries no comparable external check. Positions
|
| 375 |
-
reported as substitution-tolerant are the model's own output, and this work does
|
| 376 |
-
not verify experimentally that they tolerate mutation. That claim awaits a
|
| 377 |
-
prospective test. Established stability predictors address a related but
|
| 378 |
-
distinct question, the free energy change on substitution, and are the
|
| 379 |
-
appropriate tool where thermodynamic stability rather than evolutionary
|
| 380 |
-
tolerance is the target.
|
| 381 |
-
|
| 382 |
-
## 5. Operation
|
| 383 |
-
|
| 384 |
-
A scan requires a UniProt accession. Leaving the sequence field empty retrieves
|
| 385 |
-
the canonical sequence from UniProt [7] automatically, which guarantees that
|
| 386 |
-
scores and structure share residue numbering; mismatched numbering is the most common source of
|
| 387 |
-
silent error when the two are assembled by hand.
|
| 388 |
-
|
| 389 |
-
Three outputs are produced. The interactive structure provides spatial context,
|
| 390 |
-
with a hover readout giving each position's score, verdict and extreme
|
| 391 |
-
substitutions. The per-residue table, exportable as CSV, provides the ranking
|
| 392 |
-
for downstream prioritisation. The scored PDB carries sensitivity in the
|
| 393 |
-
B-factor column, so it opens directly in PyMOL or ChimeraX and can be coloured
|
| 394 |
-
with a single command, which is the path from a browser scan to a publication
|
| 395 |
-
figure.
|
| 396 |
-
|
| 397 |
-
No installation, model download or account is required. A 142-residue protein
|
| 398 |
-
completes in approximately four seconds. Detailed usage documentation is
|
| 399 |
-
maintained with the source code rather than reproduced here.
|
| 400 |
-
|
| 401 |
-
## 6. Limitations
|
| 402 |
-
|
| 403 |
-
The scoring method presented here is not novel. It is the established
|
| 404 |
-
masked-marginal procedure of Meier et al. [2] applied to ESM-2, and Section 3.1
|
| 405 |
-
reproduces rather than improves upon published performance. The contribution is
|
| 406 |
-
integration and accessibility, and the validation exists to demonstrate that the
|
| 407 |
-
wrapper is faithful to the underlying method, not to advance it.
|
| 408 |
-
|
| 409 |
-
The benchmarks establish less than their headline figures suggest. ClinVar is an
|
| 410 |
-
imperfect standard: pathogenic annotations are enriched in conserved functional
|
| 411 |
-
domains and benign annotations in tolerant regions, which inflates apparent
|
| 412 |
-
performance relative to prospective clinical use, and some submissions
|
| 413 |
-
incorporate computational predictions, introducing partial circularity. The
|
| 414 |
-
AUROC in Table 3 should therefore be read as evidence that the score behaves
|
| 415 |
-
sensibly on clinically annotated variation, not as an estimate of diagnostic
|
| 416 |
-
accuracy. Section 4 further shows that ProteinGym rank correlation does not
|
| 417 |
-
predict functional-site recovery, since two scoring modes separated by 0.007
|
| 418 |
-
mean Spearman differ substantially on the worked examples. Any single benchmark
|
| 419 |
-
number should be treated as narrower evidence than it appears. Within the worked
|
| 420 |
-
examples, only the constrained end of the ranking is externally validated;
|
| 421 |
-
positions reported as substitution-tolerant are the model's own output, and no
|
| 422 |
-
experiment in this work confirms that they tolerate mutation.
|
| 423 |
-
|
| 424 |
-
Two classes of protein are poorly served. Designed sequences with no
|
| 425 |
-
evolutionary history, such as engineered fluorescent proteins, score near zero
|
| 426 |
-
at every model size, which is expected because the method estimates
|
| 427 |
-
evolutionary constraint and there is none to estimate. Fast-evolving viral
|
| 428 |
-
surface proteins also scored near zero at 150M parameters, but influenza
|
| 429 |
-
haemagglutinin recovers to rho 0.46 at 650M, so that failure reflected model
|
| 430 |
-
capacity rather than a property of the approach and may recede further with
|
| 431 |
-
larger models.
|
| 432 |
-
|
| 433 |
-
Three narrower caveats apply to interpretation. Averaging the 19 substitutions
|
| 434 |
-
at a position discards direction, since a residue may tolerate conservative
|
| 435 |
-
changes while forbidding drastic ones, which is why the interface also reports
|
| 436 |
-
the extreme substitutions at each position. AlphaFold monomer models are used
|
| 437 |
-
throughout, so residues that matter only within a complex are under-weighted.
|
| 438 |
-
For proteins beyond 1,022 residues, scores depend marginally on where sliding
|
| 439 |
-
window boundaries fall.
|
| 440 |
-
|
| 441 |
-
Finally, and most importantly for anyone considering clinical application: this
|
| 442 |
-
method predicts evolutionary constraint, which correlates with but is not
|
| 443 |
-
identical to pathogenicity. DeepMutate-3D is a research tool for hypothesis
|
| 444 |
-
generation and must not be used to inform diagnostic or treatment decisions.
|
| 445 |
-
|
| 446 |
-
## 7. Figures
|
| 447 |
-
|
| 448 |
-
**Figure 1. The DeepMutate-3D interface**, scanning haemoglobin subunit alpha
|
| 449 |
-
(UniProt P69905, 142 residues) with ESM-2 650M under masked-marginal scoring.
|
| 450 |
-
(A) The complete interface: sequence and accession inputs, model and scoring
|
| 451 |
-
controls, CSV and PDB downloads, and a summary reporting the device, model,
|
| 452 |
-
inference time and the most constrained residues. The scan shown ran on
|
| 453 |
-
dynamically allocated NVIDIA hardware in 3.99 s, 28.1 ms per residue.
|
| 454 |
-
(B) The per-residue table, giving the sensitivity score, a categorical verdict,
|
| 455 |
-
and the most damaging and most tolerated substitution at each position.
|
| 456 |
-
(C) The AlphaFold model painted by residue sensitivity, with the hover readout
|
| 457 |
-
for H88. UniProt annotates this position as the proximal haem b binding
|
| 458 |
-
residue, and the scan ranks it third most constrained of 142 positions, in the
|
| 459 |
-
top 2%, having seen only the sequence. Red marks constrained positions and blue
|
| 460 |
-
substitution-tolerant ones, with the neutral midpoint fixed at zero so colour is
|
| 461 |
-
comparable between proteins.
|
| 462 |
-
Panels B and C are laid out as the application presents them.
|
| 463 |
-
|
| 464 |
-
**Figure 2. Effect of model size on ProteinGym.** (A) Empirical cumulative
|
| 465 |
-
distribution of per-assay Spearman correlation for three ESM-2 sizes across 217
|
| 466 |
-
assays. The distribution shifts uniformly rightward with model capacity rather
|
| 467 |
-
than improving only on easy assays. (B) Paired per-assay difference between
|
| 468 |
-
650M and 150M. Pairing removes between-assay variance; the mean gain is +0.041
|
| 469 |
-
and 71% of assays improve.
|
| 470 |
-
|
| 471 |
-
**Figure 3. Sensitivity along the lysozyme C sequence.** Per-residue sensitivity
|
| 472 |
-
for all 147 positions under ESM-2 650M with masked marginals, with the eight
|
| 473 |
-
cysteines forming the four UniProt-annotated disulfide bridges marked. They
|
| 474 |
-
occupy ranks 1, 2, 3, 5, 6, 7, 8 and 10 of 147. Under wildtype marginals six of
|
| 475 |
-
the eight fall in the ten most constrained positions. The dashed line is the
|
| 476 |
-
protein median.
|
| 477 |
-
|
| 478 |
-
## 8. Availability
|
| 479 |
-
|
| 480 |
-
Source code, validation scripts, and all result files are at
|
| 481 |
-
https://github.com/Saadman/DeepMutate-3D under Apache-2.0. The web application
|
| 482 |
-
is at https://huggingface.co/spaces/ras1992/DeepMutate-3D. Every table in this
|
| 483 |
-
note is reproducible from the scripts in `validation/` and `examples/`.
|
| 484 |
-
|
| 485 |
-
DeepMutate-3D retrieves but does not redistribute ESM-2 (MIT), AlphaFold
|
| 486 |
-
structures (CC-BY-4.0), and UniProt sequences (CC-BY-4.0).
|
| 487 |
-
|
| 488 |
-
## Acknowledgements
|
| 489 |
-
|
| 490 |
-
This work uses ESM-2 from Meta AI, the AlphaFold Protein Structure Database from
|
| 491 |
-
DeepMind and EMBL-EBI, UniProt, ProteinGym, and 3Dmol.js. Computation used
|
| 492 |
-
Hugging Face Spaces.
|
| 493 |
-
|
| 494 |
-
## References
|
| 495 |
-
|
| 496 |
-
1\. Lin Z, Akin H, Rao R, et al. Evolutionary-scale prediction of atomic-level protein structure with a language model. *Science* 379(6637):1123-1130 (2023).
|
| 497 |
-
|
| 498 |
-
2\. Meier J, Rao R, Verkuil R, et al. Language models enable zero-shot prediction of the effects of mutations on protein function. *Advances in Neural Information Processing Systems* 34:29287-29303 (2021).
|
| 499 |
-
|
| 500 |
-
3\. Jumper J, Evans R, Pritzel A, et al. Highly accurate protein structure prediction with AlphaFold. *Nature* 596(7873):583-589 (2021).
|
| 501 |
-
|
| 502 |
-
4\. Varadi M, Bertoni D, Magana P, et al. AlphaFold Protein Structure Database in 2024: providing structure coverage for over 214 million protein sequences. *Nucleic Acids Research* 52(D1):D368-D375 (2024).
|
| 503 |
-
|
| 504 |
-
5\. Notin P, Kollasch A, Ritter D, et al. ProteinGym: large-scale benchmarks for protein fitness prediction and design. *Advances in Neural Information Processing Systems* 36 (2023).
|
| 505 |
-
|
| 506 |
-
6\. Rego N, Koes D. 3Dmol.js: molecular visualization with WebGL. *Bioinformatics* 31(8):1322-1324 (2015).
|
| 507 |
-
|
| 508 |
-
7\. The UniProt Consortium. UniProt: the Universal Protein Knowledgebase in 2025. *Nucleic Acids Research* 53(D1):D609-D617 (2025).
|
| 509 |
-
|
| 510 |
-
8\. Cheng J, Novati G, Pan J, et al. Accurate proteome-wide missense variant effect prediction with AlphaMissense. *Science* 381(6664):eadg7492 (2023).
|
| 511 |
-
|
| 512 |
-
9\. Brandes N, Goldman G, Wang CH, Ye CJ, Ntranos V. Genome-wide prediction of disease variant effects with a deep protein language model. *Nature Genetics* 55:1512-1522 (2023).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper/DeepMutate-3D_preprint.pdf
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:78920e35a0ebdc642ea1e4b0479422c90fee0b2b929102d11721b0e32daa22d3
|
| 3 |
-
size 1675186
|
|
|
|
|
|
|
|
|
|
|
|
paper/SUBMISSION_FIELDS.txt
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
bioRxiv submission fields for DeepMutate-3D
|
| 2 |
-
|
| 3 |
-
ROUTING QUESTION Biological research
|
| 4 |
-
Manuscript type New Results
|
| 5 |
-
Subject category Bioinformatics
|
| 6 |
-
|
| 7 |
-
================================ TITLE ================================
|
| 8 |
-
DeepMutate-3D: interactive protein language model mutation scanning on predicted structures
|
| 9 |
-
|
| 10 |
-
================================ AUTHOR ===============================
|
| 11 |
-
First name Rashid
|
| 12 |
-
Last name Karim
|
| 13 |
-
Email rashidsaadman@gmail.com
|
| 14 |
-
ORCID 0000-0002-5179-5259
|
| 15 |
-
Institution Independent Researcher
|
| 16 |
-
City / Country Cambridge, MA, USA
|
| 17 |
-
Corresponding yes (sole author)
|
| 18 |
-
|
| 19 |
-
=============================== ABSTRACT ==============================
|
| 20 |
-
Motivation. Variant effect predictions are most interpretable when read against structure, and this is already available for human proteins: the AlphaFold database displays AlphaMissense pathogenicity as a residue-level heat map on the predicted fold, and proteome-wide language model predictions have been published with web portals. Those resources are precomputed for the human proteome, and the AlphaMissense weights are not publicly released, so they cannot be applied to other organisms at all. AlphaFold models are available for essentially all of them, spanning over 214 million sequences across UniProt, but no precomputed variant scores accompany those structures. A researcher working on a bacterial enzyme, a viral protein or an engineered variant must therefore assemble model, structure and visualisation themselves.
|
| 21 |
-
|
| 22 |
-
Results. DeepMutate-3D scores all 19 possible substitutions at every position of a protein using ESM-2 log-likelihood ratios, condenses them into a per-residue sensitivity score, retrieves the matching AlphaFold model, and paints the scores onto the structure as an interactive heat map in a web browser. Predictions are zero-shot. On the ProteinGym substitution benchmark (217 assays, 696,311 measured variants) it reaches a mean Spearman correlation of 0.425, within the range reported for ESM-2 650M. On 38,901 ClinVar variants across 2,011 proteins it separates pathogenic from benign substitutions with a mean per-protein AUROC of 0.881. Applied to proteins with independent ground truth, it places the six TP53 cancer hotspots among the most constrained positions of the DNA-binding domain (permutation p = 0.009) and ranks all eight cysteines of lysozyme C's four disulfide bridges within the ten most constrained of 147 positions (hypergeometric p = 1.0e-11).
|
| 23 |
-
|
| 24 |
-
Two comparisons made during validation generalise beyond this tool. Increasing model capacity buys more than refining the scoring protocol: ESM-2 650M under single-pass scoring exceeds ESM-2 150M under per-residue masked scoring while using two orders of magnitude less computation. And benchmark rank correlation does not predict functional-site recovery: two scoring modes separated by 0.007 mean Spearman on ProteinGym differ markedly on the case studies, recovering eight versus six of the lysozyme disulfide cysteines.
|
| 25 |
-
|
| 26 |
-
Availability. https://huggingface.co/spaces/ras1992/DeepMutate-3D runs in a browser with no installation or account, on shared NVIDIA hardware. Source, validation scripts and all result files are at https://github.com/Saadman/DeepMutate-3D under Apache-2.0.
|
| 27 |
-
|
| 28 |
-
=============================== KEYWORDS ==============================
|
| 29 |
-
protein language model, variant effect prediction, deep mutational scanning, AlphaFold, structural bioinformatics, ESM-2, web application
|
| 30 |
-
|
| 31 |
-
================================ FILE =================================
|
| 32 |
-
paper/DeepMutate-3D_preprint.docx
|
| 33 |
-
Figures are embedded. No separate figure upload needed.
|
| 34 |
-
|
| 35 |
-
========================= STANDARD QUESTIONS ==========================
|
| 36 |
-
License CC-BY 4.0
|
| 37 |
-
Competing interests None
|
| 38 |
-
Funding None (self-funded)
|
| 39 |
-
Previously published No
|
| 40 |
-
Under consideration No
|
| 41 |
-
Clinical trial No
|
| 42 |
-
Human/animal subjects No
|
| 43 |
-
Journal transfer offer Decline
|
| 44 |
-
|
| 45 |
-
Data availability
|
| 46 |
-
Code, validation scripts and all result files:
|
| 47 |
-
https://github.com/Saadman/DeepMutate-3D
|
| 48 |
-
Web application:
|
| 49 |
-
https://huggingface.co/spaces/ras1992/DeepMutate-3D
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper/build_manuscript.py
DELETED
|
@@ -1,121 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
"""Build submittable manuscript files from the markdown source.
|
| 3 |
-
|
| 4 |
-
Produces:
|
| 5 |
-
DeepMutate-3D_preprint.docx bioRxiv accepts Word directly
|
| 6 |
-
DeepMutate-3D_preprint.html standalone, figures embedded; print to PDF
|
| 7 |
-
|
| 8 |
-
Pandoc can emit PDF directly, but only through a LaTeX engine, and none is
|
| 9 |
-
installed here. Rather than require a TeX distribution, this script produces a
|
| 10 |
-
Word file (which bioRxiv accepts as-is) and a self-contained HTML file styled
|
| 11 |
-
for printing, which any browser turns into a clean PDF with Cmd+P.
|
| 12 |
-
|
| 13 |
-
python paper/build_manuscript.py
|
| 14 |
-
"""
|
| 15 |
-
|
| 16 |
-
from __future__ import annotations
|
| 17 |
-
|
| 18 |
-
import base64
|
| 19 |
-
import pathlib
|
| 20 |
-
import re
|
| 21 |
-
|
| 22 |
-
import pypandoc
|
| 23 |
-
|
| 24 |
-
HERE = pathlib.Path(__file__).resolve().parent
|
| 25 |
-
SRC = HERE / "DeepMutate-3D_preprint.md"
|
| 26 |
-
FIGURES = HERE / "figures"
|
| 27 |
-
|
| 28 |
-
# Inserted at each figure's caption so the images appear in the output.
|
| 29 |
-
FIGURE_FILES = {
|
| 30 |
-
"Figure 1.": "figure1_interface.png",
|
| 31 |
-
"Figure 2.": "figure2_model_size.png",
|
| 32 |
-
"Figure 3.": "figure3_lysozyme.png",
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
PRINT_CSS = """
|
| 36 |
-
@page { size: A4; margin: 22mm 20mm; }
|
| 37 |
-
body {
|
| 38 |
-
font-family: Georgia, "Times New Roman", serif;
|
| 39 |
-
font-size: 10.5pt; line-height: 1.5; color: #111;
|
| 40 |
-
max-width: 46em; margin: 0 auto;
|
| 41 |
-
}
|
| 42 |
-
h1 { font-size: 18pt; line-height: 1.25; margin: 0 0 .3em; }
|
| 43 |
-
h2 { font-size: 13pt; margin-top: 1.6em; border-bottom: 1px solid #ddd;
|
| 44 |
-
padding-bottom: .2em; }
|
| 45 |
-
h3 { font-size: 11.5pt; margin-top: 1.2em; }
|
| 46 |
-
table { border-collapse: collapse; width: 100%; font-size: 9.5pt;
|
| 47 |
-
margin: 1em 0; page-break-inside: avoid; }
|
| 48 |
-
th, td { border: 1px solid #ccc; padding: 5px 8px; text-align: left; }
|
| 49 |
-
th { background: #f4f4f2; }
|
| 50 |
-
code, pre { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 9pt; }
|
| 51 |
-
pre { background: #f7f7f5; padding: 10px 12px; border-radius: 4px;
|
| 52 |
-
overflow-x: auto; page-break-inside: avoid; }
|
| 53 |
-
img { max-width: 100%; height: auto; display: block; margin: 1em auto; }
|
| 54 |
-
p { text-align: justify; }
|
| 55 |
-
hr { border: none; border-top: 1px solid #ccc; margin: 1.5em 0; }
|
| 56 |
-
blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid #ddd;
|
| 57 |
-
color: #444; }
|
| 58 |
-
h2, h3 { page-break-after: avoid; }
|
| 59 |
-
"""
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
def with_figures(markdown: str) -> str:
|
| 63 |
-
"""Place each figure image immediately above its caption."""
|
| 64 |
-
for marker, filename in FIGURE_FILES.items():
|
| 65 |
-
path = FIGURES / filename
|
| 66 |
-
if not path.exists():
|
| 67 |
-
print(f" WARNING: {filename} missing, caption left without an image")
|
| 68 |
-
continue
|
| 69 |
-
pattern = re.compile(r"^(\*\*" + re.escape(marker) + r")", re.M)
|
| 70 |
-
markdown = pattern.sub(f"})\n\n\\1", markdown, count=1)
|
| 71 |
-
return markdown
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
def embed_images(html: str) -> str:
|
| 75 |
-
"""Inline every <img> as a data URI so the HTML is a single portable file."""
|
| 76 |
-
def repl(match):
|
| 77 |
-
src = match.group(1)
|
| 78 |
-
path = pathlib.Path(src)
|
| 79 |
-
if not path.is_absolute():
|
| 80 |
-
path = HERE / src
|
| 81 |
-
if not path.exists():
|
| 82 |
-
return match.group(0)
|
| 83 |
-
data = base64.b64encode(path.read_bytes()).decode()
|
| 84 |
-
return match.group(0).replace(src, f"data:image/png;base64,{data}")
|
| 85 |
-
return re.sub(r'<img[^>]+src="([^"]+)"', repl, html)
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
def main() -> int:
|
| 89 |
-
markdown = with_figures(SRC.read_text())
|
| 90 |
-
|
| 91 |
-
docx = HERE / "DeepMutate-3D_preprint.docx"
|
| 92 |
-
# bioRxiv recommends Times/Courier/Helvetica/Arial for reliable PDF
|
| 93 |
-
# conversion. Word's default theme uses Aptos and Consolas, so the build
|
| 94 |
-
# supplies a reference document with the fonts swapped.
|
| 95 |
-
extra = ["--standalone"]
|
| 96 |
-
reference = HERE / "reference.docx"
|
| 97 |
-
if reference.exists():
|
| 98 |
-
extra += ["--reference-doc", str(reference)]
|
| 99 |
-
pypandoc.convert_text(markdown, "docx", format="markdown",
|
| 100 |
-
outputfile=str(docx), extra_args=extra)
|
| 101 |
-
print(f" {docx.name:34s} {docx.stat().st_size // 1024} KB")
|
| 102 |
-
|
| 103 |
-
html = pypandoc.convert_text(
|
| 104 |
-
markdown, "html5", format="markdown",
|
| 105 |
-
extra_args=["--standalone", "--metadata", "pagetitle=DeepMutate-3D",
|
| 106 |
-
"--css=inline"])
|
| 107 |
-
html = html.replace('<link rel="stylesheet" href="inline" />',
|
| 108 |
-
f"<style>{PRINT_CSS}</style>")
|
| 109 |
-
html = embed_images(html)
|
| 110 |
-
out_html = HERE / "DeepMutate-3D_preprint.html"
|
| 111 |
-
out_html.write_text(html)
|
| 112 |
-
print(f" {out_html.name:34s} {out_html.stat().st_size // 1024} KB (standalone)")
|
| 113 |
-
|
| 114 |
-
print("\nTo produce the PDF:")
|
| 115 |
-
print(f" open {out_html}")
|
| 116 |
-
print(" then Cmd+P -> Save as PDF (enable 'Print backgrounds' for the tables)")
|
| 117 |
-
return 0
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
if __name__ == "__main__":
|
| 121 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper/figures/figure1_interface.pdf
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:c841922fe24647dbe82527812fefce413440ae98a9aa015c54cc6156e9095846
|
| 3 |
-
size 362324
|
|
|
|
|
|
|
|
|
|
|
|
paper/figures/figure1_interface.png
DELETED
Git LFS Details
|
paper/figures/figure2_model_size.pdf
DELETED
|
Binary file (36.5 kB)
|
|
|
paper/figures/figure2_model_size.png
DELETED
Git LFS Details
|
paper/figures/figure3_lysozyme.pdf
DELETED
|
Binary file (32.9 kB)
|
|
|
paper/figures/figure3_lysozyme.png
DELETED
Git LFS Details
|
paper/make_figure1.py
DELETED
|
@@ -1,92 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
"""Compose Figure 1 of the preprint from three interface screenshots.
|
| 3 |
-
|
| 4 |
-
Panels are captured separately at readable zoom rather than as one shrunken
|
| 5 |
-
full-page shot, then assembled here. Each is placed at its native aspect ratio;
|
| 6 |
-
nothing is stretched.
|
| 7 |
-
|
| 8 |
-
Panel order follows the application's own layout, so the figure maps directly
|
| 9 |
-
onto what a reader sees on screen.
|
| 10 |
-
|
| 11 |
-
python paper/make_figure1.py
|
| 12 |
-
"""
|
| 13 |
-
|
| 14 |
-
from __future__ import annotations
|
| 15 |
-
|
| 16 |
-
import pathlib
|
| 17 |
-
|
| 18 |
-
from PIL import Image, ImageDraw, ImageFont
|
| 19 |
-
|
| 20 |
-
HERE = pathlib.Path(__file__).resolve().parent
|
| 21 |
-
PANELS = HERE / "panels"
|
| 22 |
-
OUT = HERE / "figures"
|
| 23 |
-
|
| 24 |
-
WIDTH = 2400 # 8 inches at 300 dpi
|
| 25 |
-
GAP = 34
|
| 26 |
-
MARGIN = 18
|
| 27 |
-
LABEL_PT = 52
|
| 28 |
-
BORDER = (208, 208, 205)
|
| 29 |
-
INK = (11, 11, 11)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def load_font(size: int) -> ImageFont.FreeTypeFont:
|
| 33 |
-
"""Matplotlib ships DejaVu, so a bold face is available without extra deps."""
|
| 34 |
-
import matplotlib
|
| 35 |
-
path = pathlib.Path(matplotlib.__file__).parent / "mpl-data/fonts/ttf/DejaVuSans-Bold.ttf"
|
| 36 |
-
return ImageFont.truetype(str(path), size)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def fit(img: Image.Image, width: int = None, height: int = None) -> Image.Image:
|
| 40 |
-
if width:
|
| 41 |
-
return img.resize((width, round(img.height * width / img.width)), Image.LANCZOS)
|
| 42 |
-
return img.resize((round(img.width * height / img.height), height), Image.LANCZOS)
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
def main() -> int:
|
| 46 |
-
OUT.mkdir(parents=True, exist_ok=True)
|
| 47 |
-
# Panels are laid out in the order the app presents them, so a reader can
|
| 48 |
-
# map the figure onto the running interface: table on the left, structure
|
| 49 |
-
# on the right.
|
| 50 |
-
a = Image.open(PANELS / "panelA_interface.png").convert("RGB")
|
| 51 |
-
b = Image.open(PANELS / "panelB_table.png").convert("RGB")
|
| 52 |
-
c = Image.open(PANELS / "panelC_structure.png").convert("RGB")
|
| 53 |
-
|
| 54 |
-
font = load_font(LABEL_PT)
|
| 55 |
-
label_h = LABEL_PT + 14
|
| 56 |
-
|
| 57 |
-
# Row 1: the full interface, across the figure.
|
| 58 |
-
a = fit(a, width=WIDTH)
|
| 59 |
-
|
| 60 |
-
# Row 2: structure and table share a height so their tops and bottoms line up.
|
| 61 |
-
avail = WIDTH - GAP
|
| 62 |
-
row2_h = round(avail / (b.width / b.height + c.width / c.height))
|
| 63 |
-
b = fit(b, height=row2_h)
|
| 64 |
-
c = fit(c, height=row2_h)
|
| 65 |
-
# Absorb any rounding drift into the wider panel so the row is exactly WIDTH.
|
| 66 |
-
if b.width + GAP + c.width != WIDTH:
|
| 67 |
-
b = b.resize((WIDTH - GAP - c.width, b.height), Image.LANCZOS)
|
| 68 |
-
|
| 69 |
-
total_h = label_h + a.height + GAP + label_h + row2_h
|
| 70 |
-
sheet = Image.new("RGB", (WIDTH, total_h), "white")
|
| 71 |
-
draw = ImageDraw.Draw(sheet)
|
| 72 |
-
|
| 73 |
-
def place(img, x, y, letter):
|
| 74 |
-
draw.text((x, y - label_h + 4), letter, font=font, fill=INK)
|
| 75 |
-
sheet.paste(img, (x, y))
|
| 76 |
-
draw.rectangle([x, y, x + img.width - 1, y + img.height - 1], outline=BORDER, width=2)
|
| 77 |
-
|
| 78 |
-
y = label_h
|
| 79 |
-
place(a, 0, y, "A")
|
| 80 |
-
y += a.height + GAP + label_h
|
| 81 |
-
place(b, 0, y, "B")
|
| 82 |
-
place(c, b.width + GAP, y, "C")
|
| 83 |
-
|
| 84 |
-
for ext in ("png", "pdf"):
|
| 85 |
-
sheet.save(OUT / f"figure1_interface.{ext}", dpi=(300, 300))
|
| 86 |
-
print(f"figure1_interface: {sheet.size} "
|
| 87 |
-
f"({sheet.width/300:.1f} x {sheet.height/300:.1f} inches at 300 dpi)")
|
| 88 |
-
return 0
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
if __name__ == "__main__":
|
| 92 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper/make_figures.py
DELETED
|
@@ -1,164 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
"""Generate Figures 2 and 3 for the DeepMutate-3D preprint.
|
| 3 |
-
|
| 4 |
-
Figure 1 is a screenshot of the running application and is assembled separately.
|
| 5 |
-
|
| 6 |
-
Colour choices follow a single validated system. Model size is an ORDINAL
|
| 7 |
-
variable, so the three models use one blue hue stepped light to dark rather than
|
| 8 |
-
arbitrary categorical colours; the ordering is then legible even in greyscale
|
| 9 |
-
and to colourblind readers. Annotated residues use the reserved red, and are
|
| 10 |
-
also directly labelled, so identity never rests on colour alone.
|
| 11 |
-
"""
|
| 12 |
-
|
| 13 |
-
from __future__ import annotations
|
| 14 |
-
|
| 15 |
-
import json
|
| 16 |
-
import pathlib
|
| 17 |
-
import sys
|
| 18 |
-
|
| 19 |
-
import matplotlib
|
| 20 |
-
matplotlib.use("Agg")
|
| 21 |
-
import matplotlib.pyplot as plt
|
| 22 |
-
import numpy as np
|
| 23 |
-
import pandas as pd
|
| 24 |
-
|
| 25 |
-
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent))
|
| 26 |
-
|
| 27 |
-
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
| 28 |
-
OUT = pathlib.Path(__file__).parent / "figures"
|
| 29 |
-
|
| 30 |
-
# Ordinal ramp, light to dark. Lightest step clears the 2:1 contrast floor.
|
| 31 |
-
ORDINAL = {"ESM-2 35M": "#86b6ef", "ESM-2 150M": "#2a78d6", "ESM-2 650M": "#104281"}
|
| 32 |
-
SERIES = "#2a78d6"
|
| 33 |
-
ACCENT = "#e34948"
|
| 34 |
-
INK = "#0b0b0b"
|
| 35 |
-
INK_2 = "#52514e"
|
| 36 |
-
GRID = "#e3e2df"
|
| 37 |
-
|
| 38 |
-
plt.rcParams.update({
|
| 39 |
-
"figure.dpi": 300, "savefig.dpi": 300,
|
| 40 |
-
"font.family": "DejaVu Sans", "font.size": 8,
|
| 41 |
-
"axes.edgecolor": GRID, "axes.labelcolor": INK, "axes.titlesize": 9,
|
| 42 |
-
"axes.titleweight": "bold", "axes.titlelocation": "left",
|
| 43 |
-
"xtick.color": INK_2, "ytick.color": INK_2,
|
| 44 |
-
"axes.spines.top": False, "axes.spines.right": False,
|
| 45 |
-
"figure.facecolor": "white", "axes.facecolor": "white",
|
| 46 |
-
})
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def load(tag):
|
| 50 |
-
p = ROOT / f"validation/results/per_assay_wt_{tag}.jsonl"
|
| 51 |
-
return pd.read_json(p, lines=True)[["DMS_id", "spearman", "seq_len"]]
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
def figure2():
|
| 55 |
-
"""Distribution of per-assay accuracy across model sizes, and the paired gain."""
|
| 56 |
-
models = [("ESM-2 35M", "esm2_t12_35M_UR50D"),
|
| 57 |
-
("ESM-2 150M", "esm2_t30_150M_UR50D"),
|
| 58 |
-
("ESM-2 650M", "esm2_t33_650M_UR50D")]
|
| 59 |
-
frames = {label: load(tag) for label, tag in models}
|
| 60 |
-
|
| 61 |
-
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(7.2, 3.0))
|
| 62 |
-
|
| 63 |
-
# Panel A: empirical CDF. Shows the whole distribution, not just a summary,
|
| 64 |
-
# and a uniform rightward shift is immediately visible.
|
| 65 |
-
for label, frame in frames.items():
|
| 66 |
-
vals = np.sort(frame["spearman"].dropna().to_numpy())
|
| 67 |
-
y = np.arange(1, len(vals) + 1) / len(vals)
|
| 68 |
-
ax1.step(vals, y, where="post", color=ORDINAL[label], linewidth=2,
|
| 69 |
-
label=f"{label} (mean {vals.mean():.3f})")
|
| 70 |
-
ax1.set_xlabel("Per-assay Spearman rho")
|
| 71 |
-
ax1.set_ylabel("Cumulative fraction of assays")
|
| 72 |
-
ax1.set_title("A Accuracy distribution, 217 DMS assays")
|
| 73 |
-
ax1.grid(True, color=GRID, linewidth=0.6, alpha=0.9)
|
| 74 |
-
ax1.set_axisbelow(True)
|
| 75 |
-
ax1.axvline(0, color=INK_2, linewidth=0.8, linestyle=":")
|
| 76 |
-
ax1.legend(frameon=False, loc="lower right", fontsize=7)
|
| 77 |
-
|
| 78 |
-
# Panel B: paired differences. Pairing removes between-assay variance, so
|
| 79 |
-
# this is the honest view of whether the larger model actually helps.
|
| 80 |
-
merged = frames["ESM-2 150M"].merge(
|
| 81 |
-
frames["ESM-2 650M"], on="DMS_id", suffixes=("_150", "_650"))
|
| 82 |
-
diff = (merged["spearman_650"] - merged["spearman_150"]).dropna()
|
| 83 |
-
ax2.hist(diff, bins=36, color=SERIES, edgecolor="white", linewidth=0.5)
|
| 84 |
-
ax2.axvline(0, color=INK_2, linewidth=1.0)
|
| 85 |
-
ax2.axvline(diff.mean(), color=ACCENT, linewidth=2)
|
| 86 |
-
ax2.annotate(f"mean +{diff.mean():.3f}\n{100*(diff>0).mean():.0f}% of assays improve",
|
| 87 |
-
xy=(diff.mean(), ax2.get_ylim()[1] * 0.72),
|
| 88 |
-
xytext=(0.52, 0.80), textcoords="axes fraction",
|
| 89 |
-
color=INK, fontsize=7.5,
|
| 90 |
-
arrowprops=dict(arrowstyle="-", color=ACCENT, linewidth=1.2))
|
| 91 |
-
ax2.set_xlabel("Change in rho, 650M minus 150M")
|
| 92 |
-
ax2.set_ylabel("Assays")
|
| 93 |
-
ax2.set_title("B Paired effect of model size")
|
| 94 |
-
ax2.grid(True, axis="y", color=GRID, linewidth=0.6, alpha=0.9)
|
| 95 |
-
ax2.set_axisbelow(True)
|
| 96 |
-
|
| 97 |
-
fig.tight_layout()
|
| 98 |
-
for ext in ("png", "pdf"):
|
| 99 |
-
fig.savefig(OUT / f"figure2_model_size.{ext}", bbox_inches="tight")
|
| 100 |
-
plt.close(fig)
|
| 101 |
-
print(f" Figure 2: {len(diff)} paired assays, mean gain {diff.mean():+.4f}")
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
def figure3():
|
| 105 |
-
"""Sensitivity along the lysozyme sequence, with disulfide cysteines marked."""
|
| 106 |
-
import app
|
| 107 |
-
seq, _ = app.fetch_uniprot_sequence("P00698")
|
| 108 |
-
scores, _ = app.compute_sensitivity(
|
| 109 |
-
seq, "Masked marginals (accurate)", "ESM-2 650M (most accurate)")
|
| 110 |
-
scores = np.asarray(scores)
|
| 111 |
-
pos = np.arange(1, len(seq) + 1)
|
| 112 |
-
bridges = [(24, 145), (48, 133), (82, 98), (94, 112)]
|
| 113 |
-
cys = sorted({p for pair in bridges for p in pair})
|
| 114 |
-
|
| 115 |
-
fig, ax = plt.subplots(figsize=(7.2, 3.1))
|
| 116 |
-
ax.fill_between(pos, scores, 0, color=SERIES, alpha=0.16, linewidth=0)
|
| 117 |
-
ax.plot(pos, scores, color=SERIES, linewidth=1.4)
|
| 118 |
-
|
| 119 |
-
median = float(np.median(scores))
|
| 120 |
-
ax.axhline(median, color=INK_2, linewidth=0.9, linestyle="--",
|
| 121 |
-
label=f"protein median ({median:.2f})")
|
| 122 |
-
# The trace crosses the median line along its whole length, so there is no
|
| 123 |
-
# position for an in-plot label that does not sit on data. The value goes
|
| 124 |
-
# in the caption instead, and the line is identified in the legend.
|
| 125 |
-
|
| 126 |
-
ax.scatter(cys, scores[[c - 1 for c in cys]], s=34, color=ACCENT,
|
| 127 |
-
zorder=5, edgecolor="white", linewidth=0.8,
|
| 128 |
-
label="cysteine in a disulfide bridge")
|
| 129 |
-
# Stagger labels so neighbouring pairs (94/98, 112/133) do not collide.
|
| 130 |
-
for idx, c in enumerate(cys):
|
| 131 |
-
ax.annotate(f"C{c}", xy=(c, scores[c - 1]),
|
| 132 |
-
xytext=(0, -13 if idx % 2 == 0 else -21),
|
| 133 |
-
textcoords="offset points", ha="center", fontsize=6.5,
|
| 134 |
-
color=ACCENT)
|
| 135 |
-
|
| 136 |
-
ax.set_xlabel("Residue position")
|
| 137 |
-
ax.set_ylabel("Sensitivity (mean LLR)")
|
| 138 |
-
ax.set_title("Lysozyme C: all eight disulfide cysteines rank among the "
|
| 139 |
-
"most constrained positions\n"
|
| 140 |
-
"ESM-2 650M, masked marginals", fontsize=9)
|
| 141 |
-
ax.grid(True, color=GRID, linewidth=0.6, alpha=0.9)
|
| 142 |
-
ax.set_axisbelow(True)
|
| 143 |
-
# OUTSIDE the axes. Inside, the legend's sample marker sits over the plot
|
| 144 |
-
# area and reads as a ninth data point, which is exactly how it was
|
| 145 |
-
# misread on first review.
|
| 146 |
-
ax.legend(frameon=False, loc="upper center", fontsize=7,
|
| 147 |
-
bbox_to_anchor=(0.5, -0.30), ncol=1, handletextpad=0.5)
|
| 148 |
-
ax.set_xlim(-4, len(seq) + 8) # headroom so C145 is not clipped
|
| 149 |
-
ax.set_ylim(min(scores) - 2.6, max(scores) + 0.6)
|
| 150 |
-
|
| 151 |
-
fig.tight_layout()
|
| 152 |
-
for ext in ("png", "pdf"):
|
| 153 |
-
fig.savefig(OUT / f"figure3_lysozyme.{ext}", bbox_inches="tight")
|
| 154 |
-
plt.close(fig)
|
| 155 |
-
ranks = pd.Series(scores).rank()
|
| 156 |
-
print(f" Figure 3: {len(seq)} residues; disulfide cysteine ranks "
|
| 157 |
-
f"{sorted(int(ranks[c-1]) for c in cys)} of {len(seq)}")
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
if __name__ == "__main__":
|
| 161 |
-
OUT.mkdir(parents=True, exist_ok=True)
|
| 162 |
-
figure2()
|
| 163 |
-
figure3()
|
| 164 |
-
print(f"\nwritten to {OUT}/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paper/panels/panelA_interface.png
DELETED
Git LFS Details
|
paper/panels/panelB_table.png
DELETED
Git LFS Details
|
paper/panels/panelC_structure.png
DELETED
Git LFS Details
|
scripts/sync_space.py
CHANGED
|
@@ -18,7 +18,7 @@ import sys
|
|
| 18 |
import tempfile
|
| 19 |
|
| 20 |
from huggingface_hub import HfApi
|
| 21 |
-
from huggingface_hub.hf_api import CommitOperationAdd
|
| 22 |
|
| 23 |
REPO = "ras1992/DeepMutate-3D"
|
| 24 |
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
@@ -45,10 +45,20 @@ def main(argv: list[str]) -> int:
|
|
| 45 |
else:
|
| 46 |
ops.append(CommitOperationAdd(name, str(ROOT / name)))
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
repo_id=REPO, repo_type="space", operations=ops,
|
| 50 |
-
commit_message=f"Sync {len(ops)}
|
| 51 |
-
print(f"synced {len(ops)}
|
| 52 |
print("commit:", getattr(info, "oid", info))
|
| 53 |
return 0
|
| 54 |
|
|
|
|
| 18 |
import tempfile
|
| 19 |
|
| 20 |
from huggingface_hub import HfApi
|
| 21 |
+
from huggingface_hub.hf_api import CommitOperationAdd, CommitOperationDelete
|
| 22 |
|
| 23 |
REPO = "ras1992/DeepMutate-3D"
|
| 24 |
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
|
|
| 45 |
else:
|
| 46 |
ops.append(CommitOperationAdd(name, str(ROOT / name)))
|
| 47 |
|
| 48 |
+
api = HfApi()
|
| 49 |
+
# Anything on the Space that is no longer tracked here is removed, so the
|
| 50 |
+
# two stay in genuine sync rather than the Space accumulating stale files.
|
| 51 |
+
if not argv[1:]:
|
| 52 |
+
keep = set(files) | {".gitattributes", "space_header.yaml"}
|
| 53 |
+
stale = sorted(set(api.list_repo_files(REPO, repo_type="space")) - keep)
|
| 54 |
+
ops += [CommitOperationDelete(path_in_repo=f) for f in stale]
|
| 55 |
+
if stale:
|
| 56 |
+
print(f"removing {len(stale)} stale file(s) from the Space")
|
| 57 |
+
|
| 58 |
+
info = api.create_commit(
|
| 59 |
repo_id=REPO, repo_type="space", operations=ops,
|
| 60 |
+
commit_message=f"Sync {len(ops)} change(s) from the repository")
|
| 61 |
+
print(f"synced {len(ops)} operations -> {REPO}")
|
| 62 |
print("commit:", getattr(info, "oid", info))
|
| 63 |
return 0
|
| 64 |
|