dsadd4 commited on
Commit
e7962be
·
verified ·
1 Parent(s): 9d3cc5e

Set dataset card (YAML metadata + usage)

Browse files
Files changed (1) hide show
  1. README.md +178 -395
README.md CHANGED
@@ -1,424 +1,207 @@
1
- # UltraMS MSnLib benchmark
2
-
3
- Version **1.0.0** · 2026-11-04 · license **CC BY 4.0** (see [NOTICE.md](NOTICE.md))
4
-
5
- Two frozen, independent benchmark splits of the [MSnLib](https://doi.org/10.1038/s41592-025-02813-0)
6
- tandem mass spectral library, built and released by UltraMS:
7
-
8
- * **Split A — UltraMS MSnLib formula-level split**: the complete library (560,084 spectra,
9
- all adducts) split by molecular formula into train / validation / test
10
- (16,885 / 2,110 / 2,112 formulas, 446,667 / 55,980 / 57,437 spectra). Formula-disjoint.
11
- This is the population for single-spectrum candidate ranking, multiple-spectrum voting,
12
- label-blind grouping and embedding analyses.
13
- * **Split B — strict-adduct molecule-level split**: the strict `[M+H]+` and `[M-H]-`
14
- subsets (447,956 source rows) re-split 70 / 15 / 15 at the level of RDKit canonical
15
- isomeric SMILES, separately per polarity, with frozen queries and libraries for
16
- spectrum-to-spectrum library search. Molecule-disjoint within each polarity.
17
-
18
- Both splits are frozen benchmark definitions with published checksums; neither is a
19
- redistribution of the MSnLib spectra.
20
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ---
22
 
23
- ## 1. At a glance
24
 
25
- | | Split A (formula-level, all adducts) | Split B `[M+H]+` | Split B `[M-H]-` |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  | --- | ---: | ---: | ---: |
27
- | compounds / molecules | — (21,107 formulas) | 41,348 | 21,293 |
28
- | spectra | 560,084 | 301,636 | 140,193 |
29
- | train | 16,885 formulas · 446,667 spectra | 28,944 compounds · 211,745 spectra | 14,907 · 98,401 |
30
- | validation | 2,110 formulas · 55,980 spectra | 6,202 compounds · 44,881 spectra | 3,193 · 20,927 |
31
- | test | 2,112 formulas · 57,437 spectra | 6,202 compounds · 45,010 spectra | 3,193 · 20,865 |
32
- | test task | candidate ranking / voting (57,437 queries) | 6,202 queries vs 295,434 library spectra | 3,193 vs 137,000 |
33
- | queries with an exact-adduct library positive | — | 6,201 | 3,160 |
34
- | validation task | — | 6,202 vs 250,424 | 3,193 vs 116,135 |
35
 
36
- Split A test fold: 57,437 spectra, 2,112 formulas, 5,003 distinct MSnLib source SMILES,
37
- 4,889 distinct RDKit canonical isomeric SMILES. The **official** multiple-spectrum voting
38
- unit is the MSnLib source SMILES string: 5,002 groups covering 57,436 spectra (canonical
39
- view: 4,888 groups).
 
 
40
 
41
- Split B split seeds: 42 (`[M+H]+`) / 43 (`[M-H]-`); query seed 119. Split A has no seed:
42
- its fold assignment is frozen in the `fold` column of `MSnLib.csv` and replayed exactly by
43
- `split_A_full_msnlib/build_split_a.py`.
44
 
45
- ## 2. Disjointness: what is claimed — and what is not
46
-
47
- | split | disjointness unit | claimed |
48
- | --- | --- | --- |
49
- | A | molecular formula | every spectrum of a formula lies in exactly one fold; no formula occurs in two folds (0 conflicts out of 21,107) |
50
- | B | RDKit canonical isomeric SMILES, per polarity | the train / validation / test compound sets of each polarity are pairwise disjoint |
51
-
52
- **A and B are different objects and must not be combined into a global-disjointness claim.**
53
- About 41 % of split-B compounds are in a *different* split-A fold, and a spectrum can be a
54
- split-A test spectrum while its compound is a split-B train compound. Concrete numbers:
55
 
56
- * split B `[M+H]+` test compounds: 654 are split-A test, 4,922 are split-A train, 626 are
57
- split-A validation;
58
- * split B `[M-H]-` test compounds: 303 are split-A test, 2,541 are split-A train, 349 are
59
- split-A validation;
60
- * 31,570 split-A test spectra are `[M+H]+` rows of split B and 13,413 are `[M-H]-` rows.
61
 
62
- The full cross-tabulation (compound level and spectra level, per polarity, plus the
63
- relation of the split-A test fold to split B) is in [figures_mapping.md](figures_mapping.md) §2.
64
- Never report a cross-split score as a held-out result: train and evaluate inside one split.
 
 
65
 
66
- ## 3. Package layout
 
 
 
67
 
68
- ```text
69
- ultrams_msnlib_benchmark_v1/
70
- ├── README.md this file
71
- ├── figures_mapping.md which manuscript panel uses which split (+ cross-split statistics)
72
- ├── VERIFY.md full verification record and reproducible commands
73
- ├── NOTICE.md MSnLib attribution, provenance and licensing
74
- ├── SHA256SUMS checksums of every file except itself
75
- ├── stats.json machine-readable release summary (all counts + file hashes)
76
- ├── split_A_full_msnlib/ split A (formula-level, full library)
77
- │ ├── README.md
78
- │ ├── VERIFY.md split-A verification record
79
- │ ├── REPORT.json split-A machine-readable report
80
- │ ├── build_split_a.py replay of split A from MSnLib.csv + hash check
81
- │ ├── formula_split.csv(.gz) 21,107 formulas → fold, n_spectra
82
- │ ├── row_formula_fold.csv(.gz) 560,084 rows → formula, fold
83
- │ ├── test_spectra.csv(.gz) 57,437 test spectra
84
- │ ├── val_spectra.csv(.gz) 55,980 validation spectra
85
- │ ├── test_molecules_voting.csv(.gz) 5,002 official source-SMILES voting units
86
- │ ├── test_molecules_voting_canonical_view.csv(.gz) 4,888 canonical-SMILES alternative view
87
- │ └── msnlib_rt.csv.gz 560,084 row_index → retention time (seconds)
88
- ├── splits/ split B compound tables (70/15/15, per polarity)
89
- │ ├── pos_compound_split.csv(.gz) 41,348 compounds
90
- │ └── neg_compound_split.csv(.gz) 21,293 compounds
91
- ├── queries/ split B query spectra
92
- │ ├── pos_val_queries.csv(.gz) 6,202
93
- │ ├── pos_test_queries.csv(.gz) 6,202
94
- │ ├── neg_val_queries.csv(.gz) 3,193
95
- │ └── neg_test_queries.csv(.gz) 3,193
96
- ├── libraries/ split B library spectra
97
- │ ├── pos_val_library.csv(.gz) 250,424
98
- │ ├── pos_test_library.csv(.gz) 295,434
99
- │ ├── neg_val_library.csv(.gz) 116,135
100
- │ └── neg_test_library.csv(.gz) 137,000
101
- ├── protocol/ frozen split-B protocol arrays and manifest
102
- │ ├── manifest_summary.json
103
- │ ├── protocol_{pos,neg}.npz
104
- │ ├── smiles_{pos,neg}.json
105
- │ ├── adducts_{pos,neg}.json
106
- │ ├── derived/row_metadata_{pos,neg}.npz
107
- │ └── README.md
108
- ├── rebuild/
109
- │ ├── build_library_manifest.py the split-B producer (replays MSnLib.csv)
110
- │ ├── baseline_common.py its helper module
111
- │ ├── verify_release.py self-contained verifier for the whole package
112
- │ ├── LICENSE-APACHE-2.0.txt
113
- │ └── README.md
114
- ├── hf_dataset_card.md Hugging Face dataset card draft
115
- ├── hf_upload_commands.sh upload commands, dry-run by default, not executed
116
- └── zenodo_metadata.json Zenodo deposition metadata draft
117
  ```
118
 
119
- Every plain `.csv` has a byte-identical `.csv.gz` twin; `rebuild/verify_release.py` checks
120
- this, all counts, all orderings, the cross-split statistics and the checksums.
121
-
122
- ## 4. Split A — UltraMS MSnLib formula-level split
123
-
124
- ### 4.1 Definition
125
-
126
- For every MSnLib spectrum the neutral molecular formula is computed from the source SMILES
127
- with RDKit (`rdMolDescriptors.CalcMolFormula(Chem.MolFromSmiles(smiles))`). The frozen
128
- `fold` column of `MSnLib.csv` assigns each formula to exactly one fold; the split is the
129
- formula-grouped 80/10/10 partition that results. The rule was verified for all 560,084
130
- spectra: 21,107 formulas, none in more than one fold. This is the frozen benchmark
131
- definition; `build_split_a.py` replays it from `MSnLib.csv` and reproduces every table
132
- byte-for-byte.
133
-
134
- ### 4.2 Tables
135
-
136
- | file | rows | columns |
137
- | --- | ---: | --- |
138
- | `formula_split.csv` | 21,107 | `formula, fold, n_spectra` — ordered by fold (train, valid, test) then formula |
139
- | `row_formula_fold.csv` | 560,084 | `row_index, formula, fold` — 0-based `MSnLib.csv` data row → formula → fold |
140
- | `test_spectra.csv` | 57,437 | `row_index, smiles, precursor_mz, adduct, collision_energy, fold, canonical_isomeric_smiles` |
141
- | `val_spectra.csv` | 55,980 | same schema for the validation fold |
142
- | `test_molecules_voting.csv` | 5,002 | `group_id, smiles, n_spectra` — **official** voting units (MSnLib source SMILES) |
143
- | `test_molecules_voting_canonical_view.csv` | 4,888 | `group_id, canonical_isomeric_smiles, n_spectra` — alternative canonical view |
144
- | `msnlib_rt.csv.gz` | 560,084 | `row_index, rt` — per-spectrum retention time in seconds (gzipped only, see §4.5) |
145
-
146
- `row_index` is the 0-based data row of `MSnLib.csv` (physical line = data row + 2). The
147
- tables do not carry peak data; join on `row_index` against `MSnLib.csv` (see §8).
148
-
149
- ### 4.3 Official voting units — read this before using the voting tables
150
-
151
- The **official multiple-spectrum voting units are the 5,002 MSnLib source-SMILES groups
152
- covering 57,436 spectra**, exactly the grouping used by the published multiple-spectrum
153
- voting task (Figure 3d and the Figure 3a voting readouts, `n_molecules = 5002`). The test
154
- fold contains 5,003 distinct source SMILES strings; one occurs in only one spectrum, hence
155
- 5,002 groups. This table is `test_molecules_voting.csv` (columns `group_id, smiles,
156
- n_spectra`) and it is verified member-for-member against the repository voting table
157
- (`benchmarks/molecular_identification/data/multiple_spectrum_voting_per_group.csv.gz`).
158
-
159
- An **alternative canonical view** is provided as `test_molecules_voting_canonical_view.csv`:
160
- the same test spectra grouped by RDKit canonical isomeric SMILES give 4,888 groups covering
161
- the same 57,436 spectra (114 source-string groups merge into chemically identical
162
- molecules; the single excluded molecule is `CC(C)(C)OC(=O)NCC1(CC(=O)O)CCCCC1`). This view
163
- is not the official voting unit.
164
-
165
- No data was altered to force either count. See `split_A_full_msnlib/VERIFY.md` §7 and
166
- `REPORT.json` → `anomalies`.
167
-
168
- ### 4.5 Retention times (RT)
169
-
170
- `split_A_full_msnlib/msnlib_rt.csv.gz` is a compact companion table needed by the
171
- label-blind grouping and multiple-spectrum voting analyses (Figure 3d): `row_index` is the
172
- 0-based `MSnLib.csv` data row (0 … 560,083) and `rt` is the retention time in seconds, kept
173
- in the source text representation.
174
-
175
- RT is **source metadata from the MSnLib records** (CC BY 4.0, Zenodo
176
- 10.5281/zenodo.11163380; see `NOTICE.md`). The table was exported from
177
- `MSnLib_with_rt.csv` (755,984,910 bytes, SHA-256
178
- `a5b7c38228287c5c1de401050445319b331ee9a5f17993d6e104e9a734fe2964`) after verifying
179
- row-by-row that its first seven columns are identical to `MSnLib.csv` in the same order
180
- (560,084/560,084 rows, 0 mismatches; see `split_A_full_msnlib/VERIFY.md` §5.4). The full
181
- 756 MB CSV is not duplicated; only this 1.4 MB gzipped table is shipped.
182
 
183
  ```python
184
- import pandas as pd
185
-
186
- test = pd.read_csv("split_A_full_msnlib/test_spectra.csv")
187
- rt = pd.read_csv("split_A_full_msnlib/msnlib_rt.csv.gz") # row_index, rt
188
- test_rt = test.merge(rt, on="row_index", how="left")
189
- assert test_rt["rt"].notna().all()
190
  ```
191
 
192
- The same `row_index` join works for every row of `row_formula_fold.csv`.
193
-
194
- #### Provenance of split A
195
-
196
- Source rows, formulas and folds were computed read-only in an isolated data-preparation
197
- environment with RDKit 2026.03.5. The split-A tables were frozen from that run; cross-checks against the
198
- historical per-fold CSV files, against the MSnLib original JSON `formula` fields, and
199
- against the repository voting table are recorded in `split_A_full_msnlib/VERIFY.md`.
200
-
201
- ## 5. Split B — strict-adduct molecule-level split
202
-
203
- ### 5.1 Definition
204
-
205
- Split B keeps only the strict `[M+H]+` (303,709 source rows) and `[M-H]-` (144,247 source
206
- rows) spectra. After the frozen spectrum preprocessing (drop `m/z ≤ 0` peaks, require at
207
- least 3 peaks, normalise to the base peak, keep the 150 most intense peaks and sort by m/z)
208
- 2,073 positive and 4,054 negative rows are dropped, leaving **301,636** and **140,193**
209
- preprocessed spectra. Compound identity is RDKit canonical isomeric SMILES (frozen with
210
- RDKit 2026.03.5). Per polarity the sorted compound list is shuffled with
211
- `random.Random(42)` (`[M+H]+`) / `random.Random(43)` (`[M-H]-`) and split 70 / 15 / 15;
212
- one query spectrum per validation/test compound is drawn with a fresh `random.Random(119)`.
213
-
214
- ### 5.2 Tables
215
-
216
- | table | schema |
217
- | --- | --- |
218
- | `splits/{pos,neg}_compound_split.csv` | `polarity, compound_id, canonical_isomeric_smiles, split, n_spectra, n_frozen_queries, n_raw_smiles_variants, first_msnlib_csv_data_row` |
219
- | `queries/{pos,neg}_{val,test}_queries.csv` | `polarity, split, query_index, compound_id, canonical_isomeric_smiles, adduct, msnlib_csv_data_row, msnlib_csv_line, precursor_mz, n_peaks, collision_energy, source_smiles_raw, n_library_positives` |
220
- | `libraries/{pos,neg}_{val,test}_library.csv` | same as queries with `library_index` and `compound_split` instead of `query_index`; row order is the frozen library order |
221
-
222
- ### 5.3 Protocol
223
-
224
- 1. Score every query against the **complete** library of its task (no candidate short list).
225
- 2. A retrieved library spectrum is correct iff its canonical isomeric SMILES equals the
226
- query's (exact same-adduct spectrum of the same molecule).
227
  3. Empirical FDR = `(accepted − correct) / accepted`; identification recall =
228
  `correct / n_queries_with_library_positive` (6,201 / 3,160 for the two test tasks).
229
  Queries without a library positive enter the FDR denominator but not the recall
230
- denominator; `n_library_positives` is published per query.
231
- 4. The **test library** is every preprocessed spectrum of the polarity except the selected
232
- test queries (it therefore still contains further spectra of the test molecules; a query
233
- never occurs in its own library). The **validation library** contains train and
234
- validation compounds only, so test compounds never influence validation scores.
235
- 5. Validation is for model selection only; the test fold is evaluated once.
236
-
237
- The split-B tables deliberately do **not** carry the formula-level fold of the spectra:
238
- that label belongs to split A. To obtain each split-B row's split-A fold, join
239
- `msnlib_csv_data_row` (queries/libraries) or `first_msnlib_csv_data_row` (compound split)
240
- against `split_A_full_msnlib/row_formula_fold.csv`; the packaged verifier does exactly this
241
- for the cross-split statistics.
242
-
243
- The frozen row-index arrays behind these tables are in `protocol/`; the CSV tables are a
244
- human-readable view. `rebuild/build_library_manifest.py` replays them bit-for-bit from
245
- `MSnLib.csv`, and `rebuild/verify_release.py` checks the tables against the arrays and the
246
- frozen manifest.
247
-
248
- ### 5.4 Cross-collision-energy subtask
249
-
250
- The cross-collision-energy library-search task uses split B test queries that were measured
251
- at two or more collision energies: **6,161 positive** and **2,999 negative** queries (out of
252
- 6,202 / 3,193 split-B test queries). The task pairs a low-energy query spectrum with a
253
- high-energy reference library (or vice versa) and asks for the same-molecule hit; the
254
- query identities are a subset of the split-B test queries published here. The CE values in
255
- MSnLib are 15, 20, 30, 45, 60 and 75 eV. The cross-CE pairing manifest and readouts are
256
- part of the UltraMS repository, not of this split package.
257
-
258
- ## 6. Relation to split A
259
-
260
- Split A and split B are independent; see §2 for the disjointness statement and
261
- [figures_mapping.md](figures_mapping.md) §2 for the full cross-tabulation. Summary: 58.9 %
262
- positive and 59.4 % negative split-B compounds keep the same fold in split A; 654 positive
263
- and 303 negative split-B test compounds are also split-A test compounds; 31,570 / 13,413
264
- split-A test spectra are `[M+H]+` / `[M-H]-` rows of split B.
265
-
266
- ## 7. Manuscript figures
267
-
268
- [figures_mapping.md](figures_mapping.md) maps every figure panel to the split it uses:
269
 
270
- * **A**: Figure 2b, Figure 2j, Figure 3a, 3b, 3d, 3g, 3a_sp_4, 3a_sp_5 and the
271
- single-spectrum baselines Top-1 table;
272
- * **B**: Figure 3e, 3f, 3h, 3h_sp_1 and the cross-collision-energy task (6,161 / 2,999);
273
- * **not this dataset**: NPLIB1 and MassSpecGym comparison panels (independent external
274
- benchmarks); Figure 3c / 3i case studies are not split-defined.
275
 
276
- Candidate-ranking tables (the per-formula candidate lists behind Figure 3a/3b/3d/3g) are
277
- part of the UltraMS repository, not of this split package; this package provides the frozen
278
- queries, identities and folds they are evaluated on.
279
-
280
- ## 8. Data acquisition and rebuilding
281
-
282
- ### 8.1 The spectra are not part of this manifest
283
-
284
- This package publishes splits and identifiers, not peak arrays. Every table is joined back
285
- to the spectra through `row_index` / `msnlib_csv_data_row`, which point into `MSnLib.csv`;
286
- both large files are hosted in the same Hugging Face dataset (see the managed-file table
287
- below) rather than duplicated in this manifest.
288
-
289
- | item | value |
290
- | --- | --- |
291
- | file | `MSnLib.csv` — one row per MSnLib spectrum |
292
- | rows | 560,084 data rows (560,085 physical lines, no embedded newlines) |
293
- | bytes | 752,707,651 |
294
- | SHA-256 | `be54b33039cf18675751ea3c6354b592177c899a0cd5df303ae616330133ec07` |
295
- | columns | `mzs, intensities, smiles, precursor_mz, adduct, collision_energy, fold` |
296
- | CSV format | peaks stored as comma-separated strings (`mzs`, `intensities`), one spectrum per row |
297
-
298
- **Managed files on Hugging Face.** The dataset is planned for Hugging Face under the
299
- placeholder id **`dsadd4/UltraMS-MSnLib-Benchmark`** (dataset card and upload commands are
300
- drafted here as `hf_dataset_card.md` and `hf_upload_commands.sh`; the upload has **not**
301
- been executed). The repository will host:
302
 
303
  | hosted file | bytes | SHA-256 | purpose |
304
  | --- | ---: | --- | --- |
305
- | every file of this manifest (`split_A_full_msnlib/`, `splits/`, `queries/`, `libraries/`, `protocol/`, `rebuild/`, docs; 59 files) | ≈ 185.2 MiB total | see `SHA256SUMS` | the two benchmark splits, verifier, docs |
306
- | `split_A_full_msnlib/msnlib_rt.csv.gz` | 1,483,069 | `994053612db874f7ac7985f278e04cc3463f3b93cd649a195bd167c4c6c7d3d8` | compact per-spectrum retention time (`row_index, rt` in seconds); joins `MSnLib.csv` rows 1:1 and supplies the RT used by the label-blind grouping analysis (Figure 3d) |
307
- | `MSnLib.csv` | 752,707,651 | `be54b33039cf18675751ea3c6354b592177c899a0cd5df303ae616330133ec07` | the full source CSV: one row per MSnLib spectrum; every `row_index` / `msnlib_csv_data_row` / `first_msnlib_csv_data_row` pointer resolves here |
308
  | `MSnLib_candidates.json` | 1,368,264,026 | `125a1cdcc57a3fcef8cc76d5322ac0c434cd09b0bfb9e0c9d28bddf052f45fcc` | candidate SMILES lists behind the single-spectrum candidate-ranking task: a JSON object mapping a query SMILES string to its candidate SMILES list (9,886 query entries) |
309
 
310
- The large files are hosted because every table points into them: spectra (`MSnLib.csv`) and
311
- candidate rankings (`MSnLib_candidates.json`). The upload script keeps them in a separate
312
- step and remains dry-run by default.
313
-
314
- It can also be rebuilt from the **MSnLib original release** (Brungs et al., Zenodo
315
- [10.5281/zenodo.11163380](https://doi.org/10.5281/zenodo.11163380), CC BY 4.0): the release
316
- provides 18 per-file MS2 JSONL record lists with exactly 560,084 records in total (equal to
317
- the CSV data-row count), each record carrying `peaks`, `smiles`, `precursor_mz`, `adduct`
318
- and `collision_energy`. The UltraMS CSV conversion writes one row per record in the frozen
319
- conversion order with the columns above and carries the frozen fold labels. The
320
- authoritative row → formula → fold mapping is shipped independently as
321
- `split_A_full_msnlib/row_formula_fold.csv`, so downstream work never depends on
322
- reconstructing the conversion order.
323
-
324
- ### 8.2 Rebuilding split A
325
-
326
- ```bash
327
- python3 split_A_full_msnlib/build_split_a.py \
328
- --csv /path/to/MSnLib.csv \
329
- --output-dir replay_split_a
330
- ```
331
-
332
- Needs Python ≥ 3.10 and RDKit 2026.03.5 (the frozen canonicalisation runtime). The script
333
- verifies all counts and all six table SHA-256 values; with a different RDKit patch release
334
- the canonical-string tables can differ textually while every count still matches (the
335
- script reports that, or downgrades it to a warning with `--lenient-rdkit`).
336
-
337
- ### 8.3 Rebuilding split B
338
-
339
- See [rebuild/README.md](rebuild/README.md). In short:
340
-
341
- ```bash
342
- python3 rebuild/build_library_manifest.py \
343
- --csv /path/to/MSnLib.csv --skip-reference-regression \
344
- --output-dir replay_manifest
345
  ```
346
 
347
- This regenerates `protocol/*.npz`, `smiles_*.json`, `adducts_*.json` and
348
- `manifest_summary.json` (needs NumPy, h5py, RDKit). The CSV tables are then rebuilt from the
349
- protocol arrays through `protocol/derived/row_metadata_*.npz` (see `protocol/README.md`).
350
-
351
- ## 9. Verification
352
-
353
- ```bash
354
- python3 rebuild/verify_release.py # self-contained; no network, no MSnLib download
355
- sha256sum -c SHA256SUMS # or: shasum -a 256 -c SHA256SUMS (macOS)
356
- ```
357
-
358
- `rebuild/verify_release.py` re-derives every published count, ordering hash, disjointness
359
- statement, query/library partition, per-query library positive, cross-split statistic and
360
- file checksum from the shipped files; the complete transcript is in [VERIFY.md](VERIFY.md).
361
- Split-A-specific evidence (including the read-only replay and the voting-unit check) is in
362
- `split_A_full_msnlib/VERIFY.md`.
363
-
364
- ## 10. Known properties and caveats
365
-
366
- 1. **Two splits, two disjointness units.** Split A is formula-disjoint; split B is
367
- compound-disjoint within each polarity. Do not merge them into one global-disjointness
368
- claim and do not reuse a fold label across splits (§2).
369
- 2. **Voting units: official 5,002 source-SMILES groups / 57,436 spectra, alternative
370
- canonical view 4,888 groups / 57,436 spectra.** The official unit is the one used by the
371
- published `n_molecules = 5002` grouping; both tables are shipped (§4.3).
372
- 3. **Retention times are split-A row metadata.** `split_A_full_msnlib/msnlib_rt.csv.gz`
373
- (`row_index, rt` in seconds) is source metadata from the MSnLib release, verified
374
- row-aligned to `MSnLib.csv`; it is not part of split B and carries no fold label of its
375
- own.
376
- 4. **Queries without a library positive are expected** in split B: 1 positive and 33
377
- negative *test* queries (and 8 / 30 *validation* queries) are singleton compounds whose
378
- only spectrum is the query. They enter the FDR denominator but not the recall
379
- denominator; `n_library_positives` is published per query.
380
- 5. **Singleton compounds are retained** in split B (39 positive and 202 negative compounds
381
- have exactly one spectrum). Filtering them changes the benchmark.
382
- 6. **Compound identity is frozen text** (RDKit 2026.03.5 canonical isomeric SMILES). Other
383
- RDKit patch releases can serialise the same molecule differently; compare the published
384
- strings, not freshly canonicalised ones. Molecular formulas are stable across RDKit
385
- patch releases.
386
- 7. **Precursor m/z** is the source CSV text value; the split-B protocol stores it as
387
- float32 and all 441,829 preprocessed rows agree exactly after the cast.
388
- 8. **Collision energy is source metadata**, not a selection criterion; all six values
389
- (15, 20, 30, 45, 60, 75 eV) occur in both polarities.
390
- 9. **Split B libraries are large by design** (≈47.6 positive / ≈42.9 negative spectra per
391
- query on average); ranking must cover the full library, there is no candidate short list.
392
- 10. **Split A includes all adducts** (11 distinct adducts in the test fold), not only the
393
- strict `[M+H]+` / `[M-H]-` subset used by split B.
394
-
395
- ## 11. Provenance and licensing
396
-
397
- The upstream MSnLib release (spectra and molecule metadata) is CC BY 4.0 (Brungs et al.,
398
- Zenodo 10.5281/zenodo.11163380). The split definitions, tables and scripts added by UltraMS
399
- are released under CC BY 4.0 as well. `rebuild/build_library_manifest.py` and
400
- `rebuild/baseline_common.py` are Apache-2.0 files copied from the UltraMS public release.
401
- See [NOTICE.md](NOTICE.md) for the full attribution and licensing statement, and
402
- `protocol/manifest_summary.json` for the frozen split-B manifest (one path field is
403
- redacted to a placeholder; every count, seed and hash is byte-identical).
404
-
405
- ## 12. Citation
406
-
407
- If you use this benchmark, please cite MSnLib and UltraMS:
408
-
409
- * MSnLib: Brungs C., Schmid R., Pluskal T. *MSnLib: efficient generation of open
410
- multi-stage fragmentation mass spectral libraries.* Nature Methods (2025),
411
- doi:10.1038/s41592-025-02813-0; data: Zenodo 10.5281/zenodo.11163380 (CC BY 4.0).
412
- * UltraMS: Li Y., Zhong Y., Liu P., Xia J. *UltraMS* (manuscript in preparation;
413
- code: <https://github.com/Dsadd4/UltraMS>).
414
-
415
- Machine-readable citation metadata is in [`zenodo_metadata.json`](zenodo_metadata.json) and
416
- [`hf_dataset_card.md`](hf_dataset_card.md).
417
-
418
- ## 13. Versioning
419
-
420
- `1.0.0` is the first joint release of splits A and B. Its content is defined by
421
- `stats.json`, `SHA256SUMS` and the frozen `protocol/manifest_summary.json`. Any change to
422
- the splits, the compound/formula identity or the library scope requires a new version
423
- directory and new manifests — the frozen tables must stay frozen so that published
424
- FDR/recall/ranking numbers remain comparable.
 
1
+ ---
2
+ pretty_name: UltraMS MSnLib benchmark (formula-level split A + strict-adduct molecule-level split B)
3
+ license: cc-by-4.0
4
+ language:
5
+ - en
6
+ size_categories:
7
+ - 100K<n<1M
8
+ task_categories:
9
+ - other
10
+ configs:
11
+ - config_name: split_A_formula_split
12
+ data_files: split_A_full_msnlib/formula_split.csv
13
+ - config_name: split_A_row_formula_fold
14
+ data_files: split_A_full_msnlib/row_formula_fold.csv
15
+ - config_name: split_A_test_spectra
16
+ data_files: split_A_full_msnlib/test_spectra.csv
17
+ - config_name: split_A_val_spectra
18
+ data_files: split_A_full_msnlib/val_spectra.csv
19
+ - config_name: split_A_test_molecules_voting_official
20
+ data_files: split_A_full_msnlib/test_molecules_voting.csv
21
+ - config_name: split_A_test_molecules_voting_canonical_view
22
+ data_files: split_A_full_msnlib/test_molecules_voting_canonical_view.csv
23
+ - config_name: split_A_msnlib_rt
24
+ data_files: split_A_full_msnlib/msnlib_rt.csv.gz
25
+ - config_name: split_B_pos_compound_split
26
+ data_files: splits/pos_compound_split.csv
27
+ - config_name: split_B_neg_compound_split
28
+ data_files: splits/neg_compound_split.csv
29
+ - config_name: split_B_pos_val_queries
30
+ data_files: queries/pos_val_queries.csv
31
+ - config_name: split_B_pos_test_queries
32
+ data_files: queries/pos_test_queries.csv
33
+ - config_name: split_B_neg_val_queries
34
+ data_files: queries/neg_val_queries.csv
35
+ - config_name: split_B_neg_test_queries
36
+ data_files: queries/neg_test_queries.csv
37
+ - config_name: split_B_pos_val_library
38
+ data_files: libraries/pos_val_library.csv
39
+ - config_name: split_B_pos_test_library
40
+ data_files: libraries/pos_test_library.csv
41
+ - config_name: split_B_neg_val_library
42
+ data_files: libraries/neg_val_library.csv
43
+ - config_name: split_B_neg_test_library
44
+ data_files: libraries/neg_test_library.csv
45
+ tags:
46
+ - chemistry
47
+ - mass-spectrometry
48
+ - metabolomics
49
+ - small-molecules
50
+ - tandem-ms
51
+ - spectrum-library-search
52
+ - molecule-retrieval
53
+ - benchmark
54
+ - ultraMS
55
  ---
56
 
57
+ # UltraMS MSnLib benchmark
58
 
59
+ Two frozen, independent benchmark splits of the [MSnLib](https://doi.org/10.1038/s41592-025-02813-0)
60
+ tandem mass spectral library, released by UltraMS. The splits are different objects:
61
+
62
+ * **Split A — UltraMS MSnLib formula-level split** (all 560,084 spectra, all adducts):
63
+ 21,107 molecular formulas, split 16,885 / 2,110 / 2,112 formulas and
64
+ 446,667 / 55,980 / 57,437 spectra into train / validation / test. Formula-disjoint. Test
65
+ fold: 57,437 spectra, 2,112 formulas, 5,003 source SMILES / 4,889 canonical molecules.
66
+ Population for single-spectrum candidate ranking, multiple-spectrum voting, label-blind
67
+ grouping, fingerprint prediction and embedding analyses (Figure 2b/2j, 3a/3b/3d/3g,
68
+ 3a_sp_4, 3a_sp_5, single-spectrum baselines). The **official multiple-spectrum voting
69
+ units are the 5,002 MSnLib source-SMILES groups covering 57,436 spectra**
70
+ (`test_molecules_voting.csv`); a canonical-SMILES alternative view (4,888 groups) is also
71
+ provided (`test_molecules_voting_canonical_view.csv`). Per-spectrum retention times
72
+ (`row_index, rt` in seconds) are in `msnlib_rt.csv.gz` for the label-blind grouping and
73
+ multiple-spectrum voting analyses.
74
+ * **Split B — strict-adduct molecule-level split** (`[M+H]+` and `[M-H]-` only): 41,348 /
75
+ 21,293 compounds and 301,636 / 140,193 preprocessed spectra, split 70/15/15 per polarity
76
+ by RDKit canonical isomeric SMILES, with frozen queries and libraries for
77
+ spectrum-to-spectrum library search. Population for Figure 3e/3f/3h, 3h_sp_1 and the
78
+ cross-collision-energy task (6,161 positive / 2,999 negative queries).
79
+
80
+ | split-B task | queries | library spectra | queries with an exact-adduct library positive |
81
  | --- | ---: | ---: | ---: |
82
+ | `[M+H]+` test | 6,202 | 295,434 | 6,201 |
83
+ | `[M+H]+` validation | 6,202 | 250,424 | 6,194 |
84
+ | `[M-H]-` test | 3,193 | 137,000 | 3,160 |
85
+ | `[M-H]-` validation | 3,193 | 116,135 | 3,163 |
 
 
 
 
86
 
87
+ > **Disjointness.** Split A is formula-disjoint (no formula in two folds); split B is
88
+ > molecule-disjoint within each polarity (the train / validation / test compound sets are
89
+ > pairwise empty). The two splits must **not** be merged into a global-disjointness claim:
90
+ > about 41 % of split-B compounds lie in a different split-A fold, and a spectrum can be
91
+ > split-A test while its compound is split-B train. See the package
92
+ > `figures_mapping.md` §2 for the full cross-tabulation.
93
 
94
+ ## Usage
 
 
95
 
96
+ ```python
97
+ import pandas as pd
 
 
 
 
 
 
 
 
98
 
99
+ base = "https://huggingface.co/datasets/dsadd4/UltraMS-MSnLib-Benchmark/resolve/main/"
 
 
 
 
100
 
101
+ # split A — formula-level split of the full library
102
+ formulas = pd.read_csv(base + "split_A_full_msnlib/formula_split.csv")
103
+ rows = pd.read_csv(base + "split_A_full_msnlib/row_formula_fold.csv") # 560,084 rows
104
+ test = pd.read_csv(base + "split_A_full_msnlib/test_spectra.csv") # 57,437 rows
105
+ assert formulas.groupby("formula")["fold"].nunique().max() == 1
106
 
107
+ # split B — strict-adduct molecule-level library search
108
+ compound_split = pd.read_csv(base + "splits/pos_compound_split.csv")
109
+ queries = pd.read_csv(base + "queries/pos_test_queries.csv")
110
+ library = pd.read_csv(base + "libraries/pos_test_library.csv")
111
 
112
+ positives = library.groupby("canonical_isomeric_smiles").size()
113
+ n_pos = queries["canonical_isomeric_smiles"].map(positives).fillna(0).astype(int)
114
+ denominator = int((n_pos > 0).sum()) # 6,201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  ```
116
 
117
+ With `datasets` (one config per table, see the YAML header):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  ```python
120
+ from datasets import load_dataset
121
+ queries = load_dataset("dsadd4/UltraMS-MSnLib-Benchmark", "split_B_pos_test_queries", split="train")
 
 
 
 
122
  ```
123
 
124
+ Peak data are **not** part of the split tables. Every row is joined back to the spectra by
125
+ `row_index` / `msnlib_csv_data_row` / `first_msnlib_csv_data_row`, which point into
126
+ `MSnLib.csv`. `MSnLib.csv` and `MSnLib_candidates.json` are hosted in the same dataset; see
127
+ **Hosted files** below.
128
+
129
+ ## Columns
130
+
131
+ * `split_A_full_msnlib/formula_split.csv`: `formula, fold, n_spectra`
132
+ * `split_A_full_msnlib/row_formula_fold.csv`: `row_index, formula, fold`
133
+ * `split_A_full_msnlib/{test,val}_spectra.csv`: `row_index, smiles, precursor_mz, adduct,
134
+ collision_energy, fold, canonical_isomeric_smiles`
135
+ * `split_A_full_msnlib/test_molecules_voting.csv`: `group_id, smiles, n_spectra` —
136
+ **official** voting units: 5,002 MSnLib-source-SMILES groups covering 57,436 spectra, the
137
+ grouping of the published multiple-spectrum voting task (`n_molecules = 5002`)
138
+ * `split_A_full_msnlib/test_molecules_voting_canonical_view.csv`: `group_id,
139
+ canonical_isomeric_smiles, n_spectra` — alternative canonical view: 4,888 groups covering
140
+ the same 57,436 spectra
141
+ * `split_A_full_msnlib/msnlib_rt.csv.gz`: `row_index, rt` — per-spectrum retention time in
142
+ seconds, aligned 1:1 to the `MSnLib.csv` data rows (560,084 rows)
143
+ * `splits/*_compound_split.csv`: `polarity, compound_id, canonical_isomeric_smiles, split,
144
+ n_spectra, n_frozen_queries, n_raw_smiles_variants, first_msnlib_csv_data_row`
145
+ * `queries/*.csv`: `polarity, split, query_index, compound_id, canonical_isomeric_smiles,
146
+ adduct, msnlib_csv_data_row, msnlib_csv_line, precursor_mz, n_peaks, collision_energy,
147
+ source_smiles_raw, n_library_positives`
148
+ * `libraries/*.csv`: same as queries with `library_index` and `compound_split` instead of
149
+ `query_index`; row order is the frozen library order
150
+
151
+ ## Split-B evaluation protocol
152
+
153
+ 1. Score every query against the complete library of its task (no candidate short list).
154
+ 2. Correct = the top-1 library spectrum has the same canonical compound identity.
 
 
 
 
155
  3. Empirical FDR = `(accepted − correct) / accepted`; identification recall =
156
  `correct / n_queries_with_library_positive` (6,201 / 3,160 for the two test tasks).
157
  Queries without a library positive enter the FDR denominator but not the recall
158
+ denominator; `n_library_positives` is provided per query.
159
+ 4. The test library contains all preprocessed spectra of the polarity except the selected
160
+ test queries; the validation library contains train and validation compounds only.
161
+ 5. Validation is for model selection only; evaluate the test fold once.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
+ ## Hosted files
 
 
 
 
164
 
165
+ The dataset hosts the complete manifest plus two large source files. Every file of the
166
+ manifest is checksummed in `SHA256SUMS`; the two large files are kept in a separate upload
167
+ step (see `hf_upload_commands.sh`, dry-run by default).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  | hosted file | bytes | SHA-256 | purpose |
170
  | --- | ---: | --- | --- |
171
+ | manifest: `split_A_full_msnlib/`, `splits/`, `queries/`, `libraries/`, `protocol/`, `rebuild/`, docs (59 files) | ≈ 185.2 MiB | see `SHA256SUMS` | the two benchmark splits, verifier, docs |
172
+ | `split_A_full_msnlib/msnlib_rt.csv.gz` | 1,483,069 | `994053612db874f7ac7985f278e04cc3463f3b93cd649a195bd167c4c6c7d3d8` | compact per-spectrum retention time (`row_index, rt` in seconds), aligned 1:1 to `MSnLib.csv`; used by the label-blind grouping analysis |
173
+ | `MSnLib.csv` | 752,707,651 | `be54b33039cf18675751ea3c6354b592177c899a0cd5df303ae616330133ec07` | full source CSV: one row per MSnLib spectrum (560,084 rows); every row pointer in the split tables resolves here |
174
  | `MSnLib_candidates.json` | 1,368,264,026 | `125a1cdcc57a3fcef8cc76d5322ac0c434cd09b0bfb9e0c9d28bddf052f45fcc` | candidate SMILES lists behind the single-spectrum candidate-ranking task: a JSON object mapping a query SMILES string to its candidate SMILES list (9,886 query entries) |
175
 
176
+ `MSnLib.csv` is the UltraMS CSV conversion of the MSnLib original release (Zenodo
177
+ 10.5281/zenodo.11163380, CC BY 4.0), whose 18 per-file MS2 JSONL record lists contain the
178
+ same 560,084 spectra. `MSnLib_candidates.json` contains candidate SMILES lists derived from
179
+ the MSnLib compound set; both files carry the MSnLib attribution.
180
+
181
+ ## Provenance, verification, license
182
+
183
+ * Source rows: `MSnLib.csv` (560,084 rows) converted from the MSnLib original release
184
+ (Brungs et al., CC BY 4.0; Zenodo 10.5281/zenodo.11163380).
185
+ * Hosted source files: `MSnLib.csv` (752,707,651 bytes, SHA-256 `be54b330…`) and
186
+ `MSnLib_candidates.json` (1,368,264,026 bytes, SHA-256 `125a1cdc…`).
187
+ * Frozen split-B manifest, seeds 42 / 43, query seed 119; frozen split-A fold assignment
188
+ from the `fold` column of `MSnLib.csv`.
189
+ * `SHA256SUMS` covers every file; `rebuild/verify_release.py` is a self-contained verifier
190
+ that re-checks every count, ordering hash, disjointness statement, cross-split statistic
191
+ and checksum offline.
192
+ * License **CC BY 4.0**, with attribution to MSnLib (CC BY 4.0); Apache-2.0 for the two
193
+ UltraMS producer scripts. See the package `NOTICE.md`.
194
+
195
+ ## Citation
196
+
197
+ ```bibtex
198
+ @misc{ultrams_msnlib_benchmark_2026,
199
+ title = {UltraMS MSnLib benchmark: full-library formula-level split and strict-adduct molecule-level library-search split},
200
+ author = {Li, Yifan and Zhong, Yunhua and Liu, Pan and Xia, Jun},
201
+ year = {2026},
202
+ note = {Derived from MSnLib (Brungs, Schmid, Pluskal; CC BY 4.0, Zenodo 10.5281/zenodo.11163380)},
203
+ howpublished = {Hugging Face / Zenodo dataset, version 1.0.0}
204
+ }
 
 
 
 
 
 
205
  ```
206
 
207
+ Please also cite MSnLib (doi:10.1038/s41592-025-02813-0) and the UltraMS manuscript.