sample_annotation_to_colors: Generate colors for sample annotation

Description Usage Arguments Value Examples

View source: R/colors_for_annotation.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
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:

  1. sample_id_col (this can be repeated as row names)

  2. biological covariates

  3. 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

1
2
3
4
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'))

proBatch documentation built on Nov. 8, 2020, 4:55 p.m.