doALS: Wrapper function for als, plus some support functions

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/doALS.R

Description

Wrapper function for the als function in the ALS package, providing a simple interface with sensible defaults for hyphenated data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
doALS(Xl, PureS, maxiter = 100, verbose)
## S3 method for class 'ALS'
print(x, ...)
## S3 method for class 'ALS'
summary(object, ...)
## S3 method for class 'ALS'
plot(x, what = c("spectra", "profiles"), showWindows = TRUE,
                   mat.idx, comp.idx, xlab, ylab, main, ...)
getTime(x)
getWavelength(x)

Arguments

Xl

a list of (numerical) data matrices. Missing values are not allowed.

x, object

an object of class ALS.

PureS

Initial estimates of pure spectral components.

maxiter

maximum number of iterations in ALS.

verbose

show als feedback during optimisation.

what

Show spectra or elution profiles

showWindows

If showing elution profiles, the window borders and the overlap areas between the windows can be shown (by default). Simply set this parameter to FALSE if this is undesired.

mat.idx

If showing elution profiles, one can provide the index of the sample(s) that should be shown. For every sample one plot will be made. Default is to show all.

comp.idx

Indices of components to be shown. Default is to show all components.

xlab, ylab, main, ...

self-explanatory optional arguments

Details

The plot method can be used to plot the spectral components (one plot for the model) or the elution profiles (one plot for each data matrix, so usually several plots). The summary method also returns fit statistics like LOF, R2 and RMS. Extractor functions getTime and getWavelength provide the vectors of time points and wavelengths from the ALS object.

Value

Function doALS returns an object of class "ALS", a list with the following fields:

CList

a list of matrices with the elution profiles in the columns. Every matrix in this list corresponds with a matrix in the input.

S

a matrix with the spectral components in the columns. These are common for all data matrices.

rss

residual sum of squares.

resid

a list of residual matrices.

iter

number of iterations.

summ.stats

summary statistics, providing more information about the fit quality.

See the als function for more details; only the summ.stats field is not part of the original als output.

Author(s)

Ron Wehrens

See Also

als,showALSresult

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data(tea)
new.lambdas <- seq(260, 500, by = 2)
tea <- lapply(tea.raw, preprocess, dim2 = new.lambdas)
tea.split <- splitTimeWindow(tea, c(12, 14), overlap = 10)

Xl <- tea.split[[2]]
Xl.opa <- opa(Xl, 4)

Xl.als <- doALS(Xl, Xl.opa)
Xl.als
summary(Xl.als)
plot(Xl.als, "spectra")
par(mfrow = c(1, 3))
plot(Xl.als, "profiles", ylim = c(0, 600), mat.idx = 1:3)

Example output

Loading required package: ALS
Loading required package: nnls
Loading required package: Iso
Iso 0.0-17
Loading required package: ptw
There were 50 or more warnings (use warnings() to see the first 50)
ALS object fitting 5 samples; RMS fit error 0.16252 
ALS object fitting 5 samples with 4 components. 
Each data matrix contains 121 wavelengths and 60 timepoints
	RMS fit error: 0.16252 
	LOF: 2.13%
	R2: 0.99955

alsace documentation built on Nov. 8, 2020, 5:54 p.m.