rformassspectrometry / Spectra

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

passing additional parameters to filterIntensity #164

Closed ococrook closed 3 years ago

ococrook commented 3 years ago

The vignette suggest you can pass a function to "filterIntensity" which is great. Though ?filterIntensity doesn't seem to have any example at the moment but I'm sure there was one before which inspired my question

I would like to filter out low_intensities, this works exactly as intended

# function to filter out intensity smaller than the 5% of max intensity
low_int <- function(x, percentage = 0.05) {
  x > max(x, na.rm = TRUE) * percentage
}

filterIntensity(mySpectraObject, low_int) 

Now I might want my intensity filtering to be adaptive and so passing a value to low_int without recreating the function. That is it would be nice to be able to pass additional arguments to that function ...

filterIntensity(mySpectraObject, low_int, percentage = 0.01)

or

filterIntensity(mySpectraObect, low_int, methargs = list(percentage = 0.01))

Might be too much effort, but would be useful personally

jorainer commented 3 years ago

This has now also been added to the BioC 3.12 version of Spectra. Please close the issue if it works for you @ococrook