Skip to contents

Diagnose SNR threshold in peak detection

Usage

nmr_detect_peaks_tune_snr(
  ds,
  NMRExperiment = NULL,
  SNR_thresholds = seq(from = 2, to = 6, by = 0.1),
  ...
)

Arguments

ds

An nmr_dataset_1D dataset

NMRExperiment

A string with the single NMRExperiment used explore the SNR thresholds. If not given, use the first one.

SNR_thresholds

A numeric vector with the SNR thresholds to explore

...

Arguments passed on to nmr_detect_peaks

nmr_dataset

An nmr_dataset_1D.

nDivRange_ppm

Segment size, in ppms, to divide the spectra and search for peaks.

baselineThresh

All peaks with intensities below the thresholds are excluded. Either:

  • A numeric vector of length the number of samples. Each number is a threshold for that sample

  • A single number. All samples use this number as baseline threshold.

  • NULL. If that's the case, a default function is used (nmr_baseline_threshold()), which assumes that there is no signal in the region 9.5-10 ppm.

range_without_peaks

A numeric vector of length two with a region without peaks, only used when baselineThresh = NULL

fit_lorentzians

If TRUE, fit a lorentzian to each detected peak, to infer its inflection points. For now disabled for backwards compatibility.

verbose

Logical (TRUE or FALSE). Show informational messages, such as the estimated baseline

scales

The parameter of peakDetectionCWT function of MassSpecWavelet package, look it up in the original function.

SNR.Th

The parameter of peakDetectionCWT function of MassSpecWavelet package, look it up in the original function. If you set -1, the function will itself re-compute this value.

Value

A list with the following elements:

  • peaks_detected: A data frame with the columns from the nmr_detect_peaks output and an additional column SNR_threshold with the threshold used on each row.

  • num_peaks_per_region: A summary of the peaks_detected table, with the number of peaks detected on each chemical shift region

  • plot_num_peaks_per_region: A visual representation of num_peaks_per_region

  • plot_spectrum_and_detections: A visual representation of the spectrum and the peaks detected with each SNR threshold. Use plotly::ggplotly or plot_interactive on this to zoom and explore the results.