nmr_baseline_threshold: Threshold estimation for peak detection

View source: R/nmr_baseline_threshold.R

nmr_baseline_thresholdR Documentation

Threshold estimation for peak detection

Description

Estimates the threshold value for peak detection on an nmr_dataset_1D object by examining a range without peaks, by default the 9.5 - 10 ppm range.

Usage

nmr_baseline_threshold(
  nmr_dataset,
  range_without_peaks = c(9.5, 10),
  method = c("mean3sd", "median3mad")
)

Arguments

nmr_dataset

An nmr_dataset_1D.

range_without_peaks

A vector with two doubles describing a range without peaks suitable for baseline detection

method

Either "mean3sd" or the more robust "median3mad". See the details.

Details

Two methods can be used:

  • "mean3sd": The mean3sd method computes the mean and the standard deviation of each spectrum in the 9.5 - 10 ppm range. The mean spectrum and the mean standard deviation are both vectors of length equal to the number of points in the given range. The mean of the mean spectrum the noise. The threshold is defined as ⁠center + 3 dispersion⁠, and it is one single threshold for the whole dataset. This is the default for backwards compatibility.

  • "median3mad": First we take the data matrix. If we have estimated a baseline already, subtract it. In the defined region without peaks, estimate the median of each sample and its median absolute deviation. Return a vector of length equal to the number of samples with the ⁠median+3mad⁠ for each sample. This is a new more robust method.

Value

Numerical. A threshold value in intensity below that no peak is detected.

See Also

Other peak detection functions: Pipelines, nmr_detect_peaks(), nmr_detect_peaks_plot(), nmr_detect_peaks_plot_overview(), nmr_detect_peaks_tune_snr(), nmr_identify_regions_blood(), nmr_identify_regions_cell(), nmr_identify_regions_urine(), nmr_integrate_regions()

Examples

ppm_axis <- seq(from = 0, to = 10, length.out = 1000)
data_1r <- matrix(runif(1000, 0, 10), nrow = 1) + 100
dataset_1D <- new_nmr_dataset_1D(
    ppm_axis = ppm_axis,
    data_1r = data_1r,
    metadata = list(external=data.frame(NMRExperiment = "10"))
)
bl_threshold <- nmr_baseline_threshold(dataset_1D, range_without_peaks = c(9.5,10))


sipss/AlpsNMR documentation built on Aug. 13, 2024, 5:11 p.m.