SPARSE NONNEGATIVE MATRIX FACTORIZATION · LOG-CONCAVE PROFILES
Log-concave NMF.
Automatic rank selection.
A structured sparse nonnegative factorisation framework for ordered multichannel data, combining automatic rank selection, hard log-concave profiles, flexible likelihoods supporting different noise models and simultaneous multisample models that do not require trilinearity.
R · Grouped L0 discovery · Penalised likelihood · Flexible multisample sharing
Automatic rank selectionScore additions, deletions and fusions by penalised likelihood to obtain the most parsimonious rank Hard log-concavityComponent- and sample-specific chromatographic profiles Flexible noise familiesGaussian, Poisson, quasi-Poisson, Negative Binomial and Gamma models
Nonnegative matrix and tensor factorisation to separate overlapping peaks
Hyphenated chromatography is a demanding test case for structured NMF and tensor decomposition. In GC–MS, chromatographic separation is rarely complete: when compounds co-elute, the spectrum observed at one scan is an additive mixture of their spectra. In matrix notation,
\mathbf{Y}_{i\boldsymbol{\cdot}} \approx \sum_{r=1}^{R} H_{ir}\mathbf{S}_{r\boldsymbol{\cdot}} + \mathbf{B}_{i\boldsymbol{\cdot}},
where \mathbf{H}_{\boldsymbol{\cdot}r} is the elution-mode factor, \mathbf{S}_{r\boldsymbol{\cdot}} is the spectral-mode factor for component r, and \mathbf{B}_{i\boldsymbol{\cdot}} represents the smooth background at scan i. Recovering the latent components is therefore a constrained nonnegative factorisation problem: model order must be identified while chemically meaningful structure is imposed on both modes.
Chemometricians have long used nonnegative matrix and tensor factorisations to resolve co-eluting compounds. Examples include unimodal NMF, PARAFAC2 models that allow retention shifts, MCR-ALS, NMF for overlapping GC–MS spectra, the PARADISe workflow, shift-invariant trilinear models and parametric analysis of multiple chromatograms. They exploit the fact that even partly overlapping compounds can have different spectra or different elution profiles. Ang et al. · Bro et al. · de Juan et al. · Gao et al. · Johnsen et al. · Schneide et al. · van Stokkum et al.
What standard formulations leave unresolved
Optimisation and chemical rank. Bilinear and multilinear factorisations are nonconvex. Different starts can give different stationary solutions, while ALS algorithms may enter long swamps or stop at a poor local fit (Boutsidis & Gallopoulos, 2008; Tomasi & Bro, 2006). The number of components is usually supplied or selected outside the main fit. Useful diagnostics and automated classifiers exist for PARAFAC/PARAFAC2 (Bro & Kiers, 2003; Johnsen et al., 2014), but require fitting and comparing a sequence of prespecified ranks.
-
Peak geometry. Nonnegativity alone permits multimodal or jagged elution profiles. MCR-ALS can impose unimodality (Bro & Sidiropoulos, 1998), but unimodality by itself permits shoulders, plateaus and irregular tails. A more appropriate peak-shape constraint would be log-concavity, which is stronger: when imposed on the positive support,
\Delta^2\log h_i = \log h_{i+1}-2\log h_i+\log h_{i-1}\leq 0,
which implies unimodality while still allowing asymmetric and long-tailed peaks.
Instrument response, background and noise. Standard factorisations do not jointly estimate a constant or smoothly time-varying point-spread function (PSF) and a smooth nonnegative background. Least squares also imposes a constant-variance Gaussian working model. Ion production and arrival motivate count models, while detector gain, aggregation and chemical variability can produce overdispersion or approximately Gaussian intensities (Ipsen, 2015). Although Poisson MCR has been proposed—in the NMF literature, the corresponding Poisson-likelihood formulation is known as Kullback–Leibler NMF (Cichocki et al., 2009; Lavoie et al., 2016)—it is a specialised extension that has not been routinely used in the chemometrics literature and does not account for overdispersion.
Multiple samples. PARAFAC assumes trilinearity: apart from an amplitude, each compound has the same elution profile in every sample. Shifted PARAFAC adds translations but not compound- and concentration-specific broadening or tailing. Classical PARAFAC2 is more flexible, but still requires \mathbf{H}_s^{\mathsf T}\mathbf{H}_s=\boldsymbol{\Phi} for every sample s. Retention shifts can preserve these cross-products; changing widths, tails and pairwise overlaps generally do not. Flexible and fully constrained PARAFAC2 variants relax important parts of this restriction (Cohen & Bro, 2018; Roald et al., 2022).
| Method (typical cited formulation) | Rank selection | Chromatographic profile | Nonnegativity | Joint component selection across channels | Optimal spectral sparsity | Noise objective | Multiple samples | Rank and scope in the cited formulation |
|---|---|---|---|---|---|---|---|---|
| MCR-ALS / NMF† (GC–MS NMF; unimodal NMF) | Supplied; external EFA/PCA diagnostics | Optional unimodality and other constraints, but no hard log-concavity | Both factors in standard NMF and NNLS-constrained MCR; optional in broader MCR | No | No | Least squares is usual; generalized KL and specialised Poisson extensions exist | Separate, augmented or shared-factor multiset fits | Chosen for the mixture or interval being resolved |
| PARAFAC / shifted PARAFAC | Supplied; external diagnostics | One shared profile per compound; shifted variant adds translation | Optional | No | No | Least squares in standard algorithms | Exact trilinearity, or sample shifts only | Chosen for the sample tensor or interval |
| Classical PARAFAC2 / PARADISe | Usually supplied; multi-rank diagnostic automation has been proposed | Sample-specific profiles with a constant cross-product constraint; no hard chromatographic shape | Historically not on every mode | No | No | Least squares | Retention drift and restricted shape variation | PARADISe compares candidate ranks within each chromatographic interval |
| Flexible / fully constrained PARAFAC2 | Supplied externally | Optional nonnegativity, smoothness or unimodality; relaxed/flexible coupling | Can constrain every mode | No | No | Least squares in the cited formulation | More flexible drift and shape variation, with an explicit coupling penalty or constraint | Fitted at the chosen order |
| Shift-invariant trilinearity | Supplied externally | A shared peak shape up to translation; cannot model sample-specific shape changes | Can constrain all modes | No | No | Least squares | Retention shifts under shift-invariant trilinearity | Evaluated on low-rank windows; whole chromatograms still require many separate models |
† When both factors are constrained nonnegative and each alternating least-squares step uses nonnegative least squares under a squared-error loss, MCR-ALS and standard least-squares NMF solve the same constrained bilinear factorisation (Camp, 2019). MCR-ALS remains the established name in chemometrics and is the broader framework because its regressors and constraints need not be nonnegative least squares.
The cited chromatographic workflows choose rank for a matrix or retention interval. In PARADISe, intervals are selected to contain preferably fewer than six peaks. Baccolo et al. subsequently automated the PARADISe workflow. The rank of a whole chromatogram counts distinct compounds across all intervals. Automated PARADISe · PARADISe
Commercial GC–MS software
The vendor guides reviewed here do not specify a preset objective for deciding whether a better fit to the original ion counts justifies another compound, a more complex profile or additional fragment ions. Users can set peak width, height, area and signal-to-noise thresholds in AnalyzerPro. In MassHunter, the correlation window affects how many neighbouring peaks are resolved. These choices can change the peak list. The nine commercial workflows reviewed have no published result on these 16 chromatograms against which to compare rank recovery, false calls or area accuracy. Agilent MassHunter, p. 27 · SpectralWorks AnalyzerPro · Commercial software comparison
What logconNMF adds to constrained factorisation
Grouped peak selection
Candidate peak positions are selected jointly across detector channels, pooling evidence across mass channels rather than thresholding ions separately.
Optimal spectral sparsity
Within retained components, sparsity-promoting penalised regression favours parsimonious ion support; final selection moves are checked on every original channel.
Automatic rank selection
Score additions, deletions and fusions by penalised likelihood to obtain the most parsimonious rank.
Hard log-concave profiles
Every retained profile is nonnegative, contiguous and log-concave during fitting—a stronger constraint than post-hoc unimodality.
PSF starts, individual final shapes
estimatePSF() estimates a constant or time-varying PSF for initialisation. The constant blind-PSF model is a constrained lag-separable convolutive NMF; each final compound occurrence nevertheless receives its own width and tail.
Background and noise fitted jointly
A smooth nonnegative background remains in the model. Flexible likelihood families cover count-like, overdispersed and continuous measurements.
Shared spectra without trilinearity
Samples retain their original grids, shapes, locations and areas. Monotone area-preserving time warps account for drift without resampling, and compounds may be absent.
High-rank full chromatograms
Sparse screening and local likelihood updates support full chromatograms and large batches directly, with hundreds or thousands of components or sample–component occurrences.
L0glm selects candidate peaks jointly across ions by fitting a grouped L₀ regression on a time-varying PSF dictionary as a sequence of convex adaptive-ridge subproblems. With peaks aligned across samples, logconNMF updates the active set of compounds and retains deletions, residual-supported additions and fusions of neighbouring features when they lower the GIC on the original ions. The time-varying PSF is locally rather than globally convolutional, and the final factorisation does not constrain profiles to shifted copies of a common kernel. The same formulation applies to other ordered multichannel signals with nonnegative, single-peaked components.
Rank-selection objective
For ordinary identity-link count data, the original-ion objective is
J = \sum_s D_{\rm Pois}(Y_s,\mu_s)/\phi_s + \lambda_{\rm eff}\left[\sum_k(\|p_k\|_0-1)+\sum_{s,k}d(h_{sk})\right].
Each shared unit-sum spectrum contributes one fewer degree of freedom than its number of positive ions. Each sample-specific log profile contributes the dimension of its fitted piecewise-linear shape. Absent profiles contribute zero. The same criterion checks changes in peak shape, ion support and component count for one or several samples. The fixed background basis stays unpenalized. Coordinate updates and local support exchanges can reach a local minimum. The mathematical description gives the acceptance rules and the criterion used for other noise families.
Installation
install.packages("remotes")
remotes::install_github(c(
"tomwenseleers/L0glm/L0glm",
"tomwenseleers/logconNMF/logconNMF"
))The R package includes the conditional Poisson and quasi-Poisson solver. It fits the original ion counts with compiled C++ kernels and uses OpenMP when available. Solver selection is automatic for the requested noise model and memory settings.
Log-concave NMF for single samples
This deliberately small cuticular-hydrocarbon window contains six co-eluting components and is used to make the recovered factors easy to inspect. It is not a scale limit: logconNMF runs efficiently on full sample matrices with approximately 10,000–15,000 time scans or more. The initial dictionary X places a narrow Gaussian point spread function (PSF) at each possible peak location. An efficient L0glm fit then selects the best subset that can explain the multichannel signal, thereby penalising most coefficients to zero. Equally, logconNMF provides estimatePSFFromStd() and estimatePSF() to estimate the PSF and construct the most parsimonious corresponding dictionary from either externally run standards, such as an alkane ladder, or the sample chromatogram itself.
library(logconNMF)
data(gcmsData1)
Y <- gcmsData1
g <- convKernel("gaussian", 65L, list(sigma = 9))
psf <- estimatePSF(Y, time = as.numeric(rownames(Y)), standard = NULL,
nwindows = 1L, precluster = 1L,
control = list(kernel_est = g, maxiter = 0L))
X <- psf$X
fit <- logconNMF(Y, X = X, time = as.numeric(rownames(Y)), background = matrix(1, nrow(Y), 1L),
family = quasipoisson("identity"), precluster = 7L,
control = list(initial_relaxed = FALSE, fusion_passes = 0L))
fit$rank # estimated number of components
profiles <- fit$H # scans x components
loadings <- coef(fit) # components x original channels
spectra <- coef(fit, normalize = "l1")
GIC(fit)Using estimatePSF() here applies the same boundary-aware, column-normalised PSF construction as the high-level GCMSprime workflow. Consequently, these settings reproduce the identical fitted profiles, spectra and background in both packages; repeated fits are deterministic.
The columns of profiles sum to one, so each row sum in loadings gives the component’s total fitted signal across scans and channels. Grouping similar channels can speed up the initial search. The reported spectra use every original channel. We selected this six-component example after a sensitivity grid over Gaussian PSF widths and precluster counts: among solutions with six factors and chemically plausible retention times, it gave the best balance of low GIC, accurate apex times, compact profiles and strong enrichment of the compounds’ diagnostic ions.

The upper square-root display makes weak ion traces visible; the six spectra below are shown as base-peak relative intensities.
Beer volatiles: compound-specific log-concave peak shapes
A beer-headspace window provides a more demanding real-data example. Narrow, partially overlapping volatiles occur alongside a broad, strongly asymmetric acid peak. Instead of forcing one common PSF on every compound, the final factors act as compound-specific log-concave effective peak-shape functions: they can be narrow, broad or strongly asymmetric while remaining nonnegative and single-peaked. The associated spectra are estimated jointly from all 518 mass channels.
Observed ion traces are shown in grey; coloured curves show the fitted compound contributions. Component 17 captures the broad asymmetric acid signal without imposing its shape on the narrower neighbouring peaks.
Simultaneous log-concave NMF for multiple samples
For related matrices, logconNMF performs simultaneous NMF in the terminology of Badea (2008), Cichocki et al. (2009) and Lee et al. (2012):
\mathbf{Y}_s \approx \mathbf{H}_s\mathrm{diag}(\mathbf{a}_s)\mathbf{S} +\mathbf{B}_s\mathbf{A}_s.
Here \mathbf{H}_s contains unit-area log-concave profiles, \mathbf{a}_s gives the component areas, \mathbf{S} contains the shared unit-sum component spectra, and \mathbf{B}_s\mathbf{A}_s is the smooth nonnegative background. Monotone area-preserving time warps model retention drift and are taken into account as alignment and Jacobian offsets without resampling samples on a common grid; components may be absent from any subset of samples. This shares chemical information without imposing PARAFAC trilinearity or the PARAFAC2 constant-cross-product constraint.
Grouped PSF regressions divide the core budget between independent samples and native threads. The scheduler estimates how many regressions fit in available memory, including Windows commit headroom. The coupled fit stores the original counts and fitted means on disk. OpenMP workers update sample-specific profiles in local scan windows and update shared spectra in blocks of ion channels. Candidate rank changes are evaluated on the original ions. Gaussian, negative-binomial and Gamma models also read original-ion blocks from disk, using their own likelihoods.
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.
GCMSprime recovered all 1,000 compounds at the correct shared rank and called all 8,000 peaks with zero false positives, including all 80 acid peaks. Each fitted identity matched the same compound in all eight injections in which it occurred. On a 64 GB Windows laptop with eight physical cores and 16 logical processors, the fit took 29.03 seconds per sample for the 88 million ion measurements and peaked at 6.77 GiB of sampled process-tree working memory.
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.
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
Classical chromatographic MCR-ALS, PARAFAC and PARAFAC2 workflows usually fit candidate ranks chosen by the analyst and use diagnostics to assess them. In GC–MS it is common to fit short retention windows with roughly one to ten components each. Bro & Kiers · Johnsen et al. · van Stokkum et al.
PARADISe’s default upper rank is eight per retention window and can be increased. Our recovered rank of 1,000 across the full batch is 125 times that local default. PARADISe protocol, §12.1
| 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.
Among GCMSprime’s 8,000 matched occurrences, the median absolute peak area error was 0.095% [0.041%, 0.197%] and ordinary adjusted R² on the log₁₀ scale 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.
Benchmark methods, scoring, timings 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.
Single-sample and multiset MCR window benchmarks
The same shark-fin acid illustrates what fitting related samples together can resolve. Given the interior rank, Tauler’s MCR-ALS 2.0 toolbox recovered all eight compounds in sample 002, but assigned 211% of the true area to its acid peak. The joint fit recovered all 120 interior occurrences across 16 samples with a median absolute area error of 1.99% [1.09%, 3.82%]. The calibrated GCMSprime fit selected 19 factors including neighbouring tails, recovered all 120 interior occurrences with zero unassigned calls, and gave a median absolute area error of 0.160% [0.078%, 0.408%]. The R interface also benchmarks nonnegative CANDECOMP/PARAFAC (CP), two names for the same decomposition, and flexible PARAFAC2. Window results, figure and R examples
100-sample scalability benchmark
A separate 100-sample fit processed 550 million ion measurements at the same average density of 500 peaks per chromatogram. It estimated rank 5,003 for 5,000 generating compounds and recovered 50,000 of 50,000 occurrences with only one false positive. It took 80.15 seconds per sample and peaked at 8.095 GiB. Simulation, code and measured results
Choose a workflow
| Data and objective | Method |
|---|---|
| Estimate a common response shape from a standard or overlapping signals |
Estimate PSFs with estimatePSF(). The returned sparse design can use a constant or time-varying PSF. |
| Resolve components with individual shapes in one matrix |
Sparse log-concave NMF with logconNMF(). The tutorial covers rank selection, backgrounds and flexible noise families. |
| Share spectra across related samples |
Simultaneous log-concave NMF with logconNMF(). Each sample retains its own scan grid, peak shapes and areas. Components may be absent from individual samples. |
For a known and common PSF, L0glm fits the sparse convolution model directly. GCMSprime uses logconNMF for chromatogram files, retention-index calibration and library search. The algorithm and theory give the objectives, shape constraints and mathematical pseudocode.
Selected literature
- Amigo JM, Skov T, Coello J, Maspoch S, Bro R (2008). Solving GC–MS problems with PARAFAC2.
- Ang AMS, Gillis N, Vandaele A, De Sterck H (2021). Nonnegative Unimodal Matrix Factorization.
- Badea L (2008). Extracting gene expression profiles common to colon and pancreatic adenocarcinoma using simultaneous nonnegative matrix factorization.
- Boutsidis C, Gallopoulos E (2008). SVD based initialization: a head start for nonnegative matrix factorization.
- Bro R, Andersson CA, Kiers HAL (1999). PARAFAC2—Part II. Modeling chromatographic data with retention time shifts.
- Bro R, Kiers HAL (2003). A new efficient method for determining the number of components in PARAFAC models.
- Bro R, Sidiropoulos ND (1998). Least squares algorithms under unimodality and non-negativity constraints.
- Camp CH Jr (2019). pyMCR: A Python Library for Multivariate Curve Resolution Analysis with Alternating Regression (MCR-AR).
- Cichocki A, Zdunek R, Phan AH, Amari S-I (2009). Nonnegative Matrix and Tensor Factorizations: Applications to Exploratory Multi-way Data Analysis and Blind Source Separation.
- Cohen JE, Bro R (2018). Nonnegative PARAFAC2: a flexible coupling approach.
- de Juan A, Jaumot J, Tauler R (2014). Multivariate Curve Resolution (MCR). Solving the mixture analysis problem.
- de Juan A, Tauler R (2021). Multivariate Curve Resolution: 50 years addressing the mixture analysis problem—A review.
- de Rooi JJ, Eilers PHC (2011). Deconvolution of pulse trains with the L0 penalty.
- Eilers PHC (2005). Unimodal smoothing.
- Gao H-T, Li T-H, Chen K, Li W-G, Bi X (2005). Overlapping spectra resolution using non-negative matrix factorization.
- Ipsen A (2015). Derivation from first principles of the statistical distribution of the mass peak intensities of MS data.
- Johnsen LG, Amigo JM, Skov T, Bro R (2014). Automated resolution of overlapping peaks in chromatographic data.
- Johnsen LG, Skou PB, Khakimov B, Bro R (2017). Gas chromatography–mass spectrometry data processing made easy.
- Lavoie FB, Braidy N, Gosselin R (2016). Including noise characteristics in MCR to improve mapping and component extraction from spectral images.
- Lee CM, Mudaliar MAV, Haggart DR, Wolf CR, Miele G, Vass JK, Higham DJ (2012). Simultaneous non-negative matrix factorization for multiple large scale gene expression datasets in toxicology.
- Roald M, Schenker C, Calhoun VD, Adalı T, Bro R, Cohen JE, Acar E (2022). An AO-ADMM approach to constraining PARAFAC2 on all modes.
- Schneide P-A, Bro R, Gallagher NB (2023). Shift-invariant tri-linearity—A new model for resolving untargeted gas chromatography coupled mass spectrometry data.
- Sorochan Armstrong MD, Hinrich JL, de la Mata AP, Harynuk JJ (2023). PARAFAC2×N: coupled decomposition of multi-modal data with drift in N modes.
- Squires S, Prügel-Bennett A, Niranjan M (2017). Rank selection in nonnegative matrix factorization using minimum description length.
- Tomasi G, Bro R (2006). A comparison of algorithms for fitting the PARAFAC model.
- van Stokkum IHM, Mullen KM, Mihaleva VV (2009). Global analysis of multiple gas chromatography–mass spectrometry (GC/MS) data sets: A method for resolution of co-eluting components with comparison to MCR-ALS.
Citation
An article describing the methods implemented in logconNMF is in preparation. If you use the package before the article is formally published, we would appreciate a citation to the package:
Wenseleers T, Vanderaa C (2026). logconNMF: Log-Concave Nonnegative Matrix Factorization with Automatic Rank Selection. R package version 0.1.0.9000, https://tomwenseleers.github.io/logconNMF/.
The Authors and Citation page also provides the citation in BibTeX format. Please also cite the methodological sources linked in the help pages where relevant.





