Skip to contents

GC/MS DECONVOLUTION · QUANTIFICATION · IDENTIFICATION

Accurate integration.
Cleaner spectra.

Fast and scalable GC/MS deconvolution and quantification for single samples or large multisample experiments to separate overlapping peaks, with inbuilt spectral library search.

R · Full mass spectra · CDF input · MSP & Excel output

A GC–MS run records mixtures of ions whenever compounds overlap in time. GCMSprime separates these signals into elution profiles and full mass spectra, then integrates each resolved compound. It accepts ANDI-MS CDF files and writes an MSP library of the recovered spectra and an Excel quantification table when requested. For a sample series, it aligns retention times and shares spectra across related occurrences.

An alkane ladder can calibrate peak shapes and retention indices. Supplying a spectral library adds ranked candidate matches, with the retention-index agreement and the reference source recorded alongside each score.

See the 16-sample benchmark for peak-area and spectral recovery across seven workflows.

Installation

install.packages("remotes")
remotes::install_github(c(
  "tomwenseleers/L0glm/L0glm",
  "tomwenseleers/logconNMF/logconNMF",
  "tomwenseleers/GCMSprime/GCMSprime"
))

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.

Automatic deconvolution for single samples

One call estimates the response shape, smooth background, compound profiles, full mass spectra and integrated areas, then writes NIST-compatible MSP and Excel reports. An alkane ladder can calibrate the PSF and retention indices.

library(GCMSprime)
fit <- gcmsDeco("sample.cdf", "sample.msp", xlsx_file="sample.xlsx",
  alkanes_file="alkanes.cdf", precluster=32L)
plot(fit, type="lines", file="sample_traces.pdf")
plot(fit, type="heatmap", file="sample_heatmaps.pdf")
plot(fit, type="profiles", file="sample_profiles_spectra.pdf")

The compound table gives apex retention times, integrated areas and the number of fitted ions. Use the trace and heatmap plots to inspect overlapping peaks and residual structure, and use the profile and spectrum plots to inspect individual components.

head(fit$compounds[c("compound", "retention_time", "area", "n_ions")])
fit$seconds
spectra <- coef(fit, normalize="l1")  # unit-L1 spectra, shared 0.1% ion cutoff

The fit allows asymmetric and broad profiles under a hard log-concavity constraint. The rank criterion selects the component set, and final refinement uses every original mass channel.

Six co-eluting hydrocarbons

The bundled cuticular-hydrocarbon window illustrates recovered elution profiles and spectra. This short-window example uses a supplied PSF dictionary and a constant background; individual compound shapes are then refined.

data(gcmsData1, package="logconNMF")
writeGCMSCDF(gcmsData1, "GCMS_data1.cdf")
example_fit <- gcmsDeco("GCMS_data1.cdf", "GCMS_data1.msp",
  nwindows=1L, baseline_df=1L, precluster=7L, correlation="auto", ncores=8L,
  control=list(initial_relaxed=FALSE, fusion_passes=0L),
  psf_control=list(kernel_est=logconNMF::convKernel("gaussian", 65L,
    list(sigma=9)), maxiter=0L))

Among six-factor solutions with chemically plausible retention times, a sensitivity grid over PSF widths and precluster counts selected this fit for its combination of low GIC, accurate apex times, compact profiles and strong enrichment of the compounds’ diagnostic ions.

Grey ion traces, six resolved profiles and matching spectra for six co-eluting hydrocarbons

Beer volatiles and a broad acid peak

A beer-headspace window contains a strongly asymmetric acid peak mixed with narrower neighbours. Flexible log-concave profiles accommodate this shape while the spectra use all 518 channels. The same workflow represents the broad acid contribution as one log-concave profile among the narrower peaks. The single-sample tutorial reports the measured CDF-to-MSP times and fit metrics.

Beer chromatogram with fitted compounds and the broad acid contribution

The single-sample tutorial includes both datasets, fitted-signal heatmaps, profile/spectrum panels, timings and downloadable MSP/PDF outputs. GC/MS deconvolution: mathematical basis explains the progression from known PSFs to estimated and component-specific shapes.

Automatic deconvolution for multiple samples

Point to a directory containing sample-group folders and a standards/ subdirectory with alkane calibrations. Acquisition timestamps determine run order. The simultaneous model aligns compounds and shares their spectra while retaining sample-specific profiles, backgrounds and areas.

experiment <- gcmsDeco("chromatograms", output_dir="experiment_results",
  precluster=32L, batch=list(plots=TRUE))
experiment$samples
experiment$areas

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.

Benchmarks against other software

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.

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.

Time per sample, sensitivity and precision for all seven workflows

Estimated versus true total-ion areas across all seven workflows

Reciprocal reference spectrum matches across the 16 chromatograms

Ion-support recovery across the seven workflows

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.

Recovered and simulated profiles for the selected EMG compound

Recovered and simulated profiles for the selected shark-fin acid

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.

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

Block-level GIC trace · Final GIC values.

Comparison with other software

In the seven workflows tested, GCMSprime obtained the highest sensitivity, the fewest false-positive calls and the most accurate peak areas. Across its 8,000 true positives, GCMSprime’s median absolute area error was 0.095% [0.041%, 0.197%]. AMDIS recovered 7,878 peaks with an error of 20.74% [14.34%, 33.82%] and called 9,122 extra peaks. Among the other six programs, mzmine GC-EI had the lowest median area error, 6.41% [2.51%, 14.23%], across its 4,202 true positives (adjusted R² = 0.966560).

GNPS/MSHub was the only other tested workflow to report a batch component count. It estimated 1,414 components (41.4% above the true rank), missed 821 occurrences and made 12,184 false-positive peak calls. The five workflows that deconvolved or grouped peaks per sample achieved 52.5–98.5% sensitivity and made 185–11,685 false-positive calls each. Even AMDIS, the closest on sensitivity, missed 122 peaks and made 9,122 false-positive calls. Peak widths, detection thresholds and ion-grouping settings are among the choices that affect these results. Benchmark counts, scoring and settings

Matrix and tensor factorisation approaches

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.

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

Matrix or tensor method How rank enters the fit Limitation for these chromatograms
MCR-ALS, conventional GC–MS NMF and unimodal NMF The analyst supplies the component count, often after an exploratory analysis. Nonnegativity allows multiple maxima within a profile. Unimodality rules those out but still allows irregular shoulders and tails. Unimodal NMF · MCR-ALS · GC–MS NMF
Simultaneous NMF A common factor links datasets at a specified rank. Sharing spectra helps across samples. The basic factorisation leaves each compound’s elution shape unrestricted and supplies no chromatographic rule to choose between one broad peak and two neighbouring factors. Lee et al.
Global parametric GC–MS analysis Candidate compound models are specified and fitted jointly. The chosen peak family must describe the peaks in every sample. A good exponentially modified Gaussian model for a regular peak can leave a systematic residual at the sharp trailing edge of a shark-fin acid. Van Stokkum et al.
PARAFAC and shifted PARAFAC Diagnostics such as core consistency compare specified ranks. Standard trilinearity fixes each compound’s elution shape across samples up to amplitude. Allowing a retention shift moves the peak, while its width and asymmetry remain fixed. The simulated peaks broaden with concentration. Core consistency · Shifted factor models
Classical PARAFAC2 and PARADISe PARADISe compares candidate ranks within retention intervals. A later automated workflow also selects and evaluates models. PARAFAC2 lets profiles move, but their cross-products after scaling must agree across samples. Differential broadening changes how much neighbouring peaks overlap and can violate that condition. Choosing an interval model also leaves the task of assigning unique compounds across the chromatogram. Automated PARADISe · PARADISe
Flexible and fully constrained PARAFAC2 Both cited formulations fit a specified number of components. Flexible coupling relaxes the cross-product condition. AO-ADMM can impose sparsity, smoothness or nonnegativity on all modes. The analyst still specifies the rank and relevant regularisation settings in these least-squares fits. Cohen and Bro · Roald et al.
Shift-invariant trilinearity and PARAFAC2×N Both fit a chosen model order. A shifted copy of a common peak cannot reproduce concentration-dependent broadening. PARAFAC2×N accommodates drift in multiple separation dimensions. Its coupling constraints still leave the number of compounds to be selected. Shift-invariant trilinearity · PARAFAC2×N

Ion-count variance in this simulation rises with the mean. Unweighted least squares assigns the same cost to an absolute residual at every intensity. Poisson MCR and KL-based NMF allow for signal-dependent variance. GCMSprime also estimates overdispersion, which determines how large a gain in fit must be to justify another profile or fragment ion. Cichocki et al. · Lavoie et al.

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

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

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

Open and commercial libraries can be imported. MoNA and Golm MSP collections, GCMS-ID CSV predictions, and OpenChrom-exported Agilent or Shimadzu libraries are supported. Large catalogues can remain in indexed SQLite storage.

lib <- readMSP("library.msp", backend="sqlite", db_file="library.sqlite")
identified <- gcmsDeco("sample.cdf", "identified.msp",
  xlsx_file="identified.xlsx", alkanes_file="alkanes.cdf", library=lib,
  search=list(phase="DB5", ri_tolerance=30, n_matches=5,
              method=c("stein_scott", "hellinger")))

The compounds recovered from single- or multisample deconvolution can be automatically annotated using spectral match quality and retention index. Alkane-derived indices first restrict candidates to the selected column class and tolerance; fast native search then ranks their spectra. Multisample consensus IDs support a unique-compound list across the experiment, with sample-specific RI evidence and full match provenance retained.

Stein–Scott, cosine/angular, Hellinger and symmetric probability/count comparisons are available, with optional ion-rarity weighting. Excel and MSP reports include the ranked matches and annotations. The library-import tutorial covers formats and storage; retention indices and library search shows single- and multisample identification. The identification theory gives the formulas, calibration and comparison benchmarks.

Selected references

  • Aksenov et al. (2021) describe the GNPS/MSHub workflow. MSHub
  • Baccolo et al. (2021) automated model selection and assessment for PARADISe. Automated PARADISe
  • Camp (2019) describes alternating regression with separate constraints on concentrations and spectra. pyMCR
  • Chennupati et al. (2020) use distributed NMF to infer the number of factors in large matrices. Distributed NMF
  • Fu, Matsushima and Yamanishi (2019) compare rank-selection criteria for nonnegative tensors. Tensor rank selection
  • Johnsen et al. (2017) describe PARADISe for local GC–MS deconvolution. PARADISe
  • Lee et al. (2012) fit a common factor across multiple datasets. Simultaneous NMF
  • Lu et al. (2008) tested how concentration and component-width settings affected GC–TOF-MS deconvolution with AnalyzerPro, ChromaTOF and AMDIS. Comparative evaluation
  • Roald et al. (2022) show how to constrain all modes of PARAFAC2. Constrained PARAFAC2
  • Squires et al. (2017) use minimum description length to select NMF rank. Rank selection by minimum description length
  • van Stokkum et al. (2009) compare parametric analysis of GC–MS data with MCR-ALS in local windows. Global analysis and MCR-ALS

Citation

An article describing the methods implemented in GCMSprime 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). GCMSprime: Scalable and Automated GC–MS Deconvolution, Quantification, and Spectral Library Search in R. R package version 0.1.0.9000, https://tomwenseleers.github.io/GCMSprime/.

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.

Acknowledgements

OpenAI Codex, using GPT-6 Astra and GPT-6.1 Sol, was used to optimize and refactor code and help draft the documentation. The key ideas and methodological decisions are the authors’ own, and the authors take full responsibility for the work presented here.