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.
method
used basic warping function.
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). 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()
## load package
library("MALDIquant")
## create a reference MassPeaks object
r <- createMassPeaks(mass=1:5, intensity=1:5)
## create test samples
p <- 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 rows
par(mfrow=c(2, 1))
## calculate warping function
## (using a linear function as basic warping function)
## and show warping plot
w <- determineWarpingFunctions(p, tolerance=0.02, method="linear",
plot=TRUE, plotInteractive=TRUE)
par(mfrow=c(1, 1))
## w contains the individual warping functions
warpedPeaks <- warpMassPeaks(p, w)
## compare results
all(mass(r) == mass(warpedPeaks[[1]])) # TRUE
all(mass(r) == mass(warpedPeaks[[2]])) # TRUE
## realistic example
## load example data
data("fiedler2009subset", package="MALDIquant")
## running typical workflow
## use only four spectra of the subset
spectra <- fiedler2009subset[1:4]
## transform intensities
spectra <- transformIntensity(spectra, method="sqrt")
## smooth spectra
spectra <- smoothIntensity(spectra, method="MovingAverage")
## baseline correction
spectra <- removeBaseline(spectra)
## detect peaks
peaks <- detectPeaks(spectra)
## create an interactive device with 2 rows
par(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 peaks
refPeaks <- 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 rows
par(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))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MALDIquant)
This is MALDIquant version 1.15
Quantitative Analysis of Mass Spectrometry Data
See '?MALDIquant' for more information about this package.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MALDIquant/determineWarpingFunctions-functions.Rd_%03d_medium.png", width=480, height=480)
> ### Name: determineWarpingFunctions
> ### Title: Determine warping functions of MassPeaks objects.
> ### Aliases: determineWarpingFunctions
> ### Keywords: methods
>
> ### ** Examples
>
> ## load package
> library("MALDIquant")
>
> ## create a reference MassPeaks object
> r <- createMassPeaks(mass=1:5, intensity=1:5)
>
> ## create test samples
> p <- 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 rows
> par(mfrow=c(2, 1))
> ## calculate warping function
> ## (using a linear function as basic warping function)
> ## and show warping plot
> w <- determineWarpingFunctions(p, tolerance=0.02, method="linear",
+ plot=TRUE, plotInteractive=TRUE)
Warning message:
In determineWarpingFunctions(p, tolerance = 0.02, method = "linear", :
Reference MassPeaks object contains very few peaks (n == 5). The warping could be instable. Consider to reduce 'minFrequency' or/and to increase 'tolerance'.
> par(mfrow=c(1, 1))
>
> ## w contains the individual warping functions
> warpedPeaks <- warpMassPeaks(p, w)
>
> ## compare results
> all(mass(r) == mass(warpedPeaks[[1]])) # TRUE
[1] FALSE
> all(mass(r) == mass(warpedPeaks[[2]])) # TRUE
[1] FALSE
>
>
>
> ## realistic example
>
> ## load example data
> data("fiedler2009subset", package="MALDIquant")
>
> ## running typical workflow
>
> ## use only four spectra of the subset
> spectra <- fiedler2009subset[1:4]
>
> ## transform intensities
> spectra <- transformIntensity(spectra, method="sqrt")
>
> ## smooth spectra
> spectra <- smoothIntensity(spectra, method="MovingAverage")
>
> ## baseline correction
> spectra <- removeBaseline(spectra)
>
> ## detect peaks
> peaks <- detectPeaks(spectra)
>
> ## create an interactive device with 2 rows
> par(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 peaks
> refPeaks <- 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 rows
> par(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))
>
>
>
>
>
>
> dev.off()
null device
1
>