| msNoise {msProcess} | R Documentation |
Estimates the local noise level by applying a specified smoother function to the the noise data attached to the primary input variable.
msNoise(x, FUN="spline",
pre=abs, detach.noise=FALSE,
event="Local Noise Estimation", ...)
x |
An object of class msSet with an existing element "noise".
The noise element should be a matrix with the same dimensions
as the intensity data, such as that returned by the msDenoise
function. |
... |
Additional arguments to FUN.
They are passed unchanged to each call of FUN
and include their names.
See the help documentation of the specified routine for details. |
FUN |
Either an object of class "character"
or of class "function".
character: A character string denoting the method to use in smoothing the noise data. Supported choices are "spline", "supsmu", "ksmooth",
"loess", and "mean". Default: "spline".
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 noise estimates of a mass spectrum).
In either case, the additional arguments ... will be
passed directly to the specified routine. |
detach.noise |
A logical indicating if the noise removed previously
should be detached or not. Default: FALSE. |
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: "Local Noise Estimation". |
pre |
A function that is applied to the data prior to
processing it with the function defined by FUN. Default: abs. |
An object of class msSet with local noise estimate attached
as element "noise.local"
and optionally with the element "noise" detached.
if (!exists("qcset")) data("qcset", package="msProcess")
## denoise a noise contaminated spectrum portion
## via waveshrink
mz <- (qcset$mz > 3000 & qcset$mz < 5000)
data <- qcset[mz, 1, drop=FALSE]
noise <- rnorm(length(data$intensity), sd=stdev(data$intensity)/3)
xnoise <- data
xnoise$intensity <- data$intensity + matrix(noise, ncol=1)
z <- vector("list", length=4)
z[[1]] <- msDenoise(xnoise, FUN="wavelet")
## smooth the resulting noise estimates to form a
## localized estimate of the noise using
## various supported methods
z[[2]] <- msNoise(z[[1]], FUN="spline")
z[[3]] <- msNoise(z[[1]], FUN="loess")
## create a user-defined smoothing function
my.fun <- function(x, wavelet="d4"){
filt <- wavDaubechies(wavelet=wavelet, norm=FALSE)$scaling
return(filter(x, filt))
}
z[[4]] <- msNoise(z[[1]], FUN=my.fun, wavelet="s12")
## create a stackplot of the results
type <- c("noise", rep("noise.local", 3))
for (i in 1:4){
z[[i]] <- as.vector(z[[i]][[type[i]]])
}
names(z) <- c("noise","spline", "loess", "my function")
wavStackPlot(z, col=seq(along=z), same.scale=TRUE)