Skip to contents

Supply a directory to gcmsDeco() to process an experiment. Sample group subdirectories are retained, and standards/ contains alkane calibrations. The closest standard in acquisition time calibrates each sample. Results share spectra through logconNMF::logconNMF() while keeping original scan grids.

Usage

# S3 method for class 'GCMSbatch'
fitted(object, sample = 1L, ...)

# S3 method for class 'GCMSbatch'
coef(
  object,
  sample = NULL,
  normalize = c("none", "l1"),
  ...,
  ion_threshold = GCMS_ion_threshold(object)
)

# S3 method for class 'GCMSbatch'
plot(x, sample = NULL, ...)

# S3 method for class 'GCMSbatch'
logLik(object, ...)

# S3 method for class 'GCMSbatch'
GIC(object, ...)

# S3 method for class 'GCMSbatch'
AIC(object, ..., k = 2)

# S3 method for class 'GCMSbatch'
BIC(object, ...)

# S3 method for class 'GCMSbatch'
EBIC(object, ...)

# S3 method for class 'GCMSbatch'
MBIC(object, ...)

# S3 method for class 'GCMSbatch'
nobs(object, ...)

# S3 method for class 'GCMSbatch'
print(x, ...)

Arguments

sample

One sample index or identifier. NULL in coef() returns the common spectral library. NULL in plot() plots the simultaneous-fit area table.

...

Arguments passed to the corresponding sample or simultaneous method.

normalize

Spectrum normalization: unnormalized or unit L1.

ion_threshold

Reported ion-intensity cutoff as a fraction of each spectrum's base-peak intensity. The default is 0.001; zero retains every positive fitted ion.

x, object

A multisample result returned by gcmsDeco().

k

Information-criterion multiplier.

Value

A GCMSbatch object with samples, optional coupled fit, sample RDS paths, consensus areas, reusable channel_groups, the parallel thread allocation, output files and stage timings. Use readRDS(x$paths[i]) for a full per-sample gcmsDeco() object.

Details

Directory layout can be experiment/standards/alkanes.cdf, experiment/beer1/sample001.cdf, and experiment/beer2/sample002.cdf. Analytical samples are sorted by acquisition timestamp, including its time zone. The exported CDF timestamp is never used as an acquisition date. If acquisition dates are absent, pass explicit relative sample paths in batch=list(sample_order=...).

batch supports method="cosine" or "hellinger", align=TRUE, coupling=list() for logconNMF::logconNMF() controls, sample_order=NULL, exposure=NULL, resume=FALSE, plots=FALSE, workers=NULL and optional cache. workers controls simultaneous file imports and sample-level PSF fits. For a local rank search on count data use batch=list(coupling=list(penalty_search=TRUE)). The search refits overlapping peaks on the original scans and ion channels. For a more extensive search, pass refinement_sweeps=100L, penalty_search=TRUE and alternative_X=TRUE in batch$coupling. The fit compares the resulting candidates on the original ion data at the original penalty. The joint count solver uses the total ncores budget after those stages. The joint fit uses disk-backed observations by default. Count-model updates read local scan intervals or ion blocks and write fitted means to scratch files. The general solver can optionally cache aggregates with cache=TRUE. exposure may be a positive scalar, a list with one scan-wise vector per acquisition-ordered sample, or a function of a sample's metadata and time vector. The default preserves vendor intensities. Known integration durations are appropriate when the data are integrated ion counts. Sequential full-scan mass spectrometers allocate acquisition time over m/z; exported peak counts and retained traces do not identify the per-mass dwell time. No automatic division by the number of exported channels is applied.

Samples run concurrently with their own sparse PSF and smooth background. A simultaneous multisample fit uses criterion-checked sparse initial spectra for these per-sample fits; set control=list(initial_relaxed=TRUE) to request the relaxed grouped-support start used by standalone single-sample fits. A common channel map is learned from summed, time-binned chromatograms; pass a saved logconNMF::channelGroups() map as precluster to reuse reference groups. Compatible Poisson/quasipoisson initial fits also reuse these groups for restart proposal screening; completed candidates and controls are checked on every original channel before acceptance. Matching uses the shared aggregate space. Original-channel means and the likelihood are used for simultaneous updates. Shared spectra are exported on the union of recorded mass ranges; unmeasured channels receive zero likelihood weight. Missing compounds retain NA areas. No gap filling is performed. coupled=FALSE keeps the independently fitted results.

The output directory contains per-sample MSP, Excel and fitted RDS files, an acquisition-ordered samples.csv, areas.csv, a consensus MSP library, and experiment.xlsx with samples, compounds, areas and packed spectra. batch=list(plots=TRUE) also writes each sample's trace and heatmap PDFs. The returned object stores file paths, tables and common spectra. Automatic worker allocation for conditional PSF regressions accounts for memory. Set batch=list(workers=4L) to cap sample-level concurrency explicitly. Use batch=list(workers=1L) to process PSF starts one sample at a time. control$initial_solver and control$initial_fallback apply to every independent sample initialization, just as for a single chromatogram. The solver's max.memory bounds its Gram/factor workspace, not total RAM; each active sample still requires its observations, profiles and fit buffers. Keep the output directory with the saved object. Explicit resume=TRUE reuses independent fits only when the file metadata and fitting arguments match; simultaneous refinement is recomputed.

Examples

if (FALSE) { # \dontrun{
experiment <- gcmsDeco("chromatograms", output_dir="results",
  family=quasipoisson("identity"), precluster=32L,
  batch=list(method="hellinger",plots=TRUE))
experiment$areas
plot(experiment,sample=1,type="lines")
} # }