Detects regions of interest with peaks in a sample.

findPeaksImpl(
  drift_time,
  retention_time,
  int_mat,
  verbose = FALSE,
  dt_length_ms = 0.07,
  rt_length_s = 8,
  dt_peakwidth_range_ms = c(0.15, 0.4),
  rt_peakwidth_range_s = c(10, 25),
  dt_peakDetectionCWTParams = list(exclude0scaleAmpThresh = TRUE),
  rt_peakDetectionCWTParams = list(exclude0scaleAmpThresh = TRUE),
  dt_extension_factor = 0,
  rt_extension_factor = 0,
  exclude_rip = FALSE,
  iou_overlap_threshold = 0.2,
  debug_idx = list(dt = NULL, rt = NULL)
)

Arguments

drift_time

The drift time vector

retention_time

The retention time vector

int_mat

The intensity matrix, of dimensions length(drift_time) rows and length(retention_time) columns

verbose

If TRUE information will be printed on screen

dt_length_ms, rt_length_s

Length of the filters used to compute the second derivative. See details.

dt_peakwidth_range_ms, rt_peakwidth_range_s

A vector of length 2 with the minimum and maximum peak width. See details

dt_peakDetectionCWTParams, rt_peakDetectinoCWTParams

Additional parameters to MassSpecWavelet::peakDetectionCWT(). See details

exclude_rip

Whether to exclude ROIs with a drift time apex smaller than the RIP drift time end.

iou_overlap_threshold

A number, between 0 and 1. Pairs of ROIs with an intersection over union larger than this threshold are merged.

debug_idx

A list with two numeric vectors named dt and rt each of them having a the indices to where debug info is kept

Value

A list with the peak_list and debug_info elements.

Details

Peaks are detected on the intensity matrix.

In detail, the approach is as follows:

  1. We compute the second derivative with respect to the drift and retention times.

  2. Based on the given peak width ranges, mexican hat wavelets are scaled

  3. Peaks are detected using MassSpecWavelet::peakDetectionCWT().

  4. We intersect the maxima to discard saddle points

  5. We merge similar ROIs using a threshold on the intersection over union

  6. Get some ROI metrics and return.

For the MassSpecWavelet-based peak detection, the scales are computed based on the requested peak widths. Besides, the scales, further tuning beyond the MassSpecWavelet defaults is possible through the *_peakDetectionCWTParams argument. By default, the only change we introduce is the exclude0scaleAmpThresh = TRUE which is a reasonable peak detection setting not enabled in MassSpecWavelet for backwards compatibility reasons.