R/smoothIntensity-methods.R

## AbstractMassObject
setMethod(f="smoothIntensity",
          signature=signature(object="MassSpectrum"),
          definition=function(object,
                              method=c("SavitzkyGolay", "MovingAverage"),
                              halfWindowSize, ...) {
  ## empty spectrum?
  if (.isEmptyWarning(object)) {
    return(object)
  }

  method <- match.arg(method)

  fun <- switch(method,
                "SavitzkyGolay" = {
                  if (missing(halfWindowSize)) {
                    halfWindowSize <- 10L
                  }
                  .savitzkyGolay
                },
                "MovingAverage" = {
                  if (missing(halfWindowSize)) {
                    halfWindowSize <- 2L
                  }
                  .movingAverage
                }
  )

  .transformIntensity(object, fun=fun, halfWindowSize=halfWindowSize, ...)
})

## list
setMethod(f="smoothIntensity",
          signature=signature(object="list"),
          definition=function(object, ...) {

  ## test arguments
  .stopIfNotIsMassSpectrumList(object)

  .mapply(smoothIntensity, object, ...)
})

Try the MALDIquant package in your browser

Any scripts or data that you put into this service are public.

MALDIquant documentation built on May 29, 2024, 6:11 a.m.