plot_spc_ext: ggplot2 wrapper for extended spectra plotting

View source: R/plot-spc-extended.R

plot_spc_extR Documentation

ggplot2 wrapper for extended spectra plotting

Description

plot_spc_ext is a custom plotting function developed within the simplerspec framework. Returns plots based on ggplot2 (class "ggplot"). Different spectra types such as raw or preprocessed spectra and groups can be differentiated by different colors or by using panels (so called facets). Additionally, spectra can be colored based on an additional measure variable, e.g. determined by chemical reference analysis.

Usage

plot_spc_ext(
  spc_tbl,
  spc_tbl_l = NULL,
  lcols_spc = "spc",
  lcol_measure = NULL,
  lcol_measure_col_palette = "Spectral",
  lcol_measure_col_direction = -1,
  spc_id = "unique_id",
  group_id = "sample_id",
  group_id_order = TRUE,
  group_color = TRUE,
  group_color_palette = NULL,
  group_panel = TRUE,
  group_legend = FALSE,
  ncol = NULL,
  relabel_spc = TRUE,
  ylab = "Spectrum value",
  alpha = 0.5,
  line_width = 0.2,
  ...
)

Arguments

spc_tbl

Tibble data frame containing spectra, x-axis values, metadata and eventual measured variables as list-columns.

spc_tbl_l

List of spectral tibbles (data frames). Default is NULL (argument is not used).

lcols_spc

Character vector of spectral list-columns to be extracted. Default is "spc" (raw spectra).

lcol_measure

Character vector of length 1 denoting the column name of the measure columns. This argument is optional. Default is NULL, which does not extract an additional measure column.

lcol_measure_col_palette

Palette value supplied to ggplot::scale_colour_brewer(). Default is "Spectral", but you can set it to the default argument 1 (will use scale_colour_brewer(..., palette = 1)).

lcol_measure_col_direction

Sets the the order of colours in the scale that is based on a measure column. Default is -1 which reverses the scale. Argument is passed on to the function ggplot2::sclae_colour_brewer() as argument direction.

spc_id

Character vector denoting column name for a unique spectrum ID. Default is "unique_id".

group_id

Character vector denoting column name for the spectrum group ID. Default is "sample_id". The group ID is used for plotting spectra by group (e.g. by using different colors or panels).

group_id_order

Logical that specifies whether the panel names derived from a numeric group_id column are reordered using ascending numbers. Default is TRUE.

group_color

Logical defining whether spectra are colored by the column specified by group_id.

group_color_palette

Character (1L) defining the diverging colour scales from colorbrewer.org; see ?scale_colour_brewer for supported diverging colur types (palette argument).

group_panel

Logical defining whether spectra are arranged into panels by groups specified in group_id. Default is TRUE.

group_legend

Logical defining whether a legend for the group_id is plotted. Default is FALSE.

ncol

Integer vector of length 1. Defines number of columns when plotting panels (facets). Default is NULL (argument not used).

relabel_spc

Logical defining whether panels are relabeled with custom names for spectra types. Default is TRUE. When TRUE, arguments from relabel_spc_types can be passed to plot_spc_ext (supported via the ... (ellipsis) argument)

ylab

Character vector or vector of type "expression" created by mathematical expression created by expression. Custom annotation for y-axis of spectra

alpha

Integer of length 1, from 0 to 1. Defines transparency of spectral lines. Default is 0.5 (0 is completely transparent and 1 is no transparency).

line_width

Numeric vector of length 1 specifying the width of the spectral lines. Default is 0.2.

...

Further arguments to be passed to plot_spc_ext. Currently, arguments of relabel_spc_types are supported.

Value

Object of class "ggplot" (ggplot2 graph).


philipp-baumann/simplerspec documentation built on Oct. 3, 2023, 12:13 p.m.