Palo: Palo: Color palette optimization

View source: R/Palo.R

PaloR Documentation

Palo: Color palette optimization

Description

Palo: Color palette optimization for single-cell and spatial data

Usage

Palo(
  position,
  cluster,
  palette,
  rgb_weight = c(1, 1, 1),
  color_blind_fun = NULL,
  init_iter = 1000,
  refine_iter = 2000,
  early_stop = 500
)

Arguments

position

A matrix of low-dimensional coordinates for single-cell data or 2-D spatial positions for spatial transcriptomics data. The number of rows of the matrix is the number of cells and the matrix has two columns.

cluster

A vector of cell or spots clusters. Should have the same length as the number of cells or spots. Should have the same order as the columns of position.

palette

A user-defined character vector of palette.

rgb_weight

A numeric vector of weights (lengths of three) for RGB values when calculating color differences. Common choices of weights include (1,1,1), (3,4,2), and (2,4,3).

color_blind_fun

A character value indicating if the color palette will be transformed before calculating the color distances for colorblind-friendly visualizations. The value has to be one of 'deutan','protan','tritan','desaturate', or NULL. If NULL, no transformation will be done.

init_iter

A numeric value of number of optimization iterations for initial optimization.

refine_iter

A numeric value of number of optimization iterations for refined optimization.

early_stop

A numeric value to early stop the optimization process if the color score remains unchanged for early_stop consecutive exchanges.

Value

A named vector of colors.

Author(s)

Wenpin Hou<whou10@jhu.edu>, Zhicheng Ji

Examples

x <- matrix(rnorm(2000),ncol=2)
x[1:200,1] <- x[1:200,1] + 5
x[200 + 1:200,1] <- x[200 + 1:200,1] + 10
x[400 + 1:200,2] <- x[400 + 1:200,2] + 5
x[600 + 1:200,2] <- x[600 + 1:200,2] + 10
cluster <- paste0('cluster',rep(1:5,each=200))
palette <- c("orange","red","green","blue","yellow")
pal <- Palo(x,cluster,palette)
qplot(x[,1],x[,2],col=cluster) + scale_color_manual(values=pal)

Winnie09/Palo documentation built on May 22, 2022, 7:36 p.m.