sweep {hyperSpec} | R Documentation |
sweep
for hyperSpec
objects.
## S4 method for signature 'hyperSpec': sweep(x, MARGIN, STATS, FUN = "-", check.margin = TRUE, ..., short = NULL, user = NULL, date = NULL)
x |
a hyperSpec object. |
MARGIN |
direction of the spectra matrix that STATS goees along. |
STATS |
the summary statistic to sweep out. Either a vector or a
hyperSpec object. |
FUN |
the function to do the sweeping, e.g. `-` or `/`. |
check.margin |
If TRUE (the default), warn if the length or
dimensions of STATS do not match the specified dimensions
of x . Set to FALSE for a small speed gain when you
know that dimensions match. |
... |
further arguments for FUN |
short, user, date |
handed over to logentry . |
Calls sweep
for the spectra matrix.
sweep
is useful for some spectra preprocessing, like
offset correction, substraction of background spectra, and
normalization of the spectra.
A hyperSpec
object.
C. Beleites
## Substract the background / slide / blank spectrum # the example data does not have spectra of the empty slide, # so instead the overall composition of the sample is substracted background <- apply (chondro, 2, quantile, probs = 0.05) corrected <- sweep (chondro, 2, background, "-") plot (corrected, "spcprctl5") ## Offset correction offsets <- apply (chondro, 1, min) corrected <- sweep (chondro, 1, offsets, "-") plot (corrected, "spcprctl5") ## Min-max normalization (on max amide I) # the minimum is set to zero by the offset correction. factor <- apply (corrected, 1, max) corrected <- sweep (corrected, 1, factor, "/") plot (corrected, "spcprctl5")