msDenoiseMRD {msProcess} | R Documentation |
Forms a multiresolution decomposition (MRD) by taking a specified discrete wavelet transform of the input spectrum and subsequently inverting each level of the transform back to the "time" domain. The resulting components of the MRD form an octave-band decomposition of the original spectrum, and can be summed together to reconstruct the original spectrum. Summing only a subset of these components can be viewed as a denoising operation if the "noisy" components are excluded from the summation.
msDenoiseMRD(x, wavelet="s8", levels=1, xform="modwt", reflect=TRUE, keep.smooth=TRUE, keep.details=TRUE, process="msDenoiseMRD")
x |
A vector containing a uniformly-sampled real-valued time series. |
keep.details |
A logical value. If TRUE , the details
corresponding to the specified levels are included in the partial summation
over the MRD components. The user also has the choice to
exclude the smooth in the summation via the keep.smooth option,
but one of keep.details and keep.smooth must be TRUE .
Default: TRUE . |
keep.smooth |
A logical value. If TRUE , the smooth
at the last decomposition level is added to the partial summation
over specified details. The smooth typically contains low-frequency trends present in
a spectrum, so removing the smooth (keep.smooth=FALSE ) will result
in removing the trend in such cases. The user also has the choice to
exclude the details in the summation via the keep.details option,
but one of keep.details and keep.smooth must be TRUE .
Default: TRUE . |
levels |
An integer vector of integers denoting the MRD detail(s) to sum over in forming
a denoised approximation to the orginal spectrum (the summation is performed across scale and nto across time).
All values must be positive integers,
and cannot exceed floor(logb(length(x),2)) if reflect=FALSE and, if reflect=TRUE , cannot exceed
floor(logb((length(x)-1)/(L-1) + 1, b=2)) where L is the length of the wavelet filter. Use
the keep.smooth option to also include the last level's smooth in the summation.
Default: 1. |
process |
A character string denoting the name of the
process to register with the (embedded) event history object of the input
after processing the input data. This process is not updated if it
already exists in the event history. Default: "msDenoiseMRD" . |
reflect |
A logical value. If TRUE , the
last Lj = (2^n.level - 1)(L - 1) + 1
coefficients of the series are reflected (reversed and appended to the end
of the series) in order to attenuate the adverse effect of circular
filter operations on wavelet transform coefficients for
series whose endpoint levels are (highly) mismatched.
The variable Lj represents the effective filter length at
decomposition level n.level , where L
is the length of the wavelet (or scaling) filter.
A similar operation is performed at the beginning of the series.
After synthesis and (partial) summation of the resulting details
and smooth, the middle N points of the result are returned, where N is the length
of the original time series.
Default: TRUE . |
wavelet |
A character string denoting the filter type.
See wavDaubechies for details. Default: "s8". |
xform |
A character string denoting the wavelet transform type.
Choices are "dwt" and "modwt" for the discrete wavelet transform (DWT)
and maximal overlap DWT (MODWT), respectively. The DWT is a decimated transform
where (at each level) the number of transform coefficients is halved. Given
N is the length of the original time series, the total
number of DWT transform coefficients is N.
The MODWT is a non-decimated transform where the number of
coefficients at each level is N and the total number of
transform coefficients is N*n.level . Unlike the DWT, the MODWT
is shift-invariant and is seen as a weighted average of all possible
non-redundant shifts of the DWT. See the references for details.
Default: "modwt" . |
Performs a level J decimated or undecimated discrete wavelet transform on the input series and inverts the transform at each level separately to produce details D1,...,DJ and smooth SJ. The decomposition is additive such that the original series X may be reconstructed ala X=D1 + D2 + ... DJ + SJ. As the effective wavelet filters at level j are nominally associated with approximate band pass filters, the details Dj correspond approximately to normalized frequencies on the interval [1/2^(j+1), 1/2^j], while the content of the smooth SJ corresponds approximately to normalized frequencies [0, 1/2^(J+1)]. The collection of details and smooth form a multiresolution decomposition (MRD).
With the intent of removing unwanted noise events,
a summation over a subset of MRD components may be
calculated yielding a smooth approximation to the
original spectrum. For example, summing all MRD components
beyond D1 is tantamount to a low-pass filtering
of the original spectrum (whether or not this is a relevant
and sufficient noise removal technique is left to the discretion
of the practitioner). This function allows the user to specify
the decomposition levels they wish to sum over in order to form
a multiresolution approximation. The inclusion of the last level's smooth
in the summation is controlled by the optional keep.smooth
argument.
The user may also select either a decimated wavelet transform (DWT) or an undecimated wavelet transform (MODWT). However, we recommend that the user stick with the MODWT for the following reasons:
A vector containing the denoised series.
D. B. Percival and A. T. Walden, Wavelet Methods for Time Series Analysis, Cambridge University Press, 2000.
T.W. Randolph and Y. Yasui, Multiscale Processing of Mass Spectrometry Data, Biometrics, 62:589–97, 2006.
T.W. Randolph, Scale-based normalization of spectral data, Disease Biomarkers, 2:135–144, 2006.
msDenoise
, msDenoiseWaveletThreshold
, msNoise
,
wavDaubechies
, wavDWT
, wavMODWT
,
wavMRD
, msSmoothLoess
, msSmoothSpline
,
msSmoothKsmooth
, msSmoothSupsmu
, msSmoothApprox
,
msDenoiseSmooth
, eventHistory
.
if (!exists("qcset")) data("qcset", package="msProcess") ## obtain a subset of a mass spectrum and add some ## noise x <- qcset$intensity[5000:7000,1] sd.noise <- 2 set.seed(100) xnoise <- x + rnorm(length(x), sd=sd.noise) mz <- as.matrix(as.numeric(names(x))) ## define two different ranges of summation levels lev1 <- 6:8 lev2 <- 4:8 ## calculate MODWT MRDs over these levels z1 <- msDenoiseMRD(xnoise, levels=lev1) z2 <- msDenoiseMRD(xnoise, levels=lev2) ## plot the results Slab <- "S8" lab1 <- paste(paste("D", lev1, sep="", collapse="+"), Slab, sep="+") lab2 <- paste(paste("D", lev2, sep="", collapse="+"), Slab, sep="+") msPlot(matlines=list( list(x=mz, y=cbind(z1, z2), lty=1, lwd=3), list(x=mz, y=cbind(xnoise, xnoise), type="p", pch="o", cex=0.15)), yref=FALSE, xlab="m/z", ylab="MODWT MRD", text=list(x=rep(8300,2), y=c(2300,1650), labels=c(lab2,lab1), adj=0, col=2:1))