Skip to contents

Pluggable alignment stages used by align() and the align_fun argument of fit_mdm() / benchmark().

  • clupa(): CluPA — hierarchical-clustering peak alignment (recursive FFT segment shifts, Beirnaert et al. 2018, Vu et al. 2011). Operates on the Lorentz reconstruction sit$sup already attached to each spectrum by deconvolution.

  • snap_to_ref(): Reference snapping — snap each peak to the nearest reference column within maxCombine.

All these functions require every input spectrum to share the same $cs grid; an explicit stop() is raised otherwise. Call harmonize_grid() upstream to enforce that invariant.

snap_to_ref() applies the snapping step on its own: for each peak in each spectrum, finds the nearest reference column on the shared cs grid and records that column as pcisn (and its ppm value as x0sn). Peaks farther than maxCombine columns from every reference column get pcisn = NA / x0sn = NA. Original x0, x0al, A, lambda, pcide and pcial are preserved — snapping only adds the snapped fields. Collisions on the same pcisn column are not merged here; si_mat() sums their areas when rasterising the feature matrix. sit$supal is cleared because the post-snap superposition would need recomputing.

Usage

clupa(
  x,
  y = NULL,
  ref = NULL,
  maxShift = 50,
  verbose = TRUE,
  nworkers = 1,
  full = TRUE,
  use_speaq = FALSE,
  gap_tol = NULL
)

snap_to_ref(x, ref = NULL, maxCombine = 20, ...)

Arguments

x

A decons2 or aligns object.

y

Optional factor of class labels. Unused by the default pipeline; accepted for signature compatibility.

ref

Optional reference spectrum (align or decon2). When NULL, chosen internally.

maxShift

Maximum CluPA shift in datapoints.

verbose

Print progress messages?

nworkers

Number of parallel workers.

full

If TRUE also recompute the aligned superposition.

use_speaq

Use speaq::hClustAlign (CluPA only).

gap_tol

Optional gap tolerance in ppm; only consulted by experimental snap backends.

maxCombine

Maximum reference-snapping distance in datapoints.

...

Ignored.

Value

An object of class aligns.

Examples

decons <- deconvolute(sim[1:5], sfr=c(3.55, 3.35), verbose=FALSE)
aligned <- clupa(decons, maxShift=50, verbose=FALSE)  # CluPA stage
snapped <- snap_to_ref(aligned, maxCombine=20)        # reference snapping