Abstract
Liquid chromatography–mass spectrometry (LC–MS) and nuclear magnetic resonance (NMR) spectroscopy are complementary analytical techniques widely used in proteomics, metabolomics, and structural biology. Both generate high-dimensional, noisy spectra where overlapping peaks complicate interpretation. LC–MS relies on retention time (RT) separation before mass analysis, while multidimensional NMR spreads information across chemical-shift axes to reduce congestion. However, comparative or replicate experiments often introduce RT shifts in LC–MS or frequency shifts in NMR, hindering accurate matching of corresponding features. In some experiments, such as variable-temperature NMR, the shifts are intentionally triggered, and frequency tracking provides important information. In any case, a robust, scalable alignment across runs is critical for reliable compound identification, quantification, and structural analysis. We propose a truncated Wasserstein distance-based algorithm for aligning LC–MS and NMR spectra. By constraining maximum transport distance and formulating alignment as a minimum-cost flow problem solved via the Network Simplex algorithm, our method accelerates computation, suppresses spurious matches, and improves robustness to noise. On benchmark LC–MS datasets, it achieved 0.97 precision, 0.96 recall, and a 0.6-s runtime, outperforming OpenMS and DeepRTAlign tools. For NMR data, the algorithm proved effective in 2D, 4D, and even 7D analyses. The algorithm is implemented in wnetalign with supporting modules wnet and pylmcf, available on PyPI and GitHub under permissive licenses: https://github.com/michalsta/pylmcf, https://github.com/michalsta/wnet, https://github.com/michalsta/wnetalign.
Keywords: nuclear magnetic resonance spectroscopy, liquid chromatography–mass spectrometry, spectra alignment, optimal transport, Wasserstein distance, network simplex algorithm
Introduction
Liquid chromatography–mass spectrometry (LC–MS) and nuclear magnetic resonance (NMR) spectroscopy are among the most widely used analytical techniques in chemistry, biology, and medicine. They provide complementary insights into the composition, structure, and dynamics of complex molecular systems.
While LC–MS offers high sensitivity and is particularly effective for compound detection and quantification in complex mixtures, NMR provides detailed information about molecular structure and dynamics. However, both techniques generate large, high-dimensional datasets that are often noisy, redundant, and computationally demanding to interpret.
A mass spectrometer measures the mass-to-charge ratio (m/z) of ions and presents the results as a mass spectrum. In such spectra, the intensity is plotted as a function of m/z.
In the NMR spectrum, each compound gives rise to a characteristic pattern of peaks, often sufficient to identify it. Unlike LC–MS, no reference is necessary—the molecular structure can be determined ab initio, at least in simple cases. For complex samples, such as macromolecules or mixtures, the overlap of spectral peaks hampers the analysis. To address this problem, various multidimensional NMR experiments were developed. Multidimensional NMR spreads the spectral information across two or more chemical shift axes, effectively adding new dimensions to the data. This reduces spectral congestion and improves the separation of overlapping signals, thereby enhancing interpretability and enabling the structural analysis of large biomolecules, such as proteins and nucleic acids. Moreover, the multidimensional experiments enable the observation of internuclear couplings via various interactions, boost sensitivity through indirect detection of nuclei resonating at low frequencies, and even allow the observation of directly undetectable multiple-quantum coherences.
In this context, it is instructive to compare NMR with another widely used technique in analytical chemistry: LC–MS. While fundamentally different in physical principles, both NMR and LC–MS share a similar analytical challenge: the need to resolve overlapping signals arising from complex mixtures. In LC–MS, this is achieved by chromatographic separation prior to mass analysis. Components of a sample are separated based on their interactions with the stationary phase inside a chromatography column, and elute at different RTs before being introduced into the mass spectrometer. The resulting spectra span 3D: mass-to-charge ratio, retention time (RT), and signal intensity.
Both multidimensional NMR and LC–MS address the problem of signal overlap by introducing additional dimensions that help distinguish between different chemical components. In both techniques, these higher-dimensional representations aim to disentangle the contributions of individual compounds and improve the specificity and interpretability of the data.
However, increasing the number of dimensions comes at a cost: the volume and complexity of the resulting datasets grow substantially. This, in turn, introduces significant challenges related to data processing—including signal extraction, noise reduction, alignment, and the identification of meaningful patterns within high-dimensional, often noisy, measurements. These issues are central across both modalities and have motivated the search for more effective strategies of spectral data interpretation in complex chemical and biological systems.
Motivation and related research
Performing LC–MS experiments typically involves conducting multiple runs of the same or similar biological samples, either as technical or biological replicates. Technical replicates consist of repeated runs of the same sample to assess instrument reproducibility. Biological replicates, in contrast, capture biological variability by analyzing samples obtained under different conditions or at various time points. In both cases, analytes may elute at varying RTs and occasionally at slightly different mass-to-charge (m/z) values. While variation in m/z is usually minimal due to high mass resolution, RT variability can be substantial. These shifts may result from numerous factors, including instrumental drift, temperature fluctuations, column aging, ionization efficiency, variation in signal intensity, and random effects during sample collection or injection. Notably, such RT shifts can occur even in well-calibrated LC–MS systems operated within the same laboratory and on the same instrument [1].
Before further analysis, it is essential to reconcile these variations by aligning the spectra, i.e. mapping corresponding analytes across runs. While certain aspects of RT variability can be minimized experimentally, much of the alignment process relies on computational methods. LC–MS data alignment aims to produce a list of consensus features—groups of peaks, each representing the same chemical entity across multiple runs. In the case of pairwise alignment, consensus features are defined as matching peak pairs from two spectra; for more than two runs, they are sets of matched features ideally present in all spectra.
Numerous alignment algorithms have been proposed, many of which rely on a warping function—a transformation that models systematic RT distortions across runs. However, the ultimate goal remains the same: to accurately identify corresponding peaks in different spectra that represent the same analyte. Due to the high complexity of LC–MS data, only a few algorithms attempt to model this directly and robustly [2]. Furthermore, it is important to account for spurious peaks, which may arise from noise or sample-specific compounds not found in other spectra. These should remain unaligned to avoid introducing false matches.
A similar challenge is encountered in NMR spectroscopy, especially in comparative studies involving multiple multidimensional NMR spectra. In this setting, peak shifts across spectra are common and may be caused by environmental effects (e.g. pH or temperature differences), instrument variability, or specific sample interactions. As in LC–MS, these shifts hinder comparative and statistical analyses, as well as automated structure elucidation. Sometimes, however, they are introduced in a controlled manner and provide important information. For example, the temperature-induced shifts are probes of hydrogen bonding, solvent accessibility [3, 4], and structure changes [5]. Their non-linearities are connected to the presence of low-populated excited states of a protein [6, 7]. To measure these so-called temperature coefficients, effective peak-tracking algorithms have to be developed [8].
While alignment in 1D NMR is already a non-trivial task, multidimensional NMR alignment presents a significantly more complex problem. Misalignments can occur along multiple frequency dimensions simultaneously, and the direction and magnitude of the shifts may vary between dimensions and across peaks.
Among recent developments, optimal transport theory has emerged as a promising framework for addressing various spectral alignment problems. For instance, the Masserstein algorithm applied the 1D Wasserstein distance to deconvolve mass spectra, successfully separating overlapping isotopic envelopes and filtering out noise [9]. This idea was extended to NMR by the Magnetstein algorithm, which incorporated a denoising step tailored for 1D NMR spectra. However, both approaches remained restricted to univariate data.
In the context of LC–MS alignment, the Alignstein algorithm [10] applied the Sinkhorn approximation to compute optimal transport maps between spectra. Although it demonstrated a strong alignment performance, especially on noisy data, it suffered from computational inefficiency when applied to large-scale datasets.
Beyond optimal transport-based strategies, a broad range of LC–MS alignment methods have been developed and systematically benchmarked. A comparative evaluation presented in [2] examined commonly used tools such as OpenMS [11, 12], msInspect [13], SpecArray [14], XAlign [15], XCMS [16], and MZmine [17]. These tools represent a variety of approaches, including RT correction, peak matching heuristics, and statistical modeling. One of the benchmark datasets from that study was also used in the present work for evaluation and for comparison with the Alignstein algorithm. The corresponding results are provided in the Supplementary Material.
Several methods have been developed to tackle NMR alignment. While 1D NMR benefits from mature tools such as icoshift [18], CluPA [19], and Speaq [20], there remains a gap in robust and scalable alignment strategies for multidimensional spectra. In recent years, however, a number of promising developments have emerged.
In 2023, the GIPMA algorithm (Global Intensity-Guided Peak Matching and Alignment) was proposed for the alignment of 2D 1H-13C HSQC spectra in metabolomics. GIPMA uses intensity-weighted clustering to dynamically group peaks across multiple samples, achieving accurate alignment on over 80 real-world biological spectra with minimal parameter tuning [21].
Despite these advances, most approaches are still confined either to 1D or to 2D datasets or require manual intervention and problem-specific heuristics. At present, a general-purpose, automated, and scalable solution capable of aligning multidimensional NMR spectra—handling nonlinear distortions, partial peak overlap, and noisy data—remains an open challenge in the field.
In this paper, we propose a novel method for spectra alignment based on optimal transport theory. This framework addresses the problem of transferring mass between probability distributions with minimal cost, which we quantify using the truncated Wasserstein distance. To apply this concept in proteomics, spectra are modeled as discrete probability measures. This approach has previously been shown to be effective in 1D mass spectra analysis [9, 22], as well as in LC–MS alignment [10].
Materials and methods
Truncated Wasserstein distance
The Wasserstein distance provides a principled way to quantify dissimilarity between two probability measures by solving an optimal transport problem [23]. While its computation admits a closed-form solution in 1D, extending it to multidimensional data is substantially more challenging, as the optimal transport plan must be determined numerically.
Several approaches have been proposed to approximate the Wasserstein distance in higher dimensions, including entropy-regularized methods such as the Sinkhorn algorithm [24], sliced-Wasserstein distances based on 1D projections, and classical linear programming formulations [9, 22, 25]. However, these methods either scale poorly or provide only approximate solutions, and few of them allow efficient recovery of the transport plan itself.
In the context of spectra alignment, transporting all signal mass is neither necessary nor biologically justified. Therefore, we base our approach on the truncated Wasserstein distance, defined directly as an optimal transport problem
![]() |
(1) |
where
denotes the set of admissible transport plans between probability measures
and
, and
is the truncated cost function
![]() |
Here
denotes a standard distance metric, such as the Euclidean norm or the
-norm. In the spectrometric setting,
and
represent the locations of spectral features (e.g. mass-to-charge ratios or chemical shift positions) in two spectra. The difference
thus corresponds to a shift along the spectral axis. The truncation prevents transport between distant spectral features, restricting alignment to biologically plausible matches and improving the robustness and accuracy of the proposed method.
WNetAlign: Wasserstein flow alignment
The problem of calculation of optimal transport (with respect to the Truncated Wasserstein Distance) can be represented as an instance of the well-known Min-Cost-Flow problem [26], by constructing a special graph, as pictured in Fig. 1. The graph contains a node for every signal in each of the aligned spectra (blue and orange nodes,
and
, respectively) and two special nodes: the source and the sink node. Next, we connect the source node and the nodes from the first spectrum (the blue ones) with edges, each with capacity
, i.e. the signal intensity of the
peak, and zero cost. Similarly, we connect the (orange) nodes corresponding to the second spectrum to the sink. Next, for each pair of nodes in respective spectra, we join them with a “matching” edge of infinite capacity, and cost equal to the distance between the nodes. We also add a special “mismatch” edge with infinite capacity and cost equal to
, which is a parameter of the algorithm. Last, it can be easily shown that “matching” edges with cost greater than
will never carry any flow, and can be safely dropped from the graph, without affecting the result (represented by dotted lines in Fig. 1). This has the additional benefit of speeding up the algorithm, because it will usually cause the graph to be sparse rather than dense. Furthermore, it also represents the expected behavior of the alignment: it represents the maximum distance of signal shifts which we expect in the spectra, and prevents signals that lie unreasonably far from one another from being matched.
Figure 1.

Flow network used to compute the optimal transport plan corresponding to the Truncated Wasserstein Distance between two spectra. The nodes
represent the signals of the
spectrum and the nodes
the signals of the
spectrum. Each edge is labeled with a pair of numbers (
,
), where
is the flow capacity of the edge, and
is the cost of transporting a unit of flow through the edge. For the edges connecting nodes
to
, the cost of transporting a unit of flow is equal to the distance (
) between the signals
while flow capacity is infinite. For incoming edges of
nodes and outgoing edges of
nodes, the flow capacity is equal to the peak’s signal intensity (
and
, respectively), while transport cost equals zero. The edge joining source and sink nodes carries flow corresponding to unmatched signals.
Next, unlike previous approaches in spectrometry [9, 10, 22, 25], which constructed similar flow networks but ultimately diverged from a pure MCF formulation and were forced to use generic linear programming solvers, we use the Network Simplex algorithm [27] to compute the min-cost-flow in the constructed graph, resulting in a dramatic speedup. Although Network Simplex has an exponential theoretical worst-case runtime, in practice, it exhibits excellent performance—better than the best-known polynomial-time algorithms [28]. For reasonable values of
, the alignment graph is typically sparse in practice (the number of edges is proportional to the number of signals, multiplied by a constant density factor). As a result, the observed runtime is nearly linear with respect to the number of signals in each spectrum.
PXD000484 liquid chromatographymass spectrometry dataset
The algorithm was evaluated using the PXD000484 dataset from the PRIDE repository. This dataset consists of 56 breast cancer tissue samples, each obtained from a different patient. The samples were microdissected, sonicated, and subjected to in-solution digestion. Mass spectrometry analysis was performed using an LTQ-Orbitrap instrument coupled with a nano-LC system, generating Thermo.RAW files as output [29].
All further data preprocessing was carried out by the authors of this paper using the OpenMS 3.3.0 TOPP tools. All spectra were first converted to the.mzML format using the FileConverter tool, followed by feature detection using the FeatureFinderCentroided function. The process of establishing ground truth for alignment is described in detail in Section 1.1 of the Supplementary Materials.
Alignment of the liquid chromatographymass spectrometry dataset
In LC–MS data, RT shifts are typically much larger in magnitude than shifts observed in the m/z dimension, which are generally highly stable, with deviations limited to small instrument-specific mass errors. When aligning spectra, these differences in scale must be taken into account. If uncorrected, the substantial RT shifts can overshadow the comparatively small m/z deviations, leading to suboptimal alignments. To address this imbalance, it is necessary to rescale the 2D so that RT and m/z shifts become comparable.
To account for the differing magnitudes of variation in RT and m/z, we express the alignment thresholds in terms of two interpretable parameters, max_mz_shift and max_rt_shift, which define the maximum expected shifts in each dimension. The m/z axis is rescaled by the ratio
, thereby ensuring that RT and m/z shifts are comparable in scale. After this normalization step, both
and
are set to max_rt_shift, providing a unified distance threshold for alignment across dimensions. Consequently, features can only be matched to those lying within the predefined maximum shifts in each dimension.
After this process, the spectra are aligned using the proposed algorithm. Spectra should be in centroid mode, where each feature is represented by a single point defined by its m/z, RT, and intensity. The alignment process then produces a list of consensus features, i.e. pairs of signals from aligned spectra corresponding to the same analyte.
To construct a ground truth reference for feature alignment, we annotated the raw mass spectrometry files using MaxQuant. The ground truth was then defined as the set of feature pairs that were annotated with the same high-confidence peptide sequence. The details are provided in Section 1.1 of Supplementary materials.
As proposed by Lange et al. [2], the primary metrics for evaluating LC–MS alignment methods are recall and precision, defined as
, where TP (true positives) are aligned pairs of features that were both assigned to the same peptide, FN (false negatives) are missed alignments that should have been detected, TP+FN is then equal to the number of feature matches in the ground truth. FP (false positives) are incorrect matches. In this context, the input to the alignment algorithm is the complete list of features detected by OpenMS, of which only a small subset has confident peptide identifications. A match is considered incorrect under two conditions: (i) the matched features have different peptide identifications, or (ii) one feature in the matched pair lacks a peptide identification, while the other is identified and present in the ground truth, indicating that it should instead be aligned to a feature with the same peptide identification. The procedure of evaluation is shown in Fig. 2.
Figure 2.
(a) Process of evaluation. In each panel, blue and orange represent aligned spectra. For clarity, only a small region of the spectra is shown. Large dots indicate features detected by OpenMS. (a1) Lines connect features aligned by the WNetAlign algorithm. (a2) Large dots indicate features with reliable peptide identifications. Lines connect features sharing the same peptide identification; these connections define the ground truth. (a3) Large dots represent all OpenMS-detected features, with black dots marking those with reliable peptide identifications. WNetAlign alignments are shown in blue if correct (true positives) and in red if incorrect (false positives), as defined in the Results section. Matches connected by dashed lines are excluded from evaluation due to insufficient reliable peptide identifications. (b) Evaluation results and comparison with DeepRTAlign and OpenMS. The PXD000484 dataset consists of two batches: MT and TDM. The performance of all algorithms varies between these batches. When aligning spectra across different batches, the WNetAlign algorithm maintains reasonable performance, DeepRTAlign performs slightly worse, while OpenMS fails to align reliably, achieving a recall of <0.3. Alignment results are significantly improved when spectra from the same batch are compared. Across all alignment scenarios, the WNetAlign algorithm consistently outperformed both DeepRTAlign and OpenMS. (c) Examples of alignment evaluation on the MT–MT pair of spectra and the MT–TDM pair of spectra. The lines connect matched features in both spectra. True positive matches are highlighted in blue, while false positive matches are highlighted in red. Longer lines correspond to greater RT shifts between spectra.
2D
H-
N HSQC nuclear magnetic resonance dataset
The algorithm was evaluated on the series of 2D
H-
N HSQC spectra of
N-labeled GB1 protein (Immunoglobulin G-binding protein G, IgG-binding protein G) measured at different temperatures:
, and
(Fig. 3).
Figure 3.
Evaluation on the NMR dataset. The GB1 1H 15N HSQC spectra measured in the different temperatures (a). Definition of performance metrics taking into account unmatched peaks from both spectra (b). To assess the quality of the chain alignment (Section 2.6), we clustered the first spectrum in a series (
C) using the K-Means algorithm. We then colored the peaks depending on the cluster of the starting point of the chain (c3 and c4) to assess how well the WNetAlign algorithm reconstructs the original cluster membership (c1 and c2). Performance evaluation for the
and
parameters shown for alignment of 25C and 30C spectra. Reference the main text for more details.
The 1 mM GB1 protein sample in 10%/90%
/H
O, 20 mM sodium phosphate, pH 7.0 was purchased from Giotto Biotech). We used the peak assignment from the Biological Magnetic Resonance Bank (entry 7280) [30, 31].
We acquired the spectra on a 600 MHz DirectDrive2 Agilent spectrometer equipped with a room-temperature HCN probe with XYZ gradients. We used the gNhsqc pulse sequence from Biopack (VnmrJ 4.2 software) and the following parameters for
H and
N dimensions, respectively: spectral width
, number of complex sampling points
, pulse width 8.125
s and 42.175
s. We processed spectra in nmrPipe [32] using zero-filling to
points, boxcar low-pass solvent filter, and 90
shifted sinebell apodization in both dimensions.
To reduce noise, negative intensities were discarded, and only peaks with intensities >10% of the maximum were retained. This threshold preserved between
and
of the original signal (Fig. S6).
Chain alignment for series of nuclear magnetic resonance spectra
Pairwise alignments were performed between consecutive spectra in the temperature series, with all spectra normalized prior to alignment. For each peak
in the first spectrum (Fig. 1), the principal match was defined as the peak
in the subsequent spectrum receiving the largest flow from
(Fig. 1). These maximal-flow correspondences were concatenated across the series to generate chain alignments from
through
.
Validation of WNetAlign on multidimensional nuclear magnetic resonance data
The proposed algorithm can be applied to NMR data of any dimensionality without the need for additional computations. However, to assess its quality, we require ground truth. For this reason, we introduce synthetic data, as described below.
2D
H-
N HSQC nuclear magnetic resonance dataset
To establish ground truth for evaluating the algorithm, we generated a series of synthetic spectra replicating the original GB1
H-
N HSQC spectra series using the procedure described in Section 2.2.1 of Supplementary materials. Moreover, to verify that performance results were not sample-dependent, the process of generating synthetic spectra was repeated 1000 times (Section 2.2.3 of Supplementary materials).
4D CCNOESY (aliphatic) spectrum
To test scalability, we applied the algorithm to the 4D CCNOESY (aliphatic) spectrum of the SH3 domain of growth arrest-specific protein 7 (GAS7) (PDB structure ID: 2LX7) published as part of the 100-protein NMR spectra dataset [33]. A corresponding replicate spectrum was generated by randomly shifting the signals of the original spectrum as described in Section 3 of the Supplementary materials.
Hypothetical 7D nuclear magnetic resonance spectra
To further demonstrate robustness in high dimensions, we utilized 7D HN-N-CO-CA-CB-HA-HB NMR peak lists of 17 proteins published by Romero et al. [34]. The proteins’ BMRB entry IDs are provided in Table S4. In practice, the hypothetical 7D spectra were derived from combinations of peaks from 2D–4D spectra as described in [34].
Peaks with missing chemical shifts in at least 1D were discarded, resulting in 17 spectra (S4) with amino acid distribution shown in Fig. S32. Since the hypothetical spectra were constructed from peak lists, they did not include signal intensities; thus, all peaks were assigned unit intensity.
Corresponding replicate spectra were generated for each protein by shifting signals of the original spectrum according to the methodology from Section 4 of the Supplementary materials.
Extended performance metrics for nuclear magnetic resonance alignment
To evaluate WNetAlign’s performance, we extended the definition of standard performance metrics to account for the peaks in each spectrum that were not matched. Each spectrum in the series of simulated 2D spectra has the same number of peaks in each cluster. The same is true for the 4D spectra. Similarly, for each 7D spectrum, the corresponding simulated 7D spectrum has the same number of peaks coming from the amino acid group.
Let us consider the matching between the peak from the first spectrum
and the peak from the second spectrum
as the classification problem, where the cluster membership of
is a true class and cluster membership of
is a predicted class. Thus, the alignment problem can be treated as a classification problem, and performance metrics such as accuracy, precision, and recall can be computed, as shown in Figs S13–S19. Since those metrics do not include the information about the peaks that were not matched, we define two auxiliary classes:
, which includes the number of unmatched peaks from the S1 spectrum divided by the classes they belong to, and
, which includes the unmatched peaks from the S2 spectrum divided by the class they belong to. Then we can extend the confusion matrix by adding a row corresponding to the
class and a column corresponding to the
class as seen in Fig. 3b.
Then, to validate the algorithm’s performance on 2D spectra and select
and
parameters for further analysis, we performed a grid search for the
and
ranging from 0.01 to 0.1 and computed the accuracy, precision, and recall metrics from the extended confusion matrices. For comparison purposes, we also computed standard performance metrics for the mentioned range of parameters.
Based on the grid search, we selected
and
, computed extended metrics for 1000 sets of synthetic spectra simulated for different random seeds. Selected parameters were also used for the chain alignment of real 2D
H-
N HSQC spectra of GB1 protein described in the previous section.
For the 4D dataset, extended metrics were calculated across
and
values ranging from 0.05 to 0.15, while for the 7D dataset, the range 0.03–0.13 was used.
To account for the larger chemical shift scale of
N dimension in 2D spectra and C1 and C2 dimensions in 4D spectra, we scaled them by the factor 0.1. In all cases, spectra were normalized before alignment.
Results and discussion
Comparison with existing alignment tools on the breast cancer data
To evaluate the performance of the WNetAlign algorithm, we conducted 1540 alignments, corresponding to all possible pairwise comparisons within the PXD000484 dataset. The parameters used in all alignments were max_mz_shift = 0.005 and max_rt_shift = 800. Parameter selection was performed via grid search using a representative subset of the spectra pairs. Full details of the grid search procedure are provided in Section 1.2 of the Supplementary materials.
It should be noted that (like other alignment algorithms) the performance of WNetAlign depends on the choice of max_mz_shift and max_rt_shift parameters. However, there is a wide range of settings in which it performs reasonably. For a more detailed sensitivity analysis, see Supplementary Material.
The input to the algorithm consisted of two lists of detected features in centroided mode, where each feature is represented by a single point corresponding to the entire isotopic envelope associated with a specific peptide. Feature detection was performed using the OpenMS FeatureFinderCentroided tool.
We compared the WNetAlign algorithm with two other existing alignment tools: the recently developed DeepRTAlign [35] and the widely used OpenMS alignment tool [12].
The WNetAlign algorithm demonstrated strong performance, achieving an average precision of 0.97 and an average recall of 0.96 across all alignments. In contrast, one of the most widely used alignment tools, OpenMS, performed notably worse, with a precision of 0.89 and a recall of 0.74. The average alignment time for WNetAlign was 0.6 s. OpenMS required an average of 29 s per alignment, while DeepRTAlign required substantially longer, with an average runtime above 2 h per alignment.
The aligned dataset consists of two batches: MT and TDM, with each batch containing samples processed by a different operator. When aligning spectra from different batches, OpenMS exhibited poor performance, achieving a recall of <0.3. DeepRTAlign performed substantially better than OpenMS in this setting, but it still remained below the performance of WNetAlign, especially in terms of recall (see Table 1). Although the WNetAlign algorithm also showed reduced performance in this challenging scenario, it consistently maintained precision and recall values >0.8, demonstrating its robustness to large RT shifts introduced by operator variability. The extended analysis of this behavior is provided in Section 1.4 of the Supplementary Materials.
Table 1.
Mean performance metrics of different alignment methods
| Method | Recall | Precision | Runtime |
|---|---|---|---|
| WNetAlign | 0.96 | 0.97 | 0.6 s |
| DeepRTAligna | 0.90 | 0.95 | 2 h 20 min 23 s |
| OpenMS | 0.74 | 0.89 | 29 s |
aDue to high computation time, DeepRTAlign was evaluated only on 70 random spectra pairs from all possible pairwise comparisons. Each spectrum from the dataset was aligned at least once.
Figure 2c presents two examples of WNetAlign alignments. In each example, lines connect matched features between spectra: blue lines indicate true positive matches, while red lines represent false positive matches. The length of each line corresponds to the RT shift between matched features. Figure 2c1 illustrates an MT–MT alignment, where both spectra originate from the MT batch, whereas Fig. 2c2 depicts an alignment between an MT spectrum and a TDM spectrum. RT shifts between MT and TDM spectra are substantially larger, which likely contributes to the poor performance of OpenMS in these cross-batch alignments.
In summary, WNetAlign outperformed both the novel, deep learning-based RT alignment tool DeepRTAlign, as well as the widely used OpenMS alignment tool in terms of accuracy, robustness, and processing speed.
Application to multidimensional NMR data
We demonstrated that the WNetAlign algorithm can be applied to align the temperature series of GB1 spectra, allowing for the computation of temperature-dependent shifts in each dimension as shown in Supplementary Fig. S7. These distances provide a quantitative basis for estimating the effect of temperature on the variance of chemical shifts.
To assess performance, we next validated the algorithm on the ground truth constructed by simulating temperature series designed to mimic the GB1 data. WNetAlign correctly matched signals from the corresponding neighborhoods, reaching maximum accuracy between 0.87 and 0.92, precision between 0.91 and 0.94, and recall between 0.93 and 0.95. Moreover, once parameter values exceeded the average distance between peaks in one spectrum and their counterparts in replicate spectra, extended metrics stabilized, plateauing for
and
(Fig. 3d). This average inter-replicate distance arises directly from the simulation design, where spectra were generated by shifting peak positions relative to one another in a controlled manner.
Analysis of the impact of the
parameter on classification results revealed that lower values reduce accuracy, precision, and recall primarily due to unmatched peaks rather than misclassifications (Figs S25–S29). This indicates that the algorithm favors conservative matching over incorrect alignments, further supporting its robustness.
The
is data specific since it represents the expected maximum distance between the shifts of signals corresponding to the same type of functional group/nuclide in the specific experiment. However, our analysis shows that the rough estimate of the expected maximum distance between signals in replicate samples should be sufficient lower bound for the sensible
.
We proved that the obtained validation results were not sample-dependent by repeated validation across 1000 independently simulated temperature series datasets. Performance metrics remained highly stable across the simulations, with standard deviations of 0.029, 0.02, and 0.013 for accuracy, precision, and recall, respectively (Figs S20–S24; Table S3).
The proposed algorithm scales effectively to higher-dimensional data. For the 4D CCNOESY spectrum, accuracy reached 0.87, while precision and recall increased with parameter values, reaching 0.96 and 0.97, respectively (Fig. S31). On the 7D dataset, performance metrics increased steadily with both
and
, plateauing near 0.1 and reaching 0.92–0.95 for precision and recall and 0.96–1.0 for accuracy (Figs S33–S49).
Together, these results highlight WNetAlign as a robust, scalable, and interpretable framework for aligning multidimensional NMR spectra. By reducing the influence of instrumental drift and environmental variability, the method improves the comparability of replicate measurements and enhances the utility of high-dimensional NMR for comparative analysis, automated quantification, and structure elucidation. Beyond structural biology, WNetAlign is particularly relevant in metabolomics, where peak shifts across samples complicate statistical comparisons and obscure biomarker discovery, and in medical diagnostics, where reliable alignment of spectra from patient samples acquired under heterogeneous conditions is essential for identifying disease-associated signatures. By enabling accurate and automated alignment across diverse experimental conditions, WNetAlign provides a foundation for broader integration of multidimensional NMR into both fundamental and translational research.
Runtime scaling on large datasets
To study the algorithm’s runtime performance on large datasets, we constructed a partially artificial dataset. For each
, we created an artificial pair of spectra from the PXD000484 dataset, repeating each spectrum
times. Each repetition was shifted along the m/z axis to avoid overlap, resulting in datasets containing between 159 422 and 40 million features across the two aligned spectra. The dataset was generated so as to preserve the character of the original data, allowing us to study the effect of data size in isolation from other factors, such as varying peak density between different datasets. The results are presented in Fig. 4.
Figure 4.

Runtime and RAM usage comparison across various input dataset sizes. The irregular behavior of RAM usage curve is due to various STL and Python data structures adjusting their overallocation strategies based on data size.
The algorithm exhibits approximately linear scaling with respect to input dataset size. In theory, the complexity is at least
, although the logarithmic factor is too small to be visible in the plots. The runtime performance remains satisfactory, reaching 12 s even for the largest dataset tested.
Conclusions
The study demonstrates that the proposed algorithm effectively aligns multidimensional spectra from LC–MS and NMR, minimizing errors caused by RT or frequency shifts. It employs a truncated Wasserstein distance and formulates alignment as a minimum-cost flow problem solved with the Network Simplex algorithm. Constraining the maximum transport distance accelerates computation, reduces false matches, and improves robustness to noise. The algorithm is suitable for comparative analyses, replicate experiments, and studies where signal shifts are intentionally introduced, such as variable-temperature NMR. Its scalability makes it applicable to large proteomics, metabolomics, and structural biology projects. Combining LC–MS and NMR with precise spectral alignment enhances the reliability of compound identification, quantification, and structural analysis.
Last but not least, the proposed algorithm can be utilized not only as an efficient method for aligning multidimensional spectra but also for efficiently estimating the high-dimensional Wasserstein distance, which has potential applications in areas such as generative modeling and flow matching techniques.
Key Points
WNetAlign introduces a fast and robust spectra alignment framework based on truncated Wasserstein distance formulated as a minimum-cost flow problem.
By constraining transport distance and using the Network Simplex algorithm, the method improves alignment accuracy while substantially reducing computational cost.
WNetAlign outperforms widely used tools on benchmark LC–MS proteomics data and remains robust to large retention time shifts.
The same framework naturally extends to multidimensional NMR data (2D–7D), enabling reliable alignment and peak tracking in high-dimensional bioinformatics applications.
Supplementary Material
Contributor Information
Justyna Król, Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Banacha 2, 02-097 Warsaw, Poland.
Maria Bochenek, Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Banacha 2, 02-097 Warsaw, Poland.
Sylwia Jopa, Centre of New Technologies, University of Warsaw, Banacha 2C, 02-097 Warsaw, Poland.
Krzysztof Kazimierczuk, Centre of New Technologies, University of Warsaw, Banacha 2C, 02-097 Warsaw, Poland.
Anna Gambin, Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Banacha 2, 02-097 Warsaw, Poland.
Michał Piotr Startek, Faculty of Mathematics, Informatics and Mechanics, University of Warsaw, Banacha 2, 02-097 Warsaw, Poland.
Conflicts of interest
None declared.
Funding
The work was supported by the National Science Centre, Poland, project 2024/53/B/ST6/03852.
Data availability
Most of the article is based on reanalysis of publicly available datasets, see text for details. The novel NMR dataset has been uploaded to https://doi.org/10.5281/zenodo.17226285.
References
- 1. Smith R, Ventura D, Prince JT. LC–MS alignment in theory and practice: a comprehensive algorithmic review. Brief Bioinform 2015; 16:104–17. [DOI] [PubMed] [Google Scholar]
- 2. Lange E, Tautenhahn R, Neumann S et al. Critical assessment of alignment procedures for LC–MS proteomics and metabolomics measurements. BMC Bioinformatics 2008; 9:375. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3. Jane Dyson H, Rance M, Houghten RA et al. Folding of immunogenic peptide fragments of proteins in water solution. I. Sequence requirements for the formation of a reverse turn. J Mol Biol 1988; 201:161–200. [DOI] [PubMed] [Google Scholar]
- 4. Jane Dyson H, Rance M, Houghten RA et al. Folding of immunogenic peptide fragments of proteins in water solution. II. The nascent helix. J Mol Biol 1988; 201:201–17. [DOI] [PubMed] [Google Scholar]
-
5.
Okazaki H, Matsuo N, Tenno T et al. Using
H
amide temperature coefficients to define intrinsically disordered regions: an alternative NMR method. Protein Sci 2018; 27:1821–30.
[DOI] [PMC free article] [PubMed] [Google Scholar] - 6. Baxter NJ, Hosszu LLP, Waltho JP et al. Characterisation of low free-energy excited states of folded proteins. J Mol Biol 1998; 284:1625–39. [DOI] [PubMed] [Google Scholar]
- 7. Shchukina A, Małecki P, Mateos B et al. Temperature as an extra dimension in multidimensional protein NMR spectroscopy. Chem Eur J 2021; 27:1753–67. [DOI] [PubMed] [Google Scholar]
- 8. Trainor K, Palumbo JA, MacKenzie DWS et al. Temperature dependence of NMR chemical shifts: tracking and statistical analysis. Protein Sci 2020; 29:306–14. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9. Ciach M, Miasojedow B, Skoraczynski G et al. Masserstein: linear regression of mass spectra by optimal transport. Rapid Commun Mass Spectrom 2025;39;e8956. [DOI] [PubMed] [Google Scholar]
- 10. Skoraczyński G, Gambin A, Miasojedow B. Alignstein: optimal transport for improved LC–MS retention time alignment. GigaScience 2022; 11:giac101. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11. Sturm M, Bertsch A, Gröpl C et al. Openms – an open-source software framework for mass spectrometry. BMC Bioinformatics 2008; 9:163. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12. Lange E, Gröpl C, Schulz-Trieglaff O et al. A geometric approach for the alignment of liquid chromatography-mass spectrometry data. Bioinformatics. 2007; 23:i273–81. [DOI] [PubMed] [Google Scholar]
- 13. Bellew M, Coram M, Fitzgibbon M et al. A suite of algorithms for the comprehensive analysis of complex protein mixtures using high-resolution LC-MS. Bioinformatics 2006; 22:1902–9. [DOI] [PubMed] [Google Scholar]
- 14. Li XJ, Yi EC, Kemp CJ et al. A software suite for the generation and comparison of peptide arrays from sets of data collected by liquid chromatography-mass spectrometry. Mol Cell Proteomics 2005; 4:1328–40. [DOI] [PubMed] [Google Scholar]
- 15. Zhang X, Asara J, Adamec J et al. Data pre-processing in liquid chromatography-mass spectrometry-based proteomics. Bioinformatics 2005; 21:4054–9. [DOI] [PubMed] [Google Scholar]
- 16. Smith C, Want E, O’Maille G et al. XCMS: processing mass spectrometry data for metabolite profiling using nonlinear peak alignment, matching, and identification. Anal Chem 2006; 78:779–87. [DOI] [PubMed] [Google Scholar]
- 17. Katajamaa M, Miettinen J, Oresic M. MZmine: toolbox for processing and visualization of mass spectrometry based molecular profile data. Bioinformatics 2006; 22:634–6. [DOI] [PubMed] [Google Scholar]
- 18. Savorani F, Tomasi G, Engelsen SB. icoshift: a versatile tool for the rapid alignment of 1D NMR spectra. J Magn Reson 2010; 202:190–202. [DOI] [PubMed] [Google Scholar]
- 19. Thuy-Nga V, Valkenborg D, Smets K et al. An integrated workflow for robust alignment and simplified quantitative analysis of NMR spectrometry data. BMC Bioinformatics 2011; 12:405. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20. Beirnaert C, Meysman P, Thuy-Nga V et al. speaq 2.0: a complete workflow for high-throughput 1D NMR spectra processing and quantification. PLoS Comput Biol 2018; 14:e1006018. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21. Zhou J, Zhang M, Wang Y et al. Global intensity-guided peak matching and alignment for 2D HSQC spectra in metabolomics. Anal Chem 2023; 95:2331–40. [DOI] [PubMed] [Google Scholar]
- 22. Domżał B, Nawrocka E, Gołowicz D et al. Magnetstein: an open-source tool for quantitative NMR mixture analysis robust to low resolution, distorted lineshapes, and peak shifts. Anal Chem 2024; 96:188––96.. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23. Ambrosio L, Gigli N. A User’s Guide to Optimal Transport. Berlin Heidelberg: Springer, 2013, 1–155. [Google Scholar]
- 24. Peyré G, Cuturi M. Computational optimal transport: with applications to data science. Found Trends Mach Learn 2019; 11:355–607. [Google Scholar]
- 25. Lücken L, Mitschke N, Dittmar T et al. Network flow methods for NMR-based compound identification. Anal Chem 2025; 97:4832–40. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 26. Ahuja RK, Magnanti TL, Orlin JB. Network Flows: Theory, Algorithms and Applications. Hoboken, NJ, USA: Prentice Hall, 1994. [Google Scholar]
- 27. Dezső B, Jüttner A, Kovács P. Lemon – An open source C++ graph template library. Electronic Notes in Theoretical Computer Science 2011; 264:23–45. [Google Scholar]
- 28. Orlin J. A faster strongly polynomial minimum cost flow algorithm. In: Proceedings of the Twentieth annual ACM symposium on Theory of Computing, organized by ACM SIGACT (Association for Computing Machinery, Special Interest Group on Algorithms and Computation Theory), Chicago, Illinois, USA, pp. 377–87, 1988.
- 29. De Marchi T, Liu NQ, Stingl C et al. 4-protein signature predicting tamoxifen treatment outcome in recurrent breast cancer. Mol Oncol 2016; 10:24–39. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 30. Hoch JC, Baskaran K, Burr H et al. Biological magnetic resonance data bank. Nucleic Acids Res 2022; 51:D368–76. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 31. Wilton DJ, Tunnicliffe RB, Kamatari YO et al. Pressure-induced changes in the solution structure of the GB1 domain of protein G. Proteins: Struct Funct Bioinf 2008; 71:1432–40. [DOI] [PubMed] [Google Scholar]
- 32. Delaglio F, Grzesiek S, Vuister GW et al. NMRPipe: a multidimensional spectral processing system based on UNIX pipes. J Biomol NMR 1995; 6:277––93.. [DOI] [PubMed] [Google Scholar]
- 33. Klukowski P, Damberger FF, Allain FH-T et al. The 100-protein NMR spectra dataset: a resource for biomolecular NMR data analysis. Sci Data 2024; 11:30. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 34. Romero JA, Putko P, Urbańczyk M et al. Linear discriminant analysis reveals hidden patterns in NMR chemical shifts of intrinsically disordered proteins. PLoS Comput Biol 2022; 18:e1010258. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 35. Liu Y, Yang Y, Chen W et al. DeepRTAlign: toward accurate retention time alignment for large cohort mass spectrometry data analysis. Nat Commun 2023; 14:8188. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
Most of the article is based on reanalysis of publicly available datasets, see text for details. The novel NMR dataset has been uploaded to https://doi.org/10.5281/zenodo.17226285.




