ChemoSpec requires that the hyperSpec object meets the following conditions:
Wavelengths must be unique.
Spectra must not contain
NAs.
Arguments
- hySpc
hyperSpec::hyperSpecobject.- names
Character vector with unique sample names. Length must match
nrow(data). Defaults torownames(data).- groups
Factor with sample class assignments or single integer or string value. Length of factor must match
nrow(data). A single value is treated as setting the same group for all samples. Defaults to"{missing group}"- ...
Arguments passed on to
to_ChemoSpecdescOptional description for plots generated with ChemoSpec.
colors_set,sym_set,alt.sym_setCharacter vector with group colors, Numeric vector with group symbol numbers, Character vector with alternative group symbols. Their length must match at least the number of levels in
groups. Groups are assigned colors based on their numeric factor level. Defaults toChemoSpecUtils::Col8,ChemoSpecUtils::Sym8andbase::letters. A color-blind friendly palette is available inChemoSpecUtils::Col7. Extended palettes are available atChemoSpecUtils::Col12,ChemoSpecUtils::Sym12, and using other packages, like RColorBrewer..strict_extra_data_names(Default: TRUE) Set this to FALSE to allow columns from
extra_datato overwrite values on theSpectraobject.
Examples
suppressPackageStartupMessages(library(hyperSpec))
data(flu)
hyperSpec_to_ChemoSpec(
flu,
names = 1:6 |> as.character(),
groups = LETTERS[1:6] |> as.factor()
) |> str()
#> Additional data was found: filename
#> Additional data was found: c
#> List of 11
#> $ data : num [1:6, 1:181] 27.1 66.8 93.1 130.7 167.3 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:181] "405" "405.5" "406" "406.5" ...
#> $ freq : num [1:181] 405 406 406 406 407 ...
#> $ unit : chr [1:2] "lambda/nm" "I[fl]/\"a.u.\""
#> $ desc : chr "{missing description}"
#> $ groups : Factor w/ 6 levels "A","B","C","D",..: 1 2 3 4 5 6
#> $ names : chr [1:6] "1" "2" "3" "4" ...
#> $ colors : chr [1:6] "#511CFCFF" "#FB0D16FF" "#2AA30DFF" "#700D87FF" ...
#> $ sym : num [1:6] 0 1 2 3 15 16
#> $ alt.sym : chr [1:6] "a" "b" "c" "d" ...
#> $ filename: chr [1:6] "rawdata/flu1.txt" "rawdata/flu2.txt" "rawdata/flu3.txt" "rawdata/flu4.txt" ...
#> $ c : num [1:6] 0.05 0.1 0.15 0.2 0.25 0.3
#> - attr(*, "class")= chr "Spectra"
