Aligns peaks across a set of deconvoluted spectra by chaining two stages:
CluPA (
clupa()) shifts peak centers continuously toward a reference using hierarchical-clustering FFT segment shifts (Beirnaert et al. 2018, Vu et al. 2011). Addsx0alandpcial(post-CluPA center and column index) to each peak; originalx0,A,lambda,pcideare preserved.Reference snapping (
snap_to_ref()) records, for each peak, the nearest reference column withinmaxCombineaspcisn/x0sn. Peaks farther thanmaxCombinefrom every reference column getpcisn = NA/x0sn = NA. No peaks are dropped and amplitudes are not summed here — collisions on the samepcisnare aggregated downstream bysi_mat().
All spectra in x must already live on the same chemical-shift
grid (identical $cs vector across spectra). Call
harmonize_grid() upstream if your inputs come from
different acquisitions with slight calibration offsets.
Usage
align(
x,
y = NULL,
ref = NULL,
maxShift = 50,
maxCombine = 0,
verbose = TRUE,
nworkers = 1,
full = TRUE,
use_speaq = FALSE,
gap_tol = NULL
)Arguments
- x
A
decons2(oraligns) object.- y
Optional factor of class labels (length
length(x)). Unused by the default pipeline; accepted for signature compatibility.- ref
Optional reference spectrum (
alignordecon2). WhenNULL(default) the reference is chosen internally.- maxShift
Maximum number of datapoints a peak center may be shifted by CluPA.
maxShift = 0Lskips CluPA (setsx0al = x0).- maxCombine
Maximum snap distance for reference snapping in chemical-shift columns.
maxCombine = 0Lskips snapping. A negative value is treated asmaxShift.- verbose
Print progress messages?
- nworkers
Number of parallel workers.
- full
If
TRUEalso recompute the aligned superposition during CluPA. Reference snapping always dropssit$supal(the post-snap peak list is no longer Lorentz-compatible).- use_speaq
Use
speaq::hClustAligninstead of the bundled CluPA implementation. Defaults toFALSE; the bundled implementation is byte-equivalent to the speaq one (seetests/testthat/test-speaq.R). SettingTRUErequires the suggestedspeaqpackage.- gap_tol
Optional gap tolerance in ppm.
NULL(default) uses the standard CluPA + snapping pipeline; only consulted by experimental snap backends.
Examples
decons <- deconvolute(sim[1:5], sfr=c(3.55, 3.35), verbose=FALSE)
aligned <- align(decons, maxShift=50, maxCombine=20, verbose=FALSE)