Align signals across a list of deconvoluted spectra using the 'CluPA'
algorithm from the 'speaq' package, described in Beirnaert et al. (2018)
doi:10.1371/journal.pcbi.1006018 and Vu et al. (2011)
doi:10.1186/1471-2105-12-405 plus the additional peak combination described
in combine_peaks()
.
Arguments
- x
An object of type
decons1
ordecons2
as described in Metabodecon Classes. To aligndecons0
objects (as returned by the now deprecated MetaboDecon1D), you can useas_decons2()
to convert it to adecons2
object first.- maxShift
Maximum number of points along the "ppm-axis" a value can be moved by the 'speaq' package. 50 is a suitable starting value for plasma spectra with a digital resolution of 128K. Note that this parameter has to be individually optimized depending on the type of analyzed spectra and the digital resolution. For urine which is more prone to chemical shift variations this value most probably has to be increased. Passed as argument
maxShift
tospeaq_align()
.- maxCombine
Amount of adjacent columns which may be combined for improving the alignment. Passed as argument
range
tocombine_peaks()
.- verbose
Whether to print additional information during the alignment process.
- install_deps
Alignment relies on the 'speaq' package, which itself relies on the 'MassSpecWavelet' and 'impute' packages. Both, 'MassSpecWavelet' and 'impute' are not available on CRAN, but can be installed from Bioconductor or R-Universe. If
install_deps=TRUE
, these packages will be automatically installed from R-Universe without asking for confirmation. Ifinstall_deps=NULL
(default), the user will be asked for confirmation before installing missing dependencies. If asking for confirmation is not possible orinstall_deps=FALSE
, the function will raise an error if the packages are not installed.
Value
An object of type align
as described in Metabodecon Classes.
Examples
decons <- deconvolute(sim[1:2], sfr = c(3.55, 3.35))
#> 2025-04-17 14:51:52.62 Starting deconvolution of 2 spectra using 1 worker
#> 2025-04-17 14:51:52.62 Starting deconvolution of sim_01
#> 2025-04-17 14:51:52.62 Removing water signal
#> 2025-04-17 14:51:52.62 Removing negative signals
#> 2025-04-17 14:51:52.62 Smoothing signals
#> 2025-04-17 14:51:52.63 Starting peak selection
#> 2025-04-17 14:51:52.64 Detected 314 peaks
#> 2025-04-17 14:51:52.64 Removing peaks with low pscores
#> 2025-04-17 14:51:52.64 Removed 287 peaks
#> 2025-04-17 14:51:52.64 Initializing Lorentz curves
#> 2025-04-17 14:51:52.64 MSE at peak tiplet positions: 4.0838805770844048836921
#> 2025-04-17 14:51:52.64 Refining Lorentz Curves
#> 2025-04-17 14:51:52.65 MSE at peak tiplet positions: 0.1609359876216345797140
#> 2025-04-17 14:51:52.65 MSE at peak tiplet positions: 0.0228015051613790313556
#> 2025-04-17 14:51:52.65 MSE at peak tiplet positions: 0.0071638016610617799920
#> 2025-04-17 14:51:52.65 Formatting return object as decon2
#> 2025-04-17 14:51:52.66 Finished deconvolution of sim_01
#> 2025-04-17 14:51:52.66 Starting deconvolution of sim_02
#> 2025-04-17 14:51:52.66 Removing water signal
#> 2025-04-17 14:51:52.66 Removing negative signals
#> 2025-04-17 14:51:52.66 Smoothing signals
#> 2025-04-17 14:51:52.66 Starting peak selection
#> 2025-04-17 14:51:52.67 Detected 316 peaks
#> 2025-04-17 14:51:52.67 Removing peaks with low pscores
#> 2025-04-17 14:51:52.67 Removed 286 peaks
#> 2025-04-17 14:51:52.67 Initializing Lorentz curves
#> 2025-04-17 14:51:52.68 MSE at peak tiplet positions: 3.8338943428876719465848
#> 2025-04-17 14:51:52.68 Refining Lorentz Curves
#> 2025-04-17 14:51:52.68 MSE at peak tiplet positions: 0.1289481941626757499630
#> 2025-04-17 14:51:52.68 MSE at peak tiplet positions: 0.0135651899090413786964
#> 2025-04-17 14:51:52.68 MSE at peak tiplet positions: 0.0025556755331531087749
#> 2025-04-17 14:51:52.68 Formatting return object as decon2
#> 2025-04-17 14:51:52.69 Finished deconvolution of sim_02
#> 2025-04-17 14:51:52.69 Finished deconvolution of 2 spectra in 0.068 secs
aligned <- align(decons)
#> 2025-04-17 14:51:52.69 All requested packages are already installed.
#>
#>
#> --------------------------------
#> dohCluster will run with maxShift= 50
#> If you want dohCluster to detect the optimal maxShift automatically,
#> use dohCluster(..., maxShift = NULL, ...)
#> --------------------------------
#>
#> aligning spectrum 1
#> Median pearson correlation of aligned spectra: 0.9976321
#> Alignment time: 0.004066667 minutes
aligned
#> aligns object with 2 align elements
#> sim_01: align object (2048 dp, 3.6 to 3.3 ppm, 27 peaks)
#> sim_02: align object (2048 dp, 3.6 to 3.3 ppm, 30 peaks)