Matrix ⚪ ➡️ 🟠 ChemoSpec
Arguments
- data
Numeric matrix with sample rows and frequency cols.
rownames()must be unique and contain sample names.colnames()must be unique and contain frequency values, which can be cast to numeric usingas.numeric().- 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_ChemoSpecunit_frequency,unit_intensityOptional labels for the x- and y-axis.
descOptional 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.extra_dataOptional data frame with samples in rows and additional per-sample data in its columns.
colnames()ofextra_datais used to obtain names which will be used asnames()on theSpectraobject..strict_extra_data_names(Default: TRUE) Set this to FALSE to allow columns from
extra_datato overwrite values on theSpectraobject.
Value
A ChemoSpec::Spectra() object.
Examples
x <- matrix(runif(260), nrow = 26)
rownames(x) <- letters[1:26]
colnames(x) <- 1:10
matrix_to_ChemoSpec(
x,
groups = rep(LETTERS[1:2], 13) |> as.factor()
) |> str()
#> List of 9
#> $ data : num [1:26, 1:10] 0.0808 0.8343 0.6008 0.1572 0.0074 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : chr [1:26] "a" "b" "c" "d" ...
#> .. ..$ : chr [1:10] "1" "2" "3" "4" ...
#> $ freq : num [1:10] 1 2 3 4 5 6 7 8 9 10
#> $ unit : chr [1:2] "{missing frequency unit}" "{missing intensity unit}"
#> $ desc : chr "{missing description}"
#> $ groups : Factor w/ 2 levels "A","B": 1 2 1 2 1 2 1 2 1 2 ...
#> $ names : chr [1:26] "a" "b" "c" "d" ...
#> $ colors : chr [1:26] "#511CFCFF" "#FB0D16FF" "#511CFCFF" "#FB0D16FF" ...
#> $ sym : num [1:26] 0 1 0 1 0 1 0 1 0 1 ...
#> $ alt.sym: chr [1:26] "a" "b" "a" "b" ...
#> - attr(*, "class")= chr "Spectra"
