matrix_heatmap: Create heatmap plot for a matrix

View source: R/matrix_heatmap.R

matrix_heatmapR Documentation

Create heatmap plot for a matrix

Description

matrix_heatmap produces a ggplot heatmap from a matrix

Usage

matrix_heatmap(
  data_matrix,
  x_title = "Sample",
  y_title = "Gene",
  fill_title = "Value",
  fill_palette = "plasma",
  xaxis_labels = TRUE,
  yaxis_labels = TRUE,
  ...
)

Arguments

x_title

character Name for the x-axis

y_title

character Name for the y-axis

fill_title

character Name for the legend

fill_palette

character Name of the fill palette to use. Must be one of 'viridis', 'plasma', 'magma', 'inferno', 'cividis'

xaxis_labels

logical/character default=TRUE, FALSE means labels are not printed if the value is a character vector of the same length as the levels of the x variable these values are used instead

yaxis_labels

logical/character default=TRUE, FALSE means labels are not printed if the value is a character vector of the same length as the levels of the y variable these values are used instead

...

Other arguments passed on to theme_heatmap()

plot_matrix

matrix data to plot

Details

This function takes a matrix and creates a heatmap plot. The default values for the x and y axis titles are Sample and Gene respectively and the fill legend is labelled Value. By default x and y axis labels are printed.

Value

plot - ggplot2 object

Examples

set.seed(1638)
test_matrix <- matrix(
  sample(1:16),
  nrow = 4
)
matrix_heatmap(test_matrix)

# specify x, y and fill titles and fill palette
matrix_heatmap(test_matrix, x_title = "Cols", y_title = "Rows",
               fill_title = "Log2FC", fill_palette = "inferno")

# supply different labels for x and y axes
matrix_heatmap(test_matrix, x_title = "Sample", y = "Sample_2",
               fill_title = "Log2FC",
               fill_palette = "magma", xaxis_labels = letters[1:4],
               yaxis_labels = LETTERS[1:4])

# remove x and y labels
matrix_heatmap(test_matrix, xaxis_labels = FALSE, yaxis_labels = FALSE)


richysix/biovisr documentation built on Feb. 3, 2024, 4:36 a.m.