Standard preprocessing of response matrices where the first axis is a
time axis, and the second a spectral axis. An example is HPLC-DAD
data. For smooth data, like UV-VIS data, there is the option to
decrease the size of the matrix by interpolation. By default, the data
are baseline-corrected in the time direction and smoothed in the
spectral dimension.
A numerical data matrix, missing values are not allowed. If
rownames or colnames attributes are used, they should be numerical
and signify time points and wavelengths, respectively.
dim1
A new, usually shorter, set of time points (numerical). The
range of these should not be outside the range of the original time
points, otherwise the function stops with an error message.
dim2
A new, usually shorter, set of wavelengths (numerical). The
range of these should not be outside the range of the original
wavelengths, otherwise the function stops with an error message.
remove.time.baseline
logical, indicating whether baseline
correction should be done in the time direction. Default is TRUE.
spec.smooth
logical, indicating whether smoothing should be
done in the spectral direction. Default is TRUE.
maxI
if given, the maximum intensity in the matrix is set to
this value.
...
further optional arguments to the baseline.corr
function.
Value
The function returns the preprocessed data matrix, with rownames and
colnames indicating the time points and wavelengths, respectively.
Author(s)
Ron Wehrens
Examples
data(tea)
tpoints <- as.numeric(rownames(tea.raw[[1]]))
lambdas <- as.numeric(colnames(tea.raw[[1]]))
## limit retention time and wavelength ranges, and do smoothing and
## baseline correction
new.time <- seq(13, 14.1, by = .05)
new.wavelengths <- seq(400, 500, by = 2)
tea.raw1.processed <-
preprocess(tea.raw[[1]], dim1 = new.time, dim2 = new.wavelengths)
plot(tpoints, tea.raw[[1]][,lambdas == 470],
xlim = range(new.time), type = "l", col = "gray",
main = "Chromatogram at 470 nm", xlab = "Time (min.)",
ylab = "")
lines(new.time, tea.raw1.processed[,new.wavelengths == 470], col = "red")
legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
legend = c("Original data", "Preprocessed data"))
plot(lambdas, tea.raw[[1]][tpoints == 13.7,],
xlim = range(new.wavelengths),
ylim = c(0, max(tea.raw[[1]][tpoints == 13.7,])),
type = "l", col = "gray",
main = "Spectrum at 13.7 min.", xlab = expression(lambda),
ylab = "")
lines(new.wavelengths, tea.raw1.processed[new.time == 13.7,], col = "red")
legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
legend = c("Original data", "Preprocessed data"))
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(alsace)
Loading required package: ALS
Loading required package: nnls
Loading required package: Iso
Iso 0.0-17
Loading required package: ptw
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/alsace/preprocess.Rd_%03d_medium.png", width=480, height=480)
> ### Name: preprocess
> ### Title: Preprocessing smooth time-wavelength data
> ### Aliases: preprocess
> ### Keywords: manip
>
> ### ** Examples
>
> data(tea)
> tpoints <- as.numeric(rownames(tea.raw[[1]]))
> lambdas <- as.numeric(colnames(tea.raw[[1]]))
>
> ## limit retention time and wavelength ranges, and do smoothing and
> ## baseline correction
> new.time <- seq(13, 14.1, by = .05)
> new.wavelengths <- seq(400, 500, by = 2)
> tea.raw1.processed <-
+ preprocess(tea.raw[[1]], dim1 = new.time, dim2 = new.wavelengths)
>
> plot(tpoints, tea.raw[[1]][,lambdas == 470],
+ xlim = range(new.time), type = "l", col = "gray",
+ main = "Chromatogram at 470 nm", xlab = "Time (min.)",
+ ylab = "")
> lines(new.time, tea.raw1.processed[,new.wavelengths == 470], col = "red")
> legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
+ legend = c("Original data", "Preprocessed data"))
>
> plot(lambdas, tea.raw[[1]][tpoints == 13.7,],
+ xlim = range(new.wavelengths),
+ ylim = c(0, max(tea.raw[[1]][tpoints == 13.7,])),
+ type = "l", col = "gray",
+ main = "Spectrum at 13.7 min.", xlab = expression(lambda),
+ ylab = "")
> lines(new.wavelengths, tea.raw1.processed[new.time == 13.7,], col = "red")
> legend("topleft", lty = 1, col = c("gray", "red"), bty = "n",
+ legend = c("Original data", "Preprocessed data"))
>
>
>
>
>
> dev.off()
null device
1
>