sample_annotation_to_colors {proBatch} | R Documentation

## Generate colors for sample annotation

### Description

Convert the sample annotation data frame to list of colors the list is named as columns included to use in plotting functions

### Usage

    sample_annotation_to_colors(
      sample_annotation,
      sample_id_col = "FullRunName",
      factor_columns = c("MS_batch", "EarTag", "digestion_batch", "Strain", "Diet"),
      numeric_columns = c("DateTime", "order"),
      rare_categories_to_other = TRUE,
      guess_factors = FALSE,
      numeric_palette_type = "brewer"
    )

### Arguments

`sample_annotation` | data frame with: `sample_id_col` (this can be repeated as row names) biological covariates technical covariates (batches etc) . See `help("example_sample_annotation")`
`sample_id_col` | name of the column in `sample_annotation` table, where the filenames (colnames of the `data_matrix` are found).
`factor_columns` | columns of `sample_annotation` to be treated as factors. Sometimes categorical variables are depicted as integers (e.g. in column "Batch", values are 1, 2 and 3), specification here allows to map them correctly to qualitative palettes.
`numeric_columns` | columns of `sample_annotation` to be treated as continuous numeric values.
`rare_categories_to_other` | if `True` rare categories will be merged into the value `"other"`
`guess_factors` | whether attempt which of the `factor_columns` are actually numeric
`numeric_palette_type` | palette to be used for numeric values coloring (can be `'brewer' and 'viridis'`)

### Value

list of three items:

1. list of colors;

2. data frame of colors;

3. new sample annotation (e.g. rare factor levels merged into "other")

### Examples

    color_scheme <- sample_annotation_to_colors (example_sample_annotation,
    factor_columns = c('MS_batch','EarTag', "Strain",
    "Diet", "digestion_batch", "Sex"),
    numeric_columns = c('DateTime', 'order'))

[Package proBatch version 1.11.0 Index]