File size: 15,627 Bytes
d1988f5
 
 
 
 
 
 
 
c4e317f
 
d1988f5
 
 
 
 
 
 
 
 
 
 
c4e317f
 
 
d1988f5
c4e317f
d1988f5
 
 
 
 
c4e317f
d1988f5
 
 
 
 
 
 
 
 
 
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1988f5
 
 
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68d3a65
 
c4e317f
68d3a65
 
c4e317f
 
 
68d3a65
 
 
c4e317f
 
 
68d3a65
 
 
 
c4e317f
 
 
 
68d3a65
c4e317f
 
 
 
68d3a65
 
 
 
 
 
 
c4e317f
 
 
 
 
68d3a65
c4e317f
 
e125a82
 
 
68d3a65
e125a82
 
 
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
d1988f5
c4e317f
d1988f5
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68d3a65
 
 
 
 
 
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1988f5
 
 
 
 
 
 
 
 
 
 
 
c4e317f
d1988f5
c4e317f
d1988f5
 
 
 
 
 
 
 
 
c4e317f
d1988f5
 
 
 
 
c4e317f
d1988f5
c4e317f
 
d1988f5
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1988f5
 
c4e317f
d1988f5
 
c4e317f
 
 
 
d1988f5
 
c4e317f
 
 
 
 
d1988f5
 
c4e317f
d1988f5
 
 
 
 
 
 
 
 
 
 
 
 
c4e317f
d1988f5
 
 
 
c4e317f
d1988f5
 
 
c4e317f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1988f5
 
c4e317f
 
d1988f5
 
 
 
c4e317f
 
 
d1988f5
 
 
c4e317f
d1988f5
c4e317f
 
d1988f5
 
 
 
 
 
c4e317f
d1988f5
 
 
c4e317f
 
d1988f5
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# LNPBench

**A reproducible benchmark and three physics-informed architectures for
structure–function learning of lipid nanoparticles on LNPDB.**

This repository accompanies a manuscript submitted to *Engineering*
(special issue *Intelligent Drug Delivery Systems*). It contains the full data
pipeline, all baseline re-implementations, the three proposed models, the
evaluation harness, every result table and figure, and the scripts needed to
reproduce all of it from the public Lipid Nanoparticle Database (LNPDB).

---

## 1. What is in here

| Component | Description |
|---|---|
| `src/lnpbench/data.py` | LNPDB loading, canonicalisation, exact reconstruction of the published splits |
| `src/lnpbench/prepare.py` | One-off feature cache (fingerprints, RDKit descriptors, graphs, SMILES tokens, cCPP) |
| `src/lnpbench/cpp.py` | Conformer-based critical packing parameter (cCPP) surrogate |
| `src/lnpbench/store.py` | Tensor access layer + graph batching |
| `src/lnpbench/trainer.py` | Unified training loop (early stopping on validation Spearman, optional study-balanced sampling) |
| `src/lnpbench/metrics.py` | Spearman / Pearson / R² / MAE / RMSE / EF@10 / EF@20 / NDCG@10 |
| `src/lnpbench/models/backbone.py` | The final formulation encoder: GINE + descriptor MLP + hierarchical physics set + condition path |
| `src/lnpbench/models/` | LiON, AGILE, Morgan-MLP, and the three proposed models |
| `scripts/` | Benchmark runner, reports, figures, ensembles, ablations, cCPP validation |

### Models

**Baselines (re-implemented under identical data, splits and compute)**

* `lion` — directed message passing (D-MPNN) over the ionisable lipid with the
  formulation context appended, following LiON (Nat. Commun. 2026).
* `agile` — GIN structure encoder + RDKit descriptor encoder + context encoder,
  following AGILE (Nat. Commun. 2024).
* `xgboost`, `randomforest`, `extratrees` — tabular models on RDKit descriptors,
  cCPP and formulation context.
* `mlp_fp` — Morgan fingerprint + context MLP.
* `mean` — trivial reference.

**Proposed**

* **A — PhyCausal-LNP** (`phcausal_phys`): hierarchical formulation set with
  physically biased set attention, condition cross-attention and a within-study
  ranking loss.
* **B — PhysSet-LNP** (`physset_phys`): the final architecture. A GINE encoder
  over the intact ionisable-lipid graph, an MLP over RDKit descriptors, and a
  ten-node formulation set (head, linker, tail ×4, whole lipid, helper lipid,
  cholesterol, PEG lipid) fused by physics-biased set attention. **Every node is
  described by physical descriptors only — no Morgan fingerprint.** That single
  choice is what separates the model from its identity-leaking variant
  (section 2.4).
* **C — SeqCausal-LNP** (`seqcausal`): GINE graph stream + bidirectional
  selective state-space (Mamba) SMILES stream with gated fusion, FiLM condition
  modulation and GroupDRO across source studies.

**Final predictor.** `LNPBench-Stack` = equal-weight, rank-normalised average of
PhysSet-LNP, random forest and extra trees. The member list is fixed a priori
and no weight is fitted on any evaluation data (section 2.3).

---

## 2. Results

Every number below is generated by `scripts/report.py` and `scripts/ensemble.py`
from `results/*.csv`; the authoritative, always-current version is
[`results/REPORT.md`](results/REPORT.md). **All runs are full runs**: four fully
held-out studies × five published folds = 20 external tasks, three seeds for
every neural model.

### 2.1 External generalisation

Train on the rest of LNPDB, test on a study the model has never seen. Spearman
rank correlation; `seed_avg` averages the rank-normalised predictions over the
seeds a model has, `per_seed` averages the individual runs.

| Model | LM_2019 | BL_2023 | SL_2020 | ZC_2023 | seed_avg | per_seed | seeds |
|---|---|---|---|---|---|---|---|
| Random forest | 0.194 | 0.156 | 0.656 | 0.420 | **0.357** | 0.357 | 1 |
| **PhysSet-LNP (B, ours)** | 0.142 | 0.103 | **0.750** | **0.430** | 0.356 | 0.345 | 3 |
| Extra trees | 0.179 | 0.049 | 0.713 | 0.445 | 0.346 | 0.346 | 1 |
| AGILE (re-trained, full pool) | 0.166 | 0.018 | 0.721 | 0.414 | 0.330 | 0.312 | 3 |
| LiON (from scratch) | 0.206 | 0.137 | 0.620 | 0.337 | 0.325 | 0.296 | 3 |
| Identity-free flat probe (ours) | 0.184 | −0.071 | 0.732 | 0.401 | 0.312 | 0.312 | 1 |
| XGBoost | 0.117 | 0.085 | 0.669 | 0.329 | 0.300 | 0.300 | 1 |
| PhyCausal-LNP (A, ours) | 0.089 | 0.050 | 0.701 | 0.329 | 0.292 | 0.292 | 1 |
| SeqCausal-LNP (C, ours) | −0.103 | 0.086 | 0.612 | 0.225 | 0.205 | 0.205 | 1 |
| Morgan FP + MLP | −0.063 | 0.007 | 0.490 | 0.344 | 0.194 | 0.194 | 1 |
| **LNPBench-Stack (ours)** | **0.199** | **0.132** | 0.741 | **0.466** | **0.385** | – | – |
| *Published LiON w/ LNPDB* | *0.11* | *0.09* | *0.63* | *0.52* | | | *5* |
| *Published AGILE* | *0.00* | *−0.01* | *−0.21* | *0.09* | | | *5* |

Every model is at full coverage: 20 tasks, five folds. `seed_avg` averages the
rank-normalised predictions over the seeds a model has before scoring; `per_seed`
averages the individual runs.

The published values are re-digitised from Nat. Commun. 2026 Fig. 3b and are not
directly comparable: that AGILE entry was trained on ~1.2k formulations (16× less
data than LiON), and the published LiON is pretrained on the whole corpus. Under
an identical from-scratch budget AGILE is *not* negative on SL_2020 — it reaches
0.721 — so the negative value in the published comparison is a training-set-size
artefact, not an architectural one.

### 2.2 What the benchmark shows

1. **PhysSet-LNP ties the random forest for the best single model.** Paired
   Wilcoxon over the 20 tasks: Δ = −0.000, p = 0.96. The tie hides a real
   trade-off. PhysSet-LNP is the best model on both large held-out studies
   (SL_2020 0.750 vs 0.656; ZC_2023 0.430 vs 0.420) and clearly worse on the two
   small ones (LM_2019 0.142 vs 0.194; BL_2023 0.103 vs 0.156). Against the
   remaining models the ordering is unambiguous: +0.056 over XGBoost
   (p = 0.0005), +0.027 over AGILE (p = 0.070), +0.032 over LiON (p = 0.25).
2. **Cross-family diversity, not any single architecture, is the state of the
   art.** `LNPBench-Stack` reaches **0.385**, beating every single model with
   p < 0.05 (vs random forest +0.028, p = 0.027; vs PhysSet-LNP +0.027,
   p = 0.024; vs extra trees +0.038, p = 0.0001; vs AGILE +0.054, p = 0.0003).
   Leave-one-out attribution: removing PhysSet-LNP costs −0.018, removing the
   random forest −0.010, removing extra trees −0.003. The neural member is the
   largest single contributor, and the two tree families are not redundant with
   it.
3. **In-distribution accuracy and cross-study transfer are anti-correlated.**
   Under study-stratified 5-fold CV XGBoost scores 0.611, the fingerprint MLP
   0.461 and PhysSet-LNP 0.462; on a genuinely unseen study the order inverts
   (0.300 / 0.194 / 0.356). The amine-disjoint split says the same thing
   (0.483 / 0.385 / 0.342). The features that buy in-distribution accuracy are
   the features that encode which study a formulation came from, so a model can
   be better precisely because it transfers *less* of that.

### 2.3 The dominant failure mode: study identity is a shortcut

Validation Spearman on source studies and external Spearman on a held-out study
measure different things. Adding ingredients one at a time to a minimal
formulation encoder (fold 0 of LM_2019 and BL_2023):

| Encoder | external Spearman |
|---|---|
| flat, chemistry only | 0.088 |
| + formulation set | −0.021 |
| + physics bias | −0.044 |
| + set + bias + rank loss | 0.035 |

Ablations of the final architecture (all four studies, fold 0, seed 0):

| Variant | external Spearman |
|---|---|
| full model | 0.368 |
| w/o rank loss | 0.352 |
| w/o physics bias | 0.356 |
| **fingerprint nodes (study identity)** | **0.189** |

Replacing the identity-free physical nodes with Morgan fingerprints of each
fragment keeps validation Spearman high — the model still fits the source
studies — while external Spearman collapses from 0.368 to 0.189. The fingerprint
nodes let the network recognise *which study a formulation came from* instead of
learning chemistry that transfers. This is the largest single effect anywhere in
the study, and it is why the released model uses physics descriptors only at the
node level, additive context only, and a 30-epoch budget.

A fifth, sampler-level fix — up-weighting the small source studies so that every
study contributes equally to each mini-batch — also fails: **0.304** versus 0.347
for the standard sampler, with BL_2023 dropping to −0.041. The deficit is not
sampling imbalance; the model finds study-specific structure wherever it is
allowed to. Full details in `results/REPORT.md` §4.1.

### 2.4 The conformer cCPP surrogate is a descriptor, not an MD replacement

* Protonated-state CPP below neutral-state CPP for **48.3%** of 11,648 unique
  ionisable lipids (MD expectation ~100%): the sign of the pH shift is chance.
* Neutral-state absolute CPP on the one system with shipped MD values: 1.583 vs
  MD 1.542 — good. Protonated state: 2.469 vs MD 1.379 — not good.
* On the 34 stable LM_2019 bilayers the surrogate correlates with transfection at
  r = −0.285 (p = 0.10), whereas the MD-based value reported in Nat. Commun. 2026
  is +0.53 to +0.72.

It is therefore used only as an input descriptor, and its contribution is
established by the `w/o physics bias` ablation — which is **null** (0.356 vs
0.368). We report that honestly rather than claiming the physical prior is what
makes the model work.

---## 3. Setup

```bash
git clone https://github.com/evancollins1/LNPDB.git data/LNPDB
pip install -r requirements.txt
pip install -e .
```

The LNPDB repository provides `data/LNPDB_for_LiON/LNPDB.csv` (raw) and the
exact split files used by the original publication.

---

## 4. Reproduce

### 4.1 Build the feature cache (once)

```bash
python -m lnpbench.prepare --stage all --workers 32
```

This writes `cache/`:

* `samples.parquet` — the 18,858 evaluable formulations
* `il_fp.npy`, `il_desc.npy`, `il_cpp.npy`, `il_graphs.pkl`, `il_tokens.npz`
* `frag_*.npz` — per-substructure fingerprints and physical descriptors
* `sample_features.npz`, `tasks.pkl`, `md_labels.npz`

cCPP is the only expensive step (~0.4 s per lipid, two protonation states);
it is parallelised over `--workers`.

### 4.2 The full benchmark matrix

`scripts/run_all_gpu.sh` runs exactly what is reported here. The individual
commands are:

```bash
# tabular baselines, five folds x four held-out studies
python scripts/run_benchmark.py --models xgboost randomforest extratrees mlp_fp \
    --protocols external --device cpu --out results/benchmark_classical.csv

# message-passing baselines, three seeds
python scripts/run_benchmark.py --models lion agile --protocols external \
    --seeds 0 1 2 --device cuda --epochs 30 --batch-size 256 \
    --save-preds --out results/full_agile.csv

# the proposed models, three seeds (physset) / one seed (phcausal, seqcausal)
python scripts/run_benchmark.py --models physset_phys --protocols external \
    --seeds 0 1 2 --device cuda --epochs 30 --batch-size 256 \
    --save-preds --out results/full_physset_phys.csv
python scripts/run_benchmark.py --models phcausal_phys --protocols external \
    --device cuda --epochs 30 --batch-size 256 --save-preds \
    --out results/full_phcausal_phys.csv
python scripts/run_benchmark.py --models seqcausal --protocols external \
    --device cuda --epochs 30 --batch-size 128 --save-preds \
    --out results/full_seqcausal.csv

# secondary protocols
python scripts/run_benchmark.py --models xgboost mlp_fp physset_phys \
    --protocols amine --seeds 0 1 2 --out results/benchmark_amine.csv
python scripts/run_benchmark.py --models xgboost mlp_fp physset_phys \
    --protocols cv5 --out results/benchmark_cv5.csv

# study-balanced sampling variant (reported as an ablation of the sampler)
python scripts/run_benchmark.py --models physset_phys_bal --protocols external \
    --device cuda --epochs 30 --batch-size 256 --study-balance \
    --out results/full_physset_bal.csv
```

### 4.3 Tables, figures, ensembles

```bash
python scripts/ensemble.py --pred-dirs results/predictions --out results/ensemble.csv
python scripts/report.py --results results          # -> results/REPORT.md
python scripts/make_figures.py --results results --outdir figures
python scripts/validate_ccpp.py                     # -> results/ccpp_validation.json
```

`scripts/report.py` reads only CSVs, so the manuscript tables can be regenerated
in seconds without a GPU. `scripts/ensemble.py` reads only the per-sample
predictions, so the stack and every paired test can be rebuilt without
retraining.

---

## 5. Evaluation protocol

The unit is one **LNP formulation**. The target is the per-study standardised
delivery readout shipped with LNPDB. Because the primary metric is Spearman rank
correlation, per-study standardisation does not leak information.

**Primary protocol (external generalisation).** For each of the four studies
that the LNPDB/AGILE comparison holds out entirely (`LM_2019`, `BL_2023`,
`SL_2020`, `ZC_2023`), the model is trained on the remaining database using the
five published 80/20 folds, validated on the 20% split, and evaluated on the
fully unseen study. We reconstruct the published fold membership exactly by
multiset matching on `(SMILES, value)`.

**Secondary protocols.**

* `amine` — the published 70/15/15 amine-disjoint split (LNPDB Fig. 3a).
* `cv5` — study-stratified 5-fold cross-validation over the entire database.

Metrics: Spearman (primary), Pearson, R², MAE, RMSE, enrichment factor at 10%
and 20% (EF@10, EF@20) and NDCG@10.

---

## 6. Compute actually used

All neural numbers were produced on a single 24 GB GPU; the tabular baselines
were produced on CPU. Total neural compute:

| Model | Runs | Seeds | Folds | Epochs | GPU time |
|---|---|---|---|---|---|
| PhysSet-LNP | 58 | 3 | 5 | 30 | 2.9 h |
| AGILE | 60 | 3 | 5 | 30 | 1.5 h |
| LiON | 60 | 3 | 5 | 30 | 1.3 h |
| SeqCausal-LNP | 8+ | 1 | 2+ | 30 | 2.1 h |
| PhyCausal-LNP | 20 | 1 | 5 | 30 | 0.9 h |
| Identity-free probe | 20 | 1 | 5 | 30 | 0.4 h |
| Morgan FP + MLP | 20 | 1 | 5 | 45 | 0.1 h |

Tabular baselines: ~40 min of CPU for 60 fits. Rebuilding every table and figure
from the stored predictions takes under a minute.

---

## 7. Reproducibility notes

* All featurisation is deterministic; the cache fully determines the inputs.
  The cCPP conformer search is seeded from a CRC32 of the SMILES, so it is
  bit-reproducible across machines.
* Every neural model is trained with early stopping on the *validation* split;
  the held-out study is never seen during training or model selection.
* Seeds are explicit (`--seeds`), and `run_benchmark.py --resume` makes runs
  restartable.
* `results/predictions/*.npz` stores per-sample predictions (`idx`, `y`, `pred`)
  so every table, every ensemble and every paired test can be recomputed
  without retraining.

---

## 8. Data and code availability

The derived feature cache, per-sample predictions, result tables, figures and
trained checkpoints are mirrored on Hugging Face:
`https://huggingface.co/datasets/eduzrh/LNPBench`.

Raw data: LNPDB, https://lnpdb.molcube.com and https://github.com/evancollins1/LNPDB.

---

## 9. Citation

```bibtex
@article{lnpbench2026,
  title   = {Physics-informed hierarchical and set-based learning for lipid
             nanoparticle structure--function prediction},
  journal = {Engineering},
  year    = {2026}
}
```