removeFreq | R Documentation |
This function removes specified frequencies from a Spectra
or Spectra2D
object.
For instance, one might want to remove regions lacking any useful
information (to reduce the data size), remove regions with large
interfering peaks (e.g. the water peak in 1H NMR) or simply focus
on a region of interest.
removeFreq(spectra, rem.freq = NULL, remF2 = NULL, remF1 = NULL)
spectra |
An object of S3 class |
rem.freq |
For a |
remF2 |
Applies to |
remF1 |
As for |
An object of S3 class ChemoSpec::Spectra()
or ChemoSpec2D::Spectra2D()
.
Regarding Spectra2D
objects, one cannot remove frequencies from the interior of
a 2D NMR data set and expect
to get a meaningful contour plot, because doing so puts unrelated peaks adjacent
in the data set. This would lead to contours being drawn that don't exist in the
original data set. However, one can remove data from the interior and run a PARAFAC
analysis on the result, using the spectrum as an abstract object (that is, the
spectrum may not plottable, but the resulting scores are still meaningful).
Bryan A. Hanson (DePauw University).
removeFreq
for another way to remove data.
if (checkForPackageWithVersion("ChemoSpec", 6.0)) {
library("ChemoSpec")
data(SrE.IR)
sumSpectra(SrE.IR)
# Examples where rem.freq is a logical vector
# Remove frequencies from one end:
newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 3500)
# Remove frequencies from both ends at once:
newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 3500
| SrE.IR$freq < 800)
# Remove frequencies from the middle:
newIR <- removeFreq(SrE.IR, rem.freq = SrE.IR$freq > 800
& SrE.IR$freq < 1000)
# The logic of this last one is as follows. Any values
# that are TRUE will be removed.
values <- 1:7
values > 2
values < 6
values > 2 & values < 6
# Examples where rem.freq is a formula
# Remove frequencies from one end:
newIR <- removeFreq(SrE.IR, rem.freq = 3500 ~ high)
# Remove frequencies from both ends is a two step process with formulas:
newIR <- removeFreq(SrE.IR, rem.freq = 3500 ~ high)
newIR <- removeFreq(newIR, rem.freq = low ~ 800)
# Remove frequencies from the middle:
newIR <- removeFreq(SrE.IR, rem.freq = 800 ~ 1000)
# After any of these, inspect the results:
sumSpectra(newIR)
}
if (checkForPackageWithVersion("ChemoSpec2D", 0.5)) {
library("ChemoSpec2D")
# Note we will set contours a bit low to better
# show what is going on.
data(MUD1)
plotSpectra2D(MUD1, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7: Complete Data Set")
MUD1a <- removeFreq(MUD1, remF2 = 2.5 ~ 4)
sumSpectra(MUD1a) # don't plot, removing peaks from interior is misleading
MUD1b <- removeFreq(MUD1, remF2 = low ~ 2)
sumSpectra(MUD1b)
plotSpectra2D(MUD1b, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7\nRemoved Peaks: F2 low ~ 2")
MUD1c <- removeFreq(MUD1, remF1 = high ~ 23)
sumSpectra(MUD1c)
plotSpectra2D(MUD1c, which = 7, lvls = 0.1, cols = "black",
main = "MUD1 Sample 7\nRemoved Peaks: F1 high ~ 23")
MUD1d <- removeFreq(MUD1, remF2 = 2.5 ~ 4, remF1 = 45 ~ 55)
sumSpectra(MUD1d) # don't plot, removing peaks from interior is misleading
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.