Skip to contents

Matrix ⚪ ➡️ 🟠 ChemoSpec

Usage

matrix_to_ChemoSpec(data, groups = "{missing group}", ...)

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 using as.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_ChemoSpec

unit_frequency,unit_intensity

Optional labels for the x- and y-axis.

desc

Optional description for plots generated with ChemoSpec.

colors_set,sym_set,alt.sym_set

Character 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 to ChemoSpecUtils::Col8, ChemoSpecUtils::Sym8 and base::letters. A color-blind friendly palette is available in ChemoSpecUtils::Col7. Extended palettes are available at ChemoSpecUtils::Col12, ChemoSpecUtils::Sym12, and using other packages, like RColorBrewer.

extra_data

Optional data frame with samples in rows and additional per-sample data in its columns. colnames() of extra_data is used to obtain names which will be used as names() on the Spectra object.

.strict_extra_data_names

(Default: TRUE) Set this to FALSE to allow columns from extra_data to overwrite values on the Spectra object.

Value

A ChemoSpec::Spectra() object.

See also

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"