Learn R Programming

jarbes (version 2.4.2)

cocluster_plot: Co-Clustering Heatmap from a Numeric Matrix

Description

Generates a heatmap with hierarchical clustering applied to rows and columns. It reorders the input matrix based on clustering results and visualizes the data.

Usage

cocluster_plot(
  data,
  labels.row = NULL,
  labels.col = NULL,
  colors = "Blues",
  breaks = NULL,
  title = "Clustered Heatmap",
  border.color = "black",
  cell.ratio = 1,
  cluster.rows = TRUE,
  cluster.cols = TRUE,
  clustering.distance.rows = "euclidean",
  clustering.distance.cols = "euclidean",
  row.clustering.method = "complete",
  col.clustering.method = "complete",
  show.row.names = TRUE,
  show.col.names = TRUE,
  fontsize = 8,
  fontsize.row = NULL,
  fontsize.col = NULL,
  display.numbers = FALSE,
  round.digits = 2,
  numbers.color = "black",
  numbers.fontsize = 0.5,
  label.color = "black",
  col.name.angle = 45,
  legend = TRUE,
  legend.labels = NULL,
  show.legend.labels = TRUE,
  ...
)

Value

A `ggplot2` object.

Arguments

data

A numeric matrix for the heatmap.

labels.row

An optional character vector of new labels for the rows.

labels.col

An optional character vector of new labels for the columns.

colors

A character string specifying one of the predefined palettes or a custom vector of colors. Predefined options include:

  • "YlOrRd", "YlOrBr", "YlGnBu", "YlGn", "Reds", "RdPu", "Purples", "PuBu", "PuBuGn", "OrRd", "Oranges", "Greys", "Greens", "GnBu", "BuPu", "BuGn", "Blues"

Defaults to "Blues".

breaks

The number of color breaks to use for the palette. Defaults to `NULL`.

title

Plot title. Default: "Clustered Heatmap".

border.color

Color of cell borders on the heatmap. Use "NA" for no border. Default: "white".

cell.ratio

A numeric value defining the cell's height-to-width ratio. A value of 1 creates square cells. A value > 1 creates vertical rectangles, while a value < 1 creates horizontal rectangles. Default is 1.

cluster.rows

A logical value indicating whether to cluster rows. Default: `TRUE`.

cluster.cols

A logical value indicating whether to cluster columns. Default: `TRUE`.

clustering.distance.rows

Distance measure for row clustering. Can be a string ("euclidean", "correlation", etc.) or a pre-calculated distance object. Default: "euclidean".

clustering.distance.cols

Distance measure for column clustering. Can be a string ("euclidean", "correlation", etc.) or a pre-calculated distance object. Default: "euclidean".

row.clustering.method

Agglomeration method for row clustering (see `?hclust`). Default: "complete".

col.clustering.method

Agglomeration method for column clustering (see `?hclust`). Default: "complete".

show.row.names

Logical, display row names. Default: TRUE.

show.col.names

Logical, display column names. Default: TRUE.

fontsize

Base font size for the plot. Default: 8.

fontsize.row

Font size for row names. If `NULL`, defaults to `fontsize`.

fontsize.col

Font size for column names. If `NULL`, defaults to `fontsize`.

display.numbers

Logical determining if the numeric values are also printed to the cells.

round.digits

Numeric value. For `display.numbers = TRUE`, this sets the decimal places for all values. Default: 2.

numbers.color

Color of the numbers. Default: "black".

numbers.fontsize

Font size of the numbers. Default: `fontsize`.

label.color

Color of the row and column labels. Default: "black".

col.name.angle

Angle for column names. Default: 45.

legend

A logical value indicating whether to show the color legend. Default: `TRUE`.

legend.labels

A character vector of custom labels for the legend.

show.legend.labels

Logical, display legend labels. Default: TRUE.

...

...