rformassspectrometry / Spectra

Low level infrastructure to handle MS spectra
https://rformassspectrometry.github.io/Spectra/
34 stars 24 forks source link

Add scalePeaks function #291

Closed jorainer closed 1 year ago

jorainer commented 1 year ago

Add a function scalePeaks to scale intensities of all peaks within each spectrum either by the max intensity or the sum of intensities. The definition of the function could be:

scalePeaks <- function(x, msLevel = seq_len(4), by = sum, ...)

Parameter by could be the function to calculate the intensity by which individual intensities will be scaled. sum would mean all intensities get scaled by the sum of intensities within a spectrum (i.e. intensity <- intensity / sum(intensity).

Instead of calling the function scaleSpectra I would suggest to call it scalePeaks to make clear that peaks within spectra a scaled.