This function returns a character() vector with valid R colors for a given input character() of unique cell types. These were colors that have been useful in our experience.

create_cell_colors(
  cell_types = c("Astro", "Micro", "Oligo", "OPC", "Inhib", "Excit"),
  pallet = c("classic", "gg", "tableau"),
  split = NA,
  preview = FALSE
)

Arguments

cell_types

A character() vector listing unique cell types.

pallet

Choice of base pallet "classic", "gg", or "tableau".

split

delineating character(1) after which suffixes will be ignored. This is useful for cases when say A.1 and A.2 are both to be considered as cell type A (here split = "\\.").

preview

A logical(1) indicating whether to make a plot to preview the colors.

Value

A named character() vector of R and hex color values compatible with ggplot2:scale_color_manual().

Examples

create_cell_colors(pallet = "classic")
#>     Astro     Micro     Oligo       OPC     Inhib     Excit 
#>       "3"       "4"       "5"       "6" "#E41A1C" "#377EB8" 
create_cell_colors(pallet = "classic", preview = TRUE)

#>     Astro     Micro     Oligo       OPC     Inhib     Excit 
#>       "3"       "4"       "5"       "6" "#E41A1C" "#377EB8" 
create_cell_colors(pallet = "tableau", preview = TRUE)

#>     Astro     Micro     Oligo       OPC     Inhib     Excit 
#> "#1F77B4" "#AEC7E8" "#FF7F0E" "#FFBB78" "#2CA02C" "#98DF8A" 

## Consider A.1 and A.2 as two different cell types (default)
create_cell_colors(
    cell_types = c("A.1", "A.2", "B.1", "C", "D"),
    pallet = "gg",
    preview = TRUE
)

#>       A.1       A.2       B.1         C         D 
#> "#F8766D" "#A3A500" "#00BF7D" "#00B0F6" "#E76BF3" 

## Consider A.1 and A.2 as cell type A by using the "split" argument
create_cell_colors(
    cell_types = c("A.1", "A.2", "B.1", "C"),
    split = "\\.",
    pallet = "gg",
    preview = TRUE
)

#>         A         B         C       A.1       A.2       B.1 
#> "#F8766D" "#00BA38" "#619CFF" "#F8766D" "#FBBAB5" "#00BA38"