msDenoise {msProcess} | R Documentation |
Denoise spectra with various functions.
msDenoise(x, FUN="wavelet", attach.noise=TRUE, event="Denoising", ...)
x |
An object of class msSet . |
... |
Additional arguments to FUN .
They are passed unchanged to each call of FUN
and include their names.
See the help documentation of the specified FUN for details. |
FUN |
Either an object of class "character"
or of class "function" .
character: A character string denoting the method to use in denoising the data. Supported choices are "wavelet" for wavelet shrinkage,
"mrd" for partial summation of a wavelet-based
multiresolution decomposition,
and "smooth" for robust running medians.
Default: "wavelet" .
function: A user-defined function with an argument list of the form (x, ...) where x is a required argument
corresponding to a numeric vector (typically these values
will be the intensity values of a mass spectrum).
In either case, the additional arguments ... will be
passed directly to the specified FUN. |
attach.noise |
A logical indicating if the noise removed
should be attached or not. Default: TRUE . |
event |
A character string denoting the name of the
event to register with the (embedded) event history object of the input
after processing the input data. Default: "Denoising" . |
An object of class msSet
,
optionally, with the estimated noise attached as element "noise"
.
If FUN="mrd"
, an mrd
object containing meta information regarding
the multiresolution decomposition is attached to the msSet
output object for subsequent
use by other MRD-based function calls such as msPeak(x, FUN="mrd", ...
.
msDenoiseSmooth
, msDenoiseWavelet
, msDenoiseMRD
, matchObject
.
if (!exists("qcset")) data("qcset", package="msProcess") ## denoise a spectrum portion via waveshrink and a ## smoothing function mz <- (qcset$mz > 3000 & qcset$mz < 5000) data <- qcset[mz, 1, drop=FALSE] ## add a little Gaussian noise for illustration noise <- rnorm(length(data$intensity), sd=stdev(data$intensity)/3) xnoise <- data xnoise$intensity <- data$intensity + matrix(noise, ncol=1) ## denoise using the supported routines z1 <- msDenoise(xnoise, FUN="wavelet") z2 <- msDenoise(xnoise, FUN="smooth") z3 <- msDenoise(xnoise, FUN="mrd", levels=4:6) ## create a user-defined (albeit naive) denoising ## function my.fun <- function(x, wavelet="d4"){ filt <- wavDaubechies(wavelet=wavelet, norm=FALSE)$scaling return(filter(x, filt)) } z4 <- msDenoise(xnoise, FUN=my.fun, wavelet="s12") ## create a stackplot of the results z <- list(original=data$intensity[,1], noisy=xnoise$intensity[,1], waveshrink=z1$intensity[,1], smooth=z2$intensity[,1], mrd=z3$intensity[,1], "my function"=z4$intensity[,1]) wavStackPlot(z, col=seq(along=z), same.scale=TRUE)