getWaveletPeaks: Convert raw NMR spectra to peak data by using wavelets

View source: R/getWaveletPeaks.R

getWaveletPeaksR Documentation

Convert raw NMR spectra to peak data by using wavelets

Description

This function converts phase corrected NMR spectra to peak data by using wavelet based peak detection (with the MassSpecWavelet package)

Usage

getWaveletPeaks(
  Y.spec,
  X.ppm,
  sample.labels = NULL,
  window.width = "small",
  window.split = 4,
  scales = seq(1, 16, 1),
  baselineThresh = 1000,
  SNR.Th = -1,
  nCPU = -1,
  include_nearbyPeaks = TRUE,
  raw_peakheight = FALSE,
  duplicate_detection_multiplier = 1
)

Arguments

Y.spec

The spectra in matrix format (rows = samples, columns = measurement points ).

X.ppm

The x/ppm values of the spectra (in single vector or matrix format).

sample.labels

The sample labels (optional), if not supplied these will simply be the sample numbers.

window.width

The width of the detection window for the wavelets. Because of the Fourier transform lengths of 512 ( window.width = 'small') of 1024 ( window.width = 'large') are preferable.

window.split

A positive, even and whole number indicating in how many parts the sliding window is split up. With every iteration the window slides one part further.

scales

The scales to be used in the wavelet based peak detection, see peakDetectionCWT.

baselineThresh

Peaks with a peakValue lower than this threshold will be removed (default = 1000).

SNR.Th

The Signal-to-noise threshold, see peakDetectionCWT.

nCPU

The amount of cpu's to be used for peak detection. If set to '-1' all available cores minus 1 will be used.

include_nearbyPeaks

If set to TRUE small peaks in the tails of larger ones will be included in the peak data, see peakDetectionCWT.

raw_peakheight

(default = FALSE) Whether to use the raw peak height of a peak instead of the optimal CWT coefficient (which is a measure for AUC).

duplicate_detection_multiplier

(default 1) In case users want to process other spectra besides NMR, this parameter will increase the limit for two peaks to be considered a duplicate detection. When dealing with more distorted spectra this parameter can be increased (recommended to not increase above 10).

Value

The peaks detected with the wavelets.

Author(s)

Charlie Beirnaert, charlie.beirnaert@uantwerpen.be

Examples

subset <- GetWinedata.subset()
# to reduce the example time we only select spectra 1 & 2
subset.spectra = as.matrix(subset$Spectra)[1:2,] 
subset.ppm = as.numeric(subset$PPM)

test.peaks <- getWaveletPeaks(Y.spec=subset.spectra, 
                              X.ppm=subset.ppm ,
                              nCPU = 1) # nCPU set to 2 for the vignette build


speaq documentation built on May 23, 2022, 5:06 p.m.