Skip to content

Suggest adding rtCenterFun and mzCenterFun options in groupChromPeaks / PeakDensityParam #823

@DrRuiLi

Description

@DrRuiLi

When using xcms to group peaks with PeakDensityParam, the resulting feature RT is currently calculated as the median of the grouped peaks. In datasets where:

  • Low-intensity peaks are present in most samples, and
  • High-intensity peaks are present in fewer samples,

the median RT can be pulled away from the major (intense) peaks, resulting in inaccurate feature RT assignments.

Example:

  • 30 samples
  • 20 small peaks around 910 s (low intensity, present in most samples)
  • Major peaks around 870 s (high intensity, 1000× stronger, present in 10 samples)

Current behavior: grouped feature RT → ~903 s (median of all peaks), which does not reflect the major peak RT.

Current workaround:
For m/z in CentWaveParam, there is mzCenterFun = "wMean" to calculate an intensity-weighted m/z, but no equivalent parameter exists for MZ or RT in PeakDensityParam.

Suggestion:
Add rtCenterFun and optionally mzCenterFun parameters to PeakDensityParam / groupChromPeaks with options like:

  • "median" (current default)
  • "mean"
  • "wMean" (weighted by intensity)

This would allow feature RT (and optionally m/z) to better reflect major/intense peaks, improving grouping accuracy, especially in heterogeneous datasets.

Benefits:

  • Prevents feature RT from being skewed by numerous low-intensity peaks
  • Makes grouped features more representative of biologically relevant peaks
  • Consistent interface with CentWaveParam’s mzCenterFun

Note on relationship to bw:

The proposed rtCenterFun parameter is independent of bw. While bw controls the density bandwidth and thus whether peaks are merged or split

  • Increasing bw → broader grouping → risk merging distinct peaks
  • Decreasing bw → narrower grouping → risk splitting the same peak across groups

rtCenterFun would only determine how the RT of an already grouped feature is calculated (e.g., median, mean, intensity-weighted mean). This allows users to maintain their desired grouping behavior without being forced to adjust bw to compensate for RT skew caused by uneven peak intensities.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions