Skip to contents

logconNMF() estimates which compounds occur in a batch of chromatograms, their common mass spectra and a separate elution profile and area for each occurrence. In the 16-sample benchmark it recovered the true rank of 1,000 from 88 million ion measurements, with 8,000 true positives and zero false positives. Fitting took 29.03 seconds per sample on a 64 GB laptop with 16 logical processors. The peak working set of the process tree, sampled every half second, was 6.77 GiB. Stage times · Timing and peak memory

Fitting shared spectra on the original scan grids

For sample s, the expected signal at unit exposure and zero offset is \mu_s = B_s A_s + Q_s P . The rows of P are unit-sum mass spectra shared across samples. Column k of Q_s is the total-ion elution profile of compound k in sample s, with area, width and tail specific to that injection. The column is zero when the compound is absent. B_s A_s models the smooth, ion-specific background. Sharing P makes this a simultaneous NMF. Badea · Cichocki et al. · Lee et al.

Monotone alignment maps account for retention drift. The fit evaluates the model at the observed scan times in each injection, with the change in bin width preserving integrated peak area. Each positive profile has contiguous support and nonincreasing log slopes. Its area is reported as NA for an undetected occurrence.

Known exposure can be supplied as a scalar or as a vector over scans for each sample. Exposure multiplies the mean and an identity-link offset adds known signal. Unit exposure preserves the units of the input data. Supported families are Gaussian, Poisson, quasi-Poisson, negative binomial (NB1 and NB2), censored Gamma and common-scale Gamma. Noise parameters are shared across channels within each sample. A positive dispersion or theta fixes the corresponding parameter. For NB2, a negative theta starts at its absolute value and allows bounded likelihood-improving updates.

The initial sample regressions share a core budget, with control = list(workers = 4L) setting an explicit worker cap. The joint count fit stores observations and fitted means on disk. OpenMP parallelises local profile updates across samples and shared spectrum updates across blocks of ions. The other identity-link families can also read the original channels in blocks. Keep the fitted store alongside a saved fit. Model, likelihoods and updates

Automatic rank recovery on full chromatograms

We simulated 16 full chromatograms of 10,000 scans × 550 ion channels (m/z 30–579), about 50 minutes per injection. Each of the 1,000 compounds occurred in eight randomly chosen samples, giving 8,000 peaks in total. Of these compounds, 990 had exponentially modified Gaussian (EMG) peaks and ten had shark-fin acid peaks. Both broadened with increasing concentration. The simulation included overdispersed counts, a smooth background, up to 2.93 seconds of retention drift and about 2% variation in scan spacing.

GNPS/MSHub estimated 1,414 shared components, 41.4% above the generating rank. The other five workflows report per-sample peaks or aligned feature groups. A dash indicates that the workflow reports no common factorisation rank.

Workflow Seconds/sample Estimated rank (true 1,000) TP (sensitivity) FP FN Acid TP / 80 Median absolute area error, % [P25, P75]
GCMSprime 29.03 1,000 (exact) 8,000 (100%) 0 0 80 / 80 0.095 [0.041, 0.197]
MS-DIAL 16.02 — 7,728 (96.6%) 11,685 272 73 / 80 13.94 [5.86, 26.39]
mzmine GC-EI 6.92 — 4,202 (52.5%) 185 3,798 29 / 80 6.41 [2.51, 14.23]
eRah 25.94 — 7,172 (89.7%) 5,615 828 70 / 80 12.03 [5.62, 25.70]
AMDIS 28.99 — 7,878 (98.5%) 9,122 122 80 / 80 20.74 [14.34, 33.82]
xcms + CAMERA 4.22 — 7,261 (90.8%) 890 739 31 / 80 29.70 [23.15, 38.41]
MSHub 15.05 1,414 7,179 (89.7%) 12,184 821 50 / 80 15.42 [5.96, 35.47]

For each correctly matched peak we calculated the absolute difference between estimated and true area as a percentage of its true area. Brackets give the 25th and 75th percentiles across those peaks.

All seven workflows received the same CDFs. The time for each is one full run divided by 16, including required input conversion and native analysis. For GCMSprime this included PSF calibration and results export. Simulation and accuracy scoring ran separately.

We calibrated the PSF against a separately generated 20-peak standard, grouped the ions into 32 channels for initial screening and allowed up to eight parallel sample initialisations. The benchmark enabled local rank search with batch = list(workers = 8L, coupling = list(penalty_search = TRUE)). The blind fit used the observed data throughout. Its final original-ion GIC was 32,610,830.

Here the shared rank counts distinct compounds across injections. At a detection height of 1% of each peak’s own apex, the median number of co-eluting peaks per scan was one, the 95th percentile was three and the maximum was five. The fitted model separates compounds by their elution times as well as their spectra. The unrestricted nonnegative rank of the stacked scan-by-ion matrix is at most 550, its number of ion columns.

Across all 8,000 matched peaks the median elution-profile cosine was 0.999994, the median absolute peak area error was 0.095% [0.041%, 0.197%], and the ordinary adjusted R² for log₁₀ peak area was 0.999982.

To compare whole elution profiles, we chose the EMG compound and the acid with the largest total simulated area in their respective classes before examining any fit. Solid curves show fitted profiles and dashed curves the simulated profiles, in total-ion intensity per scan. Colours run from low to high simulated area. Each compound occurred in eight samples and had zero true intensity in the other eight. The mean profile cosine includes all eight positive occurrences, with a missed peak scoring zero.

EMG and shark-fin acid profiles in all 16 samples

Seven-workflow comparison and reproduction code.

Convergence behaviour

On the 16 chromatograms the blind fit showed smooth, monotonic descent in the original-ion GIC over eight sweeps. Its final GIC differed by only 0.19% from that of a second fit started at the true elution profiles and compound identities and run for the same eight sweeps. Both fits estimated spectra, areas, elution profiles and background from the observed counts.

Original-ion GIC over eight sweeps of the blind fit on 16 full chromatograms

The curve joins 29 recorded updates. Several can occur within the same sweep as the active factors change. The percentage gap is the absolute difference in final GIC divided by the magnitude of the truth-initialised fit’s GIC. It is an empirical comparison of two attainable solutions.

Block-level GIC trace · Final GIC values.

Earlier attempts at automatic NMF or NTF best rank recovery

logconNMF estimates the rank from the ion data in two stages. First, L0glm regresses each chromatogram on shifted copies of the time-varying PSF. It selects peak positions jointly across ions with a grouped L₀ penalty, solving a sequence of convex, adaptively weighted ridge subproblems. After alignment, logconNMF alternates updates of the shared spectra and the sample-specific log-concave profiles. Its active-set search can drop a weak component, add a residual-supported candidate or fuse overlapping neighbours. A change is accepted only if it lowers the generalised information criterion (GIC) on the original ion channels. Each shared spectrum incurs a charge for its free positive ion proportions and each positive profile for the dimension of its fitted log-concave shape, including scale. The background spline basis is fixed. Rank-selection objective

Among the published tests of conventional NMF on noisy simulated data that we reviewed, the largest rank recovered exactly was 150, which Squires et al. selected by minimum description length on a 1,000 × 2,000 matrix. Squires et al., Figs. 1–2

In chromatographic applications of MCR-ALS, PARAFAC and PARAFAC2, analysts typically specify candidate ranks and inspect the fitted spectra, elution profiles and residuals. A common practice is to divide the chromatogram into windows containing roughly one to ten components. Bro & Kiers · Johnsen et al. · van Stokkum et al.

We found no earlier published demonstration of a simultaneous chromatographic factorisation that selected 1,000 distinct compounds and verified their identities across all 8,000 occurrences. For example, the PARAFAC2-based GC–MS workflow PARADISe fits one retention window at a time. By default it evaluates models with one to eight components per window, including any components used for the baseline. The user can raise that upper limit. The rank of 1,000 recovered across the full batch is 125 times the default upper rank for a single PARADISe window. Johnsen et al. · PARADISe protocol, §12.1

Multiset MCR and tensor fits on the same chromatographic window

How much does a compound gain from sharing its spectrum across injections? We cut scans 2,445–2,594 from each of the 16 full benchmark chromatograms around the first shark-fin acid (compound 250). These 150 scans include 550 ions, 15 distinct compounds with an apex in the window and 120 occurrences, plus tails from neighbouring compounds. Sample 002 is the first injection containing the acid. Eight compounds have their apex inside its window. The simulation determined which window to study. Rank estimation and data-only initialisation used only the observed counts in the selected injections.

In chemometric terminology, the shared-spectrum fit is a form of multiset multivariate curve resolution. It estimates a separate elution profile on each sample’s scan grid and a common mass spectrum per compound. Historical names for this approach to resolving mixtures include self-modelling curve resolution (SMCR) and self-modelling mixture analysis (SMMA). The fit here uses log-concave profiles, allows retention-time drift and selects compounds, sample occurrences and spectral ions by GIC. These simulated counts use quasi-Poisson noise. Camp · Lawton & Sylvestre

CANDECOMP (canonical decomposition) and PARAFAC (parallel factor analysis) are two names for the same tensor decomposition, usually abbreviated CP. Each compound contributes one time profile, one spectrum and an injection-specific amplitude. Flexible PARAFAC2 allows sample-specific profiles and penalises deviations from a common profile matrix after orthogonal transformation. Cohen & Bro · Kolda & Bader

The R ALS package takes starting concentrations. Its data-only runs here used NNDSVD and the package’s spectra-first update and stopping tolerance. The original MATLAB toolbox gives the analyst SVD and EFA diagnostics for choosing the rank. Its data-only runs used the authors’ pure-variable initialisation. Both MCR solvers used nonnegativity and per-injection unimodality. For a reproducible automatic comparison we applied the same permutation rule to both. We permuted scan order independently within each sample and ion 19 times and retained consecutive singular values above their pointwise 95th-percentile null values. We compared the covariance and correlation versions. Channel standardisation affects only this rank diagnostic. R ALS manual · MCR-ALS 2.0 toolbox

Sample 002 on its own

Rank and start Solver Rank Interior TP Real tails Unassigned (FP) Median absolute area error, % [P25, P75] Range, % Acid area / truth Seconds
Automatic, calibrated PSF GCMSprime 8 8/8 0 0 1.73 [1.19, 2.82] 0.193–9.66 98.34% —
Covariance, data-only R ALS 4 4/8 0 0 32.79 [25.38, 71.93] 4.89–187.58 0.00% 0.33
Covariance, data-only MCR-ALS 2.0 4 4/8 0 0 19.78 [7.63, 60.07] 3.72–148.43 0.00% 31.45
Correlation, data-only R ALS 7 6/8 0 1 29.11 [11.15, 30.99] 4.06–147.76 0.00% 0.50
Correlation, data-only MCR-ALS 2.0 7 7/8 0 0 4.09 [1.99, 13.80] 0.702–30.54 0.00% 31.92
Interior count supplied, data-only R ALS 8 7/8 0 1 30.22 [15.14, 32.20] 1.86–136.96 66.61% 0.14
Interior count supplied, data-only MCR-ALS 2.0 8 8/8 0 0 7.14 [2.64, 9.20] 0.920–110.77 210.77% 27.05

Area errors are percentages of the true area for the correctly detected interior peaks in the TP column. Brackets give the 25th and 75th percentiles. The range gives the smallest and largest errors. Real tails come from identified compounds with an apex outside the window. The single-sample GCMSprime run overlapped a website build, so its time is omitted.

The pure-variable MCR-ALS fit identified all eight compounds when given the interior count. It assigned 211% of the true acid area to the acid factor, with a second contribution on its leading edge. Neither automatic rank diagnostic recovered the acid in this single injection.

With the interior rank supplied and data-only starts, R ALS recovered seven of the eight peaks in sample 002 with a median absolute area error of 30.22% [15.14%, 32.20%]. MCR-ALS 2.0 recovered all eight with 7.14% [2.64%, 9.20%]. GCMSprime selected rank eight automatically, recovered all eight with zero unassigned calls, and gave 1.73% [1.19%, 2.82%] median absolute area error and 98.34% acid area recovery.

All 16 samples fitted together

Rank and start Solver Rank Interior TP Real tails Unassigned (FP) Median absolute area error, % [P25, P75] Range, % Acid area / truth Seconds
Automatic, calibrated PSF GCMSprime 19 120/120 21 0 0.160 [0.078, 0.408] 0.0013–2.11 99.74% 331.73
Covariance, data-only R ALS 6 48/120 0 45 24.43 [7.06, 69.56] 0.529–571.78 0.00% 13.09
Covariance, data-only MCR-ALS 2.0 6 48/120 0 45 21.71 [14.19, 44.85] 0.315–399.49 0.00% 36.56
Correlation, data-only R ALS 16 120/120 11 57 2.68 [0.812, 4.89] 0.035–34.78 101.62% 80.98
Correlation, data-only MCR-ALS 2.0 16 120/120 5 16 2.03 [1.18, 4.27] 0.118–16.04 101.95% 89.55
Interior count supplied, data-only R ALS 15 120/120 7 49 2.40 [1.10, 5.41] 0.039–35.35 102.88% 59.95
Interior count supplied, data-only MCR-ALS 2.0 15 120/120 4 13 1.99 [1.09, 3.82] 0.023–16.10 102.57% 84.91

Standardising ion variances before rank selection changed the estimated count from 6 to 16. Both MCR implementations then recovered all 120 interior occurrences. R ALS also called 57 occurrences without a corresponding interior compound or identifiable tail. For the MATLAB toolbox this count was 16. With the interior rank of 15 supplied, their median absolute area errors were 2.40% [1.10%, 5.41%] for R ALS and 1.99% [1.09%, 3.82%] for MCR-ALS. Some factors can account for genuine signal from beyond either window boundary.

For comparison, the calibrated GCMSprime fit selected 19 factors, recovered 120/120 interior occurrences and assigned its 21 additional calls to identifiable tails, leaving zero unassigned calls. Median absolute area error was 0.160% [0.078%, 0.408%] across all 120 interior occurrences, and median acid area recovery across the eight positive injections was 99.74%. Scoring just the same eight peaks in sample 002 gives 0.636% area error in the joint fit, compared with 1.73% when that injection was analysed alone. With data-only starting factors and the interior count supplied, the corresponding joint-fit errors for those same eight peaks were 4.09% for R ALS and 1.738% for MCR-ALS 2.0. The latter matches the accuracy of the automatic single-sample GCMSprime fit on this window. Reading the window CDFs, estimating the dictionary, fitting and exporting the batch took 331.73 s, with another 5.63 s to calibrate the independent PSF standard. Reference fits, settings and timing scopes

Fitted and true shark-fin profiles for the same injection, analysed alone and jointly using data-only starts and the supplied interior ranks.
Fitted and true shark-fin profiles for the same injection, analysed alone and jointly using data-only starts and the supplied interior ranks.

Both panels show the same acid in sample 002. Sharing the spectra across injections changed the recovered area from 66.61% to 110.33% for R ALS and from 210.77% to 102.40% for MCR-ALS 2.0. The tables summarise the acid ratio across the positive injections in each fit. We matched shared spectra to interior identities one-to-one at cosine ≥0.70, then called an occurrence above 1% of that factor’s largest area across the selected injections. In the single sample this includes each positive factor. An extra call counted as a real tail if both its spectral and temporal cosines reached 0.70 against a distinct outside-window compound contributing at least one count. Area accuracy is scored on true-positive interior occurrences. Acid area recovery is scored across all injections in which the acid was present. Timings are single serial measurements on the benchmark laptop (R 4.5.0, ALS 0.0.7, MATLAB R2025b, four MATLAB computational threads). They include rank diagnostics for automatic runs and process startup for MATLAB. Per-occurrence results and solver-only timings

Solver controls using GCMSprime initialisation

How much does the choice of starting spectrum and background affect the subsequent fit? For this control, GCMSprime supplied the starting factors. For sample 002 it used an independently measured PSF standard and the observed counts of that injection alone. Its grouped PSF fit (splogconNMF) produced eight candidate spectra, their elution profiles and an estimated background. All eight spectra were passed to the MCR methods. For the batch, GCMSprime constructed 27 cross-sample candidates before shared-factor refinement. We supplied 19 to each solver, choosing successively by total area times the squared length of the unit spectrum after projection away from the spectra already chosen. Simulated spectra and true areas were used only for scoring.

Each solver fitted the observed counts after subtracting the GCMSprime background. R ALS used the prepared spectra and profiles and updated profiles first. MCR-ALS 2.0 started from the prepared spectra. The tensor controls used the spectra and profiles to initialise their factors. The times below start with the prepared factors. Constructing them took 219.76 s for sample 002 and 283.99 s for the batch in the instrumented run, with the PSF standard already calibrated.

Data passed to GCMSprime Refinement solver Rank supplied Interior TP Real tails Unassigned (FP) Median absolute area error, % [P25, P75] Range, % Acid area / truth Refinement (s)
Sample 002 R ALS 8 8/8 0 0 1.91 [0.244, 3.50] 0.080–8.55 104.69% 0.06
Sample 002 MCR-ALS 2.0 8 8/8 0 0 0.440 [0.166, 1.66] 0.110–8.80 100.52% 23.72
16 samples R ALS 19 120/120 22 34 1.36 [0.633, 2.72] 0.016–18.29 98.35% 8.12
16 samples MCR-ALS 2.0 19 120/120 20 15 1.21 [0.711, 2.68] 0.020–56.27 96.94% 54.08
16 samples CP 19 115/120 5 29 8.62 [4.40, 17.08] 0.157–93.76 74.40% 4.50
16 samples Flexible PARAFAC2 19 111/120 5 56 17.63 [7.98, 28.41] 0.565–94.35 76.07% 12.59

In sample 002, GCMSprime followed by MCR-ALS recovered all eight compounds with 0.44% median absolute area error and 100.52% acid area recovery. The corresponding figures for MCR-ALS started from its own pure-variable estimates at the same rank were 7.14% and 210.77%. The control measures how well each solver refines an already resolved set of spectra, given the GCMSprime background and component count. The raw-data results above measure performance with each method’s data-only initialisation.

Covering a full chromatogram

A 10,000-scan chromatogram takes 133 windows of 150 scans at a stride of 75, placing the last window flush with the chromatogram end. At the measured data-only, supplied-rank rates, fitting one injection at rank eight would take 19 s with R ALS or 60 min with MCR-ALS 2.0. Fitting the entire 16-injection batch jointly at rank 15 would take 2.21 h or 3.14 h, respectively. These are serial projections from one acid-containing window. They exclude window reconciliation and assume the same rank, overlap and convergence time in every window. The MATLAB projection includes a fresh process per window. Using just its measured pure-variable initialisation and numerical solve gives 18 min for one injection and 2.44 h for the joint batch before I/O and stitching.

We also timed a complete 10,000 × 550 chromatogram (sample 002) directly. With rank 100 and the spectrum of the brightest scan in each of 100 equal scan intervals as a start, both R ALS and MCR-ALS 2.0 exceeded a 60-second fitting deadline on this machine. The clock began with the observed matrix and starting spectra already in memory. The MATLAB measurement includes startup. Deadline results and reproducible test

There is a separate algebraic limit to rank selection by SVD. Stacking 16 chromatograms gives a 160,000 × 550 matrix with at most 550 singular directions. Tauler’s toolbox uses the requested number of columns of the economy SVD in its PCA reproduction step. Asking its original pcarep for rank 1,000 on a 600 × 550 matrix failed when the requested index range exceeded 550. The same dimension bound holds on the full stack. Local elution support and cross-sample matching can distinguish 1,000 chemical identities even when the augmented matrix has at most 550 independent spectral directions. This bound applies specifically to an SVD-derived count and to this toolbox PCA step. It places no universal ceiling of 550 on a structured, overcomplete factorisation. Recorded toolbox diagnostic

Reproduce the window comparisons in R

remotes::install_github("tomwenseleers/logconNMF", subdir = "NMFbenchmarks",
                        dependencies = TRUE)
library(NMFbenchmarks)
one <- benchmarkNMFWindow(2,    "ALS", rank = "parallel_cor", unimodal = TRUE)
joint <- benchmarkNMFWindow(1:16, "ALS", rank = "parallel_cor", unimodal = TRUE)
one$summary
joint$summary

installNMFtoolbox("MCR-ALS")  # once, with MATLAB installed
benchmarkNMFWindow(2, "MCR-ALS", rank = 8, unimodal = TRUE)$summary

To use the authors’ SVD or EFA workflow interactively, export the observed matrices with writeMCRProject() and open the generated script in MATLAB. The companion package also includes the original flexible PARAFAC2 adapter, the nonnegative CP control, supplied PSF starts and scripts for the full comparison. GCMSbenchmark accepts all four methods for user-supplied ANDI-MS files. NMFbenchmarks · GCMSbenchmark

Reproduce and inspect the 16-sample fit

The GCMSbenchmark scripts generate the same 16 CDF files and a separate calibration standard. The standard run estimates rank blind. The optional diagnostic reuses those files and fits both starts.

bench <- system.file("benchmarks", package = "GCMSbenchmark", mustWork = TRUE)
source(file.path(bench, "simulated-16.R"))
directory <- "full-chromatograms"
prepareFullBenchmark(directory)
fitFullBenchmark(directory, "GCMSprime", ncores = 16L)
fit <- readRDS(file.path(directory, "runs", "GCMSprime", "native.rds"))$result$coupled
fit$rank

source(file.path(bench, "full-gic.R"))
gap <- runFullBenchmarkGIC(directory, file.path(directory, "diagnostic"), ncores = 16L)
plotFullBenchmarkGIC(gap$trace, file.path(directory, "diagnostic", "blind-gic.png"))

The fitted object contains the area table, compound identities and alignment maps. To inspect a single sample and its factors, use sampleNMF().

fit$areas
fit$compounds
fit$alignment
single <- sampleNMF(fit, sample=1L)
dim(single$H)
dim(coef(single))
plot(fit, type="areas")

100-sample scalability benchmark

The 100 full chromatograms contained 10,000 scans and 550 channels each. Every one of the 5,000 distinct simulated compounds occurred in ten randomly chosen samples. This held the mean density at 500 peaks per sample (452–539) while reducing the proportion of samples containing each compound from 50% to 10%. The fitter received the CDFs and an independent PSF standard. The spectral library, retention-index scoring key and true profiles were reserved for simulation and validation. It used 32 initial mass-channel groups, original-ion refinement and automatic local rank search.

Quantity Result
True / estimated shared rank 5,000 / 5,003
True compounds with at least one reciprocal detection 5,000 / 5,000
True positive / false positive / missed occurrences 50,000 / 1 / 0
Sensitivity / precision 100% / 99.998%
Shark-fin acid occurrences recovered 500 / 500
Median absolute peak area error, matched peaks (% [P25, P75]) 0.062 [0.028, 0.119]
Median absolute peak area error, matched acids (% [P25, P75]) 0.066 [0.027, 0.133]
Original-ion quasi-GIC 243,809,331.9
Elapsed time per sample / whole batch 80.15 s / 133.58 min
Sampled peak process-tree working set 8.095 GiB

The run used 16 logical processors and included PSF calibration, reading the CDFs, building the dictionary, rank search and native exports. Truth scoring ran afterwards. The GCMSbenchmark scorer compared every called spectrum to all 5,000 references in each of the 100 samples and awarded one credit per reciprocal match within ±30 retention-index units at cosine ≥0.70. The shared rank counts fitted spectral factors across the batch. For 4,997 compounds, a single fitted factor accounted for all ten occurrences. The other three compounds each received two identities across their ten positive samples (9 + 1, 9 + 1 and 8 + 2). The one false-positive occurrence was a call for compound 4,886 in sample 29, where it was absent. Simulation, code and measured results