getScores.Rd
Calculate amplitudes of spectroscopic components (a.k.a. scores) by
matrix multiplication (see section "Detais") and properly label created
hyperSpec
object.
getScores(
sp,
loadings = NULL,
xLabel = "Component",
yLabel = "Amplitude",
names.var = "cNames",
scores = NULL
)
Spectroscopic data
(either a hyperSpec
object or a matrix).
Components' spectra (loadings) as either a matrix or a
hyperSpec
object.
A label for x axis. Default is "Component".labels(scores,".wavelength") <- xLabel
A label for y axis. Default is "Amplitude".labels(scores,"spc") <- yLabel
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
.
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
.
Amplitudes of the components (i.e., scores), tha corespond to
observations (spectra) in object sp
.
Equation of matrix multiplication to calculate scores:
$$scores = sp * loadings * inv(loadings' * loadings)$$
This formula is taken and adapted from [1].
[1] M. Brydegaard et al. IEEE Photonics J 2011:3(3);406-21.
Other component analysis / factorisation related functions in spHelper:
infoDim()
,
plot_spDiff()
,
qplot_infoDim()
,
qplot_kAmp()
,
qplot_kSp()
,
qplot_spc()
,
reconstructSp()
,
sortLoadings()
,
unipeak()
,
whichOutlier()
sc <- getScores(Spectra2, Loadings2)
sc
#> hyperSpec object
#> 150 spectra
#> 3 data columns
#> 5 data points / spectrum
qplot_scores(sc)
#> Warning: Function 'hyperSpec::chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()): ℹ In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"