Learn R Programming

MALDIquant (version 0.2)

.estimateBaselineMovingEstimator: Estimates the baseline by moving estimators.

Description

This function estimates the baseline of mass spectrometry data. The baseline estimation is based on different estimators which are used in a moving window. It is hidden by NAMESPACE because it is a private function and estimateBaseline,SingleSpectrum-method should be used instead.

Usage

.estimateBaselineMovingEstimator(x, y, 
    windowSize=0.04, relativeWindowSize=TRUE,
    fun=median)

Arguments

x
vector of x values
y
vector of y values
windowSize
size of the moving window for the estimator function. If relativeWindowSize is TRUE the window is created windowSize/2*100% left and right of the current mass-to-charge value. E.g. on 1000 Da the w
relativeWindowSize
logical, use relative window size based on mass-to-charge ratio or use fixed window size.
fun
used estimator (default: median; min, quantile or something else would be possible, too)

Value

  • Returns a two column matrix (first column: mass, second column: intensity) of the estimated baseline.

See Also

SingleSpectrum, estimateBaseline,SingleSpectrum-method, removeBaseline,SingleSpectrum-method

Examples

Run this code
## load library
library("MALDIquant");

## load readBrukerFlexData library for fid file import 
## (is also done automatically by importSingleSpectrum)
library("readBrukerFlexData");

## get examples directory
exampleDirectory <- system.file("Examples", package="readBrukerFlexData");

## read example spectrum
s <- importSingleSpectrum(file.path(exampleDirectory,
    "2010_05_19_Gibb_C8_A1/0_A1/1/1SLin/fid"));

## plot spectrum
plot(s);

## estimate different baselines
b1 <- estimateBaseline(s, method="MovingEstimator");
b2 <- estimateBaseline(s, method="MovingEstimator", windowSize=201,
                       relativeWindowSize=FALSE, fun=min);

## draw baselines on the plot
lines(b1, col=2);
lines(b2, col=3);

## draw legend
legend(x="topright", lwd=1, legend=c("median", "min"), col=c(2, 3));

Run the code above in your browser using DataLab