reference: MassPeaks, reference object to which the samples (l) should be aligned. If missing referencePeaks is used.
tolerance: double, maximal relative deviation of a peak position (mass) to be considered as identical. Must be multiplied by 10^-6 for ppm, e.g. use tolerance=5e-6 for 5 ppm.
method: used basic warping function.
allowNoMatches: logical, don't throw an error if an MassPeaks
object could not match to the reference.
plot: logical, if TRUE a warping plot is drawn for each sample.
plotInteractive: logical, if FALSE a non-interactive device (e.g. pdf) is used for warping plots.
...: arguments to be passed to warpingFunction
Details
warpingFunction: determineWarpingFunctions estimates a warping function to overcome the difference between mass in reference and in the current sample. To calculate the differences each reference peak would match with the highest sample peak in the nearer neighborhood (defined by mass of reference peak*tolerance).
allowNoMatches: If allowNoMatches is TRUE a warning instead of an error is thrown if an MassPeaks
object could not match to the reference. The returned list of warping functions will contain NA for this object (same index in the list). plotInteractive: If plot is TRUE a lot of output is created (each sample in l gets its own plot). That's why an non-interactive devices is recommended:
## create a device
pdf()
## calculate warping functions
w <- determineWarpingFunctions(p, plot=TRUE)
## close device
dev.off()
Returns
Returns a list of individual warping functions. The attribute nmatch contains the number of matches of each MassPeaks element in l against reference.
## load packagelibrary("MALDIquant")## create a reference MassPeaks objectr <- createMassPeaks(mass=1:5, intensity=1:5)## create test samplesp <- list(createMassPeaks(mass=((1:5)*1.01), intensity=1:5), createMassPeaks(mass=((1:5)*0.99), intensity=1:5))## create an interactive device with 2 rowspar(mfrow=c(2,1))## calculate warping function## (using a linear function as basic warping function)## and show warping plotw <- determineWarpingFunctions(p, tolerance=0.02, method="linear", plot=TRUE, plotInteractive=TRUE)par(mfrow=c(1,1))## access number of matchesattr(w,"nmatch")## w contains the individual warping functionswarpedPeaks <- warpMassPeaks(p, w)## compare resultsall(mass(r)== mass(warpedPeaks[[1]]))# TRUEall(mass(r)== mass(warpedPeaks[[2]]))# TRUE## realistic example## load example datadata("fiedler2009subset", package="MALDIquant")## running typical workflow## use only four spectra of the subsetspectra <- fiedler2009subset[1:4]## transform intensitiesspectra <- transformIntensity(spectra, method="sqrt")## smooth spectraspectra <- smoothIntensity(spectra, method="MovingAverage")## baseline correctionspectra <- removeBaseline(spectra)## detect peakspeaks <- detectPeaks(spectra)## create an interactive device with 2 rowspar(mfrow=c(4,1))## calculate warping functions (using LOWESS based basic function [default])w <- determineWarpingFunctions(peaks, plot=TRUE, plotInteractive=TRUE)par(mfrow=c(1,1))## realistic example with user defined reference/calibration peaks## use the workflow above for fiedler2009subset## create reference peaksrefPeaks <- createMassPeaks(mass=c(1207,1264,1351,1466,1616,2769,2932,3191,3262,4091,4209,5904,7762,9285), intensity=rep(1,14))## create an interactive device with 2 rowspar(mfrow=c(4,1))## calculate warping functions (using a quadratic function as basic function)w <- determineWarpingFunctions(peaks, reference=refPeaks, method="quadratic", plot=TRUE, plotInteractive=TRUE)par(mfrow=c(1,1))