dsadd4's picture
Add the full manifest README alongside the dataset card
df67944 verified
|
Raw History Blame Contribute Delete
25.1 kB

UltraMS MSnLib benchmark

Version 1.0.0 · 2026-11-04 · license CC BY 4.0 (see NOTICE.md)

Two frozen, independent benchmark splits of the MSnLib tandem mass spectral library, built and released by UltraMS:

  • Split A — UltraMS MSnLib formula-level split: the complete library (560,084 spectra, all adducts) split by molecular formula into train / validation / test (16,885 / 2,110 / 2,112 formulas, 446,667 / 55,980 / 57,437 spectra). Formula-disjoint. This is the population for single-spectrum candidate ranking, multiple-spectrum voting, label-blind grouping and embedding analyses.
  • Split B — strict-adduct molecule-level split: the strict [M+H]+ and [M-H]- subsets (447,956 source rows) re-split 70 / 15 / 15 at the level of RDKit canonical isomeric SMILES, separately per polarity, with frozen queries and libraries for spectrum-to-spectrum library search. Molecule-disjoint within each polarity.

Both splits are frozen benchmark definitions with published checksums; neither is a redistribution of the MSnLib spectra.


1. At a glance

Split A (formula-level, all adducts) Split B [M+H]+ Split B [M-H]-
compounds / molecules — (21,107 formulas) 41,348 21,293
spectra 560,084 301,636 140,193
train 16,885 formulas · 446,667 spectra 28,944 compounds · 211,745 spectra 14,907 · 98,401
validation 2,110 formulas · 55,980 spectra 6,202 compounds · 44,881 spectra 3,193 · 20,927
test 2,112 formulas · 57,437 spectra 6,202 compounds · 45,010 spectra 3,193 · 20,865
test task candidate ranking / voting (57,437 queries) 6,202 queries vs 295,434 library spectra 3,193 vs 137,000
queries with an exact-adduct library positive — 6,201 3,160
validation task — 6,202 vs 250,424 3,193 vs 116,135

Split A test fold: 57,437 spectra, 2,112 formulas, 5,003 distinct MSnLib source SMILES, 4,889 distinct RDKit canonical isomeric SMILES. The official multiple-spectrum voting unit is the MSnLib source SMILES string: 5,002 groups covering 57,436 spectra (canonical view: 4,888 groups).

Split B split seeds: 42 ([M+H]+) / 43 ([M-H]-); query seed 119. Split A has no seed: its fold assignment is frozen in the fold column of MSnLib.csv and replayed exactly by split_A_full_msnlib/build_split_a.py.

2. Disjointness: what is claimed — and what is not

split disjointness unit claimed
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)
B RDKit canonical isomeric SMILES, per polarity the train / validation / test compound sets of each polarity are pairwise disjoint

A and B are different objects and must not be combined into a global-disjointness claim. About 41 % of split-B compounds are in a different split-A fold, and a spectrum can be a split-A test spectrum while its compound is a split-B train compound. Concrete numbers:

  • split B [M+H]+ test compounds: 654 are split-A test, 4,922 are split-A train, 626 are split-A validation;
  • split B [M-H]- test compounds: 303 are split-A test, 2,541 are split-A train, 349 are split-A validation;
  • 31,570 split-A test spectra are [M+H]+ rows of split B and 13,413 are [M-H]- rows.

The full cross-tabulation (compound level and spectra level, per polarity, plus the relation of the split-A test fold to split B) is in figures_mapping.md §2. Never report a cross-split score as a held-out result: train and evaluate inside one split.

3. Package layout

ultrams_msnlib_benchmark_v1/
├── README.md                     this file
├── figures_mapping.md            which manuscript panel uses which split (+ cross-split statistics)
├── VERIFY.md                     full verification record and reproducible commands
├── NOTICE.md                     MSnLib attribution, provenance and licensing
├── SHA256SUMS                    checksums of every file except itself
├── stats.json                    machine-readable release summary (all counts + file hashes)
├── split_A_full_msnlib/          split A (formula-level, full library)
│   ├── README.md
│   ├── VERIFY.md                 split-A verification record
│   ├── REPORT.json               split-A machine-readable report
│   ├── build_split_a.py          replay of split A from MSnLib.csv + hash check
│   ├── formula_split.csv(.gz)                21,107 formulas → fold, n_spectra
│   ├── row_formula_fold.csv(.gz)             560,084 rows → formula, fold
│   ├── test_spectra.csv(.gz)                 57,437 test spectra
│   ├── val_spectra.csv(.gz)                  55,980 validation spectra
│   ├── test_molecules_voting.csv(.gz)        5,002 official source-SMILES voting units
│   ├── test_molecules_voting_canonical_view.csv(.gz)  4,888 canonical-SMILES alternative view
│   └── msnlib_rt.csv.gz                      560,084 row_index → retention time (seconds)
├── splits/                       split B compound tables (70/15/15, per polarity)
│   ├── pos_compound_split.csv(.gz)           41,348 compounds
│   └── neg_compound_split.csv(.gz)           21,293 compounds
├── queries/                      split B query spectra
│   ├── pos_val_queries.csv(.gz)              6,202
│   ├── pos_test_queries.csv(.gz)             6,202
│   ├── neg_val_queries.csv(.gz)              3,193
│   └── neg_test_queries.csv(.gz)             3,193
├── libraries/                    split B library spectra
│   ├── pos_val_library.csv(.gz)              250,424
│   ├── pos_test_library.csv(.gz)             295,434
│   ├── neg_val_library.csv(.gz)              116,135
│   └── neg_test_library.csv(.gz)             137,000
├── protocol/                     frozen split-B protocol arrays and manifest
│   ├── manifest_summary.json
│   ├── protocol_{pos,neg}.npz
│   ├── smiles_{pos,neg}.json
│   ├── adducts_{pos,neg}.json
│   ├── derived/row_metadata_{pos,neg}.npz
│   └── README.md
├── rebuild/
│   ├── build_library_manifest.py the split-B producer (replays MSnLib.csv)
│   ├── baseline_common.py        its helper module
│   ├── verify_release.py         self-contained verifier for the whole package
│   ├── LICENSE-APACHE-2.0.txt
│   └── README.md
├── hf_dataset_card.md            Hugging Face dataset card draft
├── hf_upload_commands.sh         upload commands, dry-run by default, not executed
└── zenodo_metadata.json          Zenodo deposition metadata draft

Every plain .csv has a byte-identical .csv.gz twin; rebuild/verify_release.py checks this, all counts, all orderings, the cross-split statistics and the checksums.

4. Split A — UltraMS MSnLib formula-level split

4.1 Definition

For every MSnLib spectrum the neutral molecular formula is computed from the source SMILES with RDKit (rdMolDescriptors.CalcMolFormula(Chem.MolFromSmiles(smiles))). The frozen fold column of MSnLib.csv assigns each formula to exactly one fold; the split is the formula-grouped 80/10/10 partition that results. The rule was verified for all 560,084 spectra: 21,107 formulas, none in more than one fold. This is the frozen benchmark definition; build_split_a.py replays it from MSnLib.csv and reproduces every table byte-for-byte.

4.2 Tables

file rows columns
formula_split.csv 21,107 formula, fold, n_spectra — ordered by fold (train, valid, test) then formula
row_formula_fold.csv 560,084 row_index, formula, fold — 0-based MSnLib.csv data row → formula → fold
test_spectra.csv 57,437 row_index, smiles, precursor_mz, adduct, collision_energy, fold, canonical_isomeric_smiles
val_spectra.csv 55,980 same schema for the validation fold
test_molecules_voting.csv 5,002 group_id, smiles, n_spectra — official voting units (MSnLib source SMILES)
test_molecules_voting_canonical_view.csv 4,888 group_id, canonical_isomeric_smiles, n_spectra — alternative canonical view
msnlib_rt.csv.gz 560,084 row_index, rt — per-spectrum retention time in seconds (gzipped only, see §4.5)

row_index is the 0-based data row of MSnLib.csv (physical line = data row + 2). The tables do not carry peak data; join on row_index against MSnLib.csv (see §8).

4.3 Official voting units — read this before using the voting tables

The official multiple-spectrum voting units are the 5,002 MSnLib source-SMILES groups covering 57,436 spectra, exactly the grouping used by the published multiple-spectrum voting task (Figure 3d and the Figure 3a voting readouts, n_molecules = 5002). The test fold contains 5,003 distinct source SMILES strings; one occurs in only one spectrum, hence 5,002 groups. This table is test_molecules_voting.csv (columns group_id, smiles, n_spectra) and it is verified member-for-member against the repository voting table (benchmarks/molecular_identification/data/multiple_spectrum_voting_per_group.csv.gz).

An alternative canonical view is provided as test_molecules_voting_canonical_view.csv: the same test spectra grouped by RDKit canonical isomeric SMILES give 4,888 groups covering the same 57,436 spectra (114 source-string groups merge into chemically identical molecules; the single excluded molecule is CC(C)(C)OC(=O)NCC1(CC(=O)O)CCCCC1). This view is not the official voting unit.

No data was altered to force either count. See split_A_full_msnlib/VERIFY.md §7 and REPORT.json → anomalies.

4.5 Retention times (RT)

split_A_full_msnlib/msnlib_rt.csv.gz is a compact companion table needed by the label-blind grouping and multiple-spectrum voting analyses (Figure 3d): row_index is the 0-based MSnLib.csv data row (0 … 560,083) and rt is the retention time in seconds, kept in the source text representation.

RT is source metadata from the MSnLib records (CC BY 4.0, Zenodo 10.5281/zenodo.11163380; see NOTICE.md). The table was exported from MSnLib_with_rt.csv (755,984,910 bytes, SHA-256 a5b7c38228287c5c1de401050445319b331ee9a5f17993d6e104e9a734fe2964) after verifying row-by-row that its first seven columns are identical to MSnLib.csv in the same order (560,084/560,084 rows, 0 mismatches; see split_A_full_msnlib/VERIFY.md §5.4). The full 756 MB CSV is not duplicated; only this 1.4 MB gzipped table is shipped.

import pandas as pd

test = pd.read_csv("split_A_full_msnlib/test_spectra.csv")
rt = pd.read_csv("split_A_full_msnlib/msnlib_rt.csv.gz")   # row_index, rt
test_rt = test.merge(rt, on="row_index", how="left")
assert test_rt["rt"].notna().all()

The same row_index join works for every row of row_formula_fold.csv.

Provenance of split A

Source rows, formulas and folds were computed read-only in an isolated data-preparation environment with RDKit 2026.03.5. The split-A tables were frozen from that run; cross-checks against the historical per-fold CSV files, against the MSnLib original JSON formula fields, and against the repository voting table are recorded in split_A_full_msnlib/VERIFY.md.

5. Split B — strict-adduct molecule-level split

5.1 Definition

Split B keeps only the strict [M+H]+ (303,709 source rows) and [M-H]- (144,247 source rows) spectra. After the frozen spectrum preprocessing (drop m/z ≤ 0 peaks, require at least 3 peaks, normalise to the base peak, keep the 150 most intense peaks and sort by m/z) 2,073 positive and 4,054 negative rows are dropped, leaving 301,636 and 140,193 preprocessed spectra. Compound identity is RDKit canonical isomeric SMILES (frozen with RDKit 2026.03.5). Per polarity the sorted compound list is shuffled with random.Random(42) ([M+H]+) / random.Random(43) ([M-H]-) and split 70 / 15 / 15; one query spectrum per validation/test compound is drawn with a fresh random.Random(119).

5.2 Tables

table schema
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
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
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

5.3 Protocol

  1. Score every query against the complete library of its task (no candidate short list).
  2. A retrieved library spectrum is correct iff its canonical isomeric SMILES equals the query's (exact same-adduct spectrum of the same molecule).
  3. Empirical FDR = (accepted − correct) / accepted; identification recall = correct / n_queries_with_library_positive (6,201 / 3,160 for the two test tasks). Queries without a library positive enter the FDR denominator but not the recall denominator; n_library_positives is published per query.
  4. The test library is every preprocessed spectrum of the polarity except the selected test queries (it therefore still contains further spectra of the test molecules; a query never occurs in its own library). The validation library contains train and validation compounds only, so test compounds never influence validation scores.
  5. Validation is for model selection only; the test fold is evaluated once.

The split-B tables deliberately do not carry the formula-level fold of the spectra: that label belongs to split A. To obtain each split-B row's split-A fold, join msnlib_csv_data_row (queries/libraries) or first_msnlib_csv_data_row (compound split) against split_A_full_msnlib/row_formula_fold.csv; the packaged verifier does exactly this for the cross-split statistics.

The frozen row-index arrays behind these tables are in protocol/; the CSV tables are a human-readable view. rebuild/build_library_manifest.py replays them bit-for-bit from MSnLib.csv, and rebuild/verify_release.py checks the tables against the arrays and the frozen manifest.

5.4 Cross-collision-energy subtask

The cross-collision-energy library-search task uses split B test queries that were measured at two or more collision energies: 6,161 positive and 2,999 negative queries (out of 6,202 / 3,193 split-B test queries). The task pairs a low-energy query spectrum with a high-energy reference library (or vice versa) and asks for the same-molecule hit; the query identities are a subset of the split-B test queries published here. The CE values in MSnLib are 15, 20, 30, 45, 60 and 75 eV. The cross-CE pairing manifest and readouts are part of the UltraMS repository, not of this split package.

6. Relation to split A

Split A and split B are independent; see §2 for the disjointness statement and figures_mapping.md §2 for the full cross-tabulation. Summary: 58.9 % positive and 59.4 % negative split-B compounds keep the same fold in split A; 654 positive and 303 negative split-B test compounds are also split-A test compounds; 31,570 / 13,413 split-A test spectra are [M+H]+ / [M-H]- rows of split B.

7. Manuscript figures

figures_mapping.md maps every figure panel to the split it uses:

  • A: Figure 2b, Figure 2j, Figure 3a, 3b, 3d, 3g, 3a_sp_4, 3a_sp_5 and the single-spectrum baselines Top-1 table;
  • B: Figure 3e, 3f, 3h, 3h_sp_1 and the cross-collision-energy task (6,161 / 2,999);
  • not this dataset: NPLIB1 and MassSpecGym comparison panels (independent external benchmarks); Figure 3c / 3i case studies are not split-defined.

Candidate-ranking tables (the per-formula candidate lists behind Figure 3a/3b/3d/3g) are part of the UltraMS repository, not of this split package; this package provides the frozen queries, identities and folds they are evaluated on.

8. Data acquisition and rebuilding

8.1 The spectra are not part of this manifest

This package publishes splits and identifiers, not peak arrays. Every table is joined back to the spectra through row_index / msnlib_csv_data_row, which point into MSnLib.csv; both large files are hosted in the same Hugging Face dataset (see the managed-file table below) rather than duplicated in this manifest.

item value
file MSnLib.csv — one row per MSnLib spectrum
rows 560,084 data rows (560,085 physical lines, no embedded newlines)
bytes 752,707,651
SHA-256 be54b33039cf18675751ea3c6354b592177c899a0cd5df303ae616330133ec07
columns mzs, intensities, smiles, precursor_mz, adduct, collision_energy, fold
CSV format peaks stored as comma-separated strings (mzs, intensities), one spectrum per row

Managed files on Hugging Face. The dataset is planned for Hugging Face under the placeholder id dsadd4/UltraMS-MSnLib-Benchmark (dataset card and upload commands are drafted here as hf_dataset_card.md and hf_upload_commands.sh; the upload has not been executed). The repository will host:

hosted file bytes SHA-256 purpose
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
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)
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
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)

The large files are hosted because every table points into them: spectra (MSnLib.csv) and candidate rankings (MSnLib_candidates.json). The upload script keeps them in a separate step and remains dry-run by default.

It can also be rebuilt from the MSnLib original release (Brungs et al., Zenodo 10.5281/zenodo.11163380, CC BY 4.0): the release provides 18 per-file MS2 JSONL record lists with exactly 560,084 records in total (equal to the CSV data-row count), each record carrying peaks, smiles, precursor_mz, adduct and collision_energy. The UltraMS CSV conversion writes one row per record in the frozen conversion order with the columns above and carries the frozen fold labels. The authoritative row → formula → fold mapping is shipped independently as split_A_full_msnlib/row_formula_fold.csv, so downstream work never depends on reconstructing the conversion order.

8.2 Rebuilding split A

python3 split_A_full_msnlib/build_split_a.py \
    --csv /path/to/MSnLib.csv \
    --output-dir replay_split_a

Needs Python ≥ 3.10 and RDKit 2026.03.5 (the frozen canonicalisation runtime). The script verifies all counts and all six table SHA-256 values; with a different RDKit patch release the canonical-string tables can differ textually while every count still matches (the script reports that, or downgrades it to a warning with --lenient-rdkit).

8.3 Rebuilding split B

See rebuild/README.md. In short:

python3 rebuild/build_library_manifest.py \
    --csv /path/to/MSnLib.csv --skip-reference-regression \
    --output-dir replay_manifest

This regenerates protocol/*.npz, smiles_*.json, adducts_*.json and manifest_summary.json (needs NumPy, h5py, RDKit). The CSV tables are then rebuilt from the protocol arrays through protocol/derived/row_metadata_*.npz (see protocol/README.md).

9. Verification

python3 rebuild/verify_release.py     # self-contained; no network, no MSnLib download
sha256sum -c SHA256SUMS              # or: shasum -a 256 -c SHA256SUMS (macOS)

rebuild/verify_release.py re-derives every published count, ordering hash, disjointness statement, query/library partition, per-query library positive, cross-split statistic and file checksum from the shipped files; the complete transcript is in VERIFY.md. Split-A-specific evidence (including the read-only replay and the voting-unit check) is in split_A_full_msnlib/VERIFY.md.

10. Known properties and caveats

  1. Two splits, two disjointness units. Split A is formula-disjoint; split B is compound-disjoint within each polarity. Do not merge them into one global-disjointness claim and do not reuse a fold label across splits (§2).
  2. Voting units: official 5,002 source-SMILES groups / 57,436 spectra, alternative canonical view 4,888 groups / 57,436 spectra. The official unit is the one used by the published n_molecules = 5002 grouping; both tables are shipped (§4.3).
  3. Retention times are split-A row metadata. split_A_full_msnlib/msnlib_rt.csv.gz (row_index, rt in seconds) is source metadata from the MSnLib release, verified row-aligned to MSnLib.csv; it is not part of split B and carries no fold label of its own.
  4. Queries without a library positive are expected in split B: 1 positive and 33 negative test queries (and 8 / 30 validation queries) are singleton compounds whose only spectrum is the query. They enter the FDR denominator but not the recall denominator; n_library_positives is published per query.
  5. Singleton compounds are retained in split B (39 positive and 202 negative compounds have exactly one spectrum). Filtering them changes the benchmark.
  6. Compound identity is frozen text (RDKit 2026.03.5 canonical isomeric SMILES). Other RDKit patch releases can serialise the same molecule differently; compare the published strings, not freshly canonicalised ones. Molecular formulas are stable across RDKit patch releases.
  7. Precursor m/z is the source CSV text value; the split-B protocol stores it as float32 and all 441,829 preprocessed rows agree exactly after the cast.
  8. Collision energy is source metadata, not a selection criterion; all six values (15, 20, 30, 45, 60, 75 eV) occur in both polarities.
  9. Split B libraries are large by design (≈47.6 positive / ≈42.9 negative spectra per query on average); ranking must cover the full library, there is no candidate short list.
  10. Split A includes all adducts (11 distinct adducts in the test fold), not only the strict [M+H]+ / [M-H]- subset used by split B.

11. Provenance and licensing

The upstream MSnLib release (spectra and molecule metadata) is CC BY 4.0 (Brungs et al., Zenodo 10.5281/zenodo.11163380). The split definitions, tables and scripts added by UltraMS are released under CC BY 4.0 as well. rebuild/build_library_manifest.py and rebuild/baseline_common.py are Apache-2.0 files copied from the UltraMS public release. See NOTICE.md for the full attribution and licensing statement, and protocol/manifest_summary.json for the frozen split-B manifest (one path field is redacted to a placeholder; every count, seed and hash is byte-identical).

12. Citation

If you use this benchmark, please cite MSnLib and UltraMS:

  • MSnLib: Brungs C., Schmid R., Pluskal T. MSnLib: efficient generation of open multi-stage fragmentation mass spectral libraries. Nature Methods (2025), doi:10.1038/s41592-025-02813-0; data: Zenodo 10.5281/zenodo.11163380 (CC BY 4.0).
  • UltraMS: Li Y., Zhong Y., Liu P., Xia J. UltraMS (manuscript in preparation; code: https://github.com/Dsadd4/UltraMS).

Machine-readable citation metadata is in zenodo_metadata.json and hf_dataset_card.md.

13. Versioning

1.0.0 is the first joint release of splits A and B. Its content is defined by stats.json, SHA256SUMS and the frozen protocol/manifest_summary.json. Any change to the splits, the compound/formula identity or the library scope requires a new version directory and new manifests — the frozen tables must stay frozen so that published FDR/recall/ranking numbers remain comparable.