show_color_distance: Show color distance as a heatmap

show_color_distanceR Documentation

Show color distance as a heatmap

Description

Show color distance as a heatmap

Usage

show_color_distance(
  cd = NULL,
  pc = NULL,
  show_labels = TRUE,
  cluster_data = FALSE,
  row_split = 0,
  ...
)

Arguments

cd

numeric matrix, default NULL, with pre-calculated values.

pc

character vector of colors used in cd, useful when there are names(pc) to use as heatmap column or row labels. When only pc is provided and not cd, the cd is calculated by calling color_distance(pc).

show_labels

logical default TRUE, used when pc is provided.

cluster_data

logical default FALSE, whether to enable row and column hierarchical clustering in the heatmap.

row_split

numeric default 0, used when cluster_data=TRUE to subdivide the dendrogram into this many separate subclusters.

...

additional arguments are passed to color_distance(), then to jamses::heatmap_se(). Many arguments in jamses::heatmap_se() are also passed through to ComplexHeatmap::Heatmap().

Details

This function uses ComplexHeatmap::Heatmap(), which is not required for colorjam as a whole. It creates a matrix visual summary of color distances, and displays the actual colors as row and column annotations outside the color distance heatmap.

Value

ComplexHeatmap::Heatmap object, when printed it will draw a heatmap.

Examples

pc <- grDevices::palette.colors(25);
cd <- color_distance(pc, method="cie2000");
show_color_distance(cd, pc)

# with clustering
show_color_distance(cd, pc, cluster_data=TRUE,
   column_title_gp=grid::gpar(fontsize=20),
   column_title="palette.colors()")

# compare two color vectors
pc1 <- rainbowJam(10, preset="ryb2")
pc2 <- colorspace::rainbow_hcl(10)
cd <- color_distance(pc1, pc2)
show_color_distance(cd, cluster_data=TRUE,
   row_title_rot=90, row_title="rainbowJam()",
   row_title_gp=grid::gpar(fontsize=20),
   column_title_gp=grid::gpar(fontsize=20),
   column_title_rot=0, column_title="rainbow_hcl()")

# evaluate the small step size between HCL rainbow colors
show_color_distance(pc2,
   column_title_gp=grid::gpar(fontsize=20),
   column_title_rot=0, column_title="rainbow_hcl()")

# evaluate the larger step sizes between colorjam rainbow colors
show_color_distance(pc1, cluster_data=FALSE,
   column_title_gp=grid::gpar(fontsize=20),
   column_title_rot=0, column_title="rainbowJam()")


jmw86069/colorjam documentation built on June 10, 2025, 12:02 p.m.