getScores: [+] Calculate amplitudes of spectroscopic components (a.k.a....

View source: R/getScores.R

getScoresR Documentation

[+] Calculate amplitudes of spectroscopic components (a.k.a. scores) and label the resulting object

Description

Calculate amplitudes of spectroscopic components (a.k.a. scores) by matrix multiplication (see section "Detais") and properly label created hyperSpec object.

Usage

getScores(
  sp,
  loadings = NULL,
  xLabel = "Component",
  yLabel = "Amplitude",
  names.var = "cNames",
  scores = NULL
)

Arguments

sp

Spectroscopic data (either a hyperSpec object or a matrix).

loadings

Components' spectra (loadings) as either a matrix or a hyperSpec object.

xLabel

A label for x axis. Default is "Component".
labels(scores,".wavelength") <- xLabel

yLabel

A label for y axis. Default is "Amplitude".
labels(scores,"spc") <- yLabel

names.var

A name of variable in loadings, that contains names of components (loadings). These names will be transfered to scores.
NOTES:
1. if names.var does not exist (e.g., misspelled), component names No1, No2, ... will be used.
2. This parameter applicable only if class of sp is hyperSpec.

scores

A matrix of known/already calculated scores to convert to hyperSpec object.
If this argument is provided, matrix multiplication is not performed, but component names are copied from loadings to scores.

Details

Equation of matrix multiplication to calculate scores:

scores = sp * loadings * inv(loadings' * loadings)

This formula is taken and adapted from [1].

Value

Amplitudes of the components (i.e., scores), tha corespond to observations (spectra) in object sp.

Author(s)

Vilmantas Gegzna

References

[1] M. Brydegaard et al. IEEE Photonics J 2011:3(3);406-21.

See Also

qplot_scores

Other component analysis / factorisation related functions in spHelper: infoDim(), plot_spDiff(), qplot_infoDim(), qplot_kAmp(), qplot_kSp(), qplot_spc(), reconstructSp(), sortLoadings(), unipeak(), whichOutlier()

Examples


sc <- getScores(Spectra2, Loadings2)
sc
qplot_scores(sc)

GegznaV/spHelper documentation built on April 16, 2023, 1:42 p.m.