df_heatmap: Create heatmap plot for a data.frame

View source: R/matrix_heatmap.R

df_heatmapR Documentation

Create heatmap plot for a data.frame

Description

df_heatmap produces a ggplot heatmap from a data.frame

Usage

df_heatmap(
  plot_df,
  x,
  y,
  fill,
  fill_palette = "plasma",
  colour = NULL,
  size = NULL,
  xaxis_labels = TRUE,
  yaxis_labels = TRUE,
  na.translate = TRUE,
  ...
)

Arguments

plot_df

data.frame data to plot

x

character Name of the variable to plot on the x-axis

y

character Name of the variable to plot on the y-axis

fill

character Name of the variable to use for the fill colour

fill_palette

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

colour

character fixed value for the border colour of the heatmap tiles

size

integer fixed value for the line width of the heatmap tiles border

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

na.translate

logical whether to include NA values in the legend for categorical fill variables

...

Other arguments passed on to theme_heatmap

Details

This function takes a data.frame and creates a heatmap plot. The function assumes the data is in long form with a column for the x variable, a column for the y variable and a column for the data values. By default x and y axis labels are printed.

Value

plot - ggplot2 object

Examples


set.seed(20962)
test_data_cat <- data.frame(cols = factor(rep(LETTERS[1:10], 10)),
  rows = factor(rep(1:10, each = 10), levels = 10:1),
  fill = runif(100))

df_heatmap(test_data_cat, x = "cols", y = "rows", fill = "fill")

df_heatmap(test_data_cat, x = "cols", y = "rows", fill = "fill",
    fill_palette = "inferno", xaxis_labels = FALSE, yaxis_labels = FALSE)

df_heatmap(test_data_cat, x = "cols", y = "rows", fill = "fill",
    fill_palette = "inferno", xaxis_labels = letters[1:10], yaxis_labels = LETTERS[1:10])


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