Given a seurat object, get a named character vector of cluster colours, where names are cluster names (coresponding to levels(seurat@ident)), and values are hex codes of the colours, either the default colours from Seurat, or colours you specify. This is trivial to make this yourself, so this is used as a utility function for retaining the colours of clusters you want to highlight, and setting the colours of all other clusters to grey, or another default, non-intrusive colour.

getClusterColours(seurat, clusters = NULL, original_colours = NULL,
  default_colour = "gray80")

Arguments

seurat

Seurat object

clusters

Vector of one or more clusters to highlight, matching the levels at levels(seurat@ident). If "none", returns default_colour for every clusters. Default: all clusters, obtained from levels(seurat@ident).

original_colours

(Optional) Vector of colours to use. Either one colour per cluster, in the order of levels(seurat@ident), or one colour per cluster passed to clusters, in the other they were provided. Default: default ggplot2 colours used by Seurat.

default_colour

Colour to use for non-highlighted clusters Default: gray80 (light grey).

Value

Named character vector

Examples

# Trivial: get named character vector with default colours getClusterColours(pbmc)
#> 0 1 2 3 #> "#F8766D" "#7CAE00" "#00BFC4" "#C77CFF"
# Highlight clusters 2 and 3 getClusterColours(pbmc, clusters = c(2, 3))
#> 0 1 2 3 #> "gray80" "gray80" "#00BFC4" "#C77CFF"
# Highlight clusters 2 and 3, set all other cluster colours to white getClusterColours(pbmc, clusters = c(2, 3), default_colour = "white")
#> 0 1 2 3 #> "white" "white" "#00BFC4" "#C77CFF"