## load library
library("MALDIquant");
## load example data
data("fiedler2009subset", package="MALDIquant");
## choose only a smaller subset
spectra <- fiedler2009subset[1:2];
## show some information
spectra
## running typical workflow
## transform intensities
t <- transformIntensity(spectra, fun=sqrt);
## smoothing function
movingAvg <- function(y) {
ma <- rep(1, 5)/5;
return(filter(y, ma, sides=2));
}
## smooth spectra
s <- transformIntensity(t, fun=movingAvg);
## baseline correction
b <- removeBaseline(s);
## detect peaks
p <- detectPeaks(b);
## plot results
par(mfcol=c(3, length(spectra)));
for (i in seq(along=spectra)) {
plot(spectra[[i]], main="raw spectrum");
plot(s[[i]], main="transformed (sqrt) and smoothed (ma5)");
plot(b[[i]], main="baseline removed and peaks detected");
points(p[[i]], pch=4, col=2);
}
par(mfrow=c(1, 1));
## bin peaks
bp <- binPeaks(p);
## show intensity matrix
intensityMatrix(bp);Run the code above in your browser using DataLab