Skip to contents

Allows generating heatmap-like visualisations for benchmark data frames. Funky heatmaps can be fine-tuned by providing annotations of the columns and rows, which allows assigning multiple palettes or geometries or grouping rows and columns together in categories.

Usage

funky_heatmap(
  data,
  column_info = NULL,
  row_info = NULL,
  column_groups = NULL,
  row_groups = NULL,
  palettes = NULL,
  legends = NULL,
  position_args = position_arguments(),
  scale_column = TRUE,
  add_abc = TRUE,
  col_annot_offset,
  col_annot_angle,
  expand
)

Arguments

data

A data frame with items by row and features in the columns. Must contain one column named "id".

column_info

A data frame describing which columns in data to plot. This data frame should contain the following columns:

  • id (character, required): A column name in data to plot. Determines the size of the resulting geoms, and also the color unless color is specified.

  • id_color (character): A column name in data to use for the color of the resulting geoms. If NA, the id column will be used.

  • id_size (character): A column name in data to use for the size of the resulting geoms. If NA, the id column will be used.

  • name (character): A label for the column. If NA or "", no label will be plotted. If this column is missing, id will be used to generate the name column.

  • geom (character): The geom of the column. Must be one of: "funkyrect", "circle", "rect", "bar", "pie", "text" or "image". For "text", the corresponding column in data must be a character. For "pie", the column must be a list of named numeric vectors. For all other geoms, the column must be a numeric.

  • group (character): The grouping id of each column, must match with column_groups$group. If this column is missing or all values are NA, columns are assumed not to be grouped.

  • palette (character): Which palette to colour the geom by. Each value should have a matching value in palettes$palette.

  • width: Custom width for this column (default: 1).

  • overlay: Whether to overlay this column over the previous column. If so, the width of that column will be inherited.

  • legend: Whether or not to add a legend for this column.

  • hjust: Horizontal alignment of the bar, must be between [0,1] (only for geom = "bar").

  • vjust: Vertical alignment of the label, must be between [0,1] (only for geom = "text").

  • size: Size of the label, must be a numeric value (only for geom = "text").

  • label: Which column to use as a label (only for geom = "text").

  • directory: Which directory to use to find the images (only for geom = "image").

  • extension: The extension of the images (only for geom = "image").

  • draw_outline: Whether or not to draw bounding guides (only for geom == "bar"). Default: TRUE.

  • options (list or json): Any of the options above. Any values in this column will be spread across the other columns. This is useful for not having to provide a data frame with 1000s of columns. This column can be a json string.

row_info

A data frame describing the rows of data. This data should contain two columns:

  • id (character): Corresponds to the column data$id.

  • group (character): The group of the row. If all are NA, the rows will not be split up into groups.

column_groups

A data frame describing of how to group the columns in column_info. Can consist of the following columns:

  • group (character): The corresponding group in column_info$group.

  • palette (character, optional): The palette used to colour the column group backgrounds.

  • level1 (character): The label at the highest level.

  • level2 (character, optional): The label at the middle level.

  • level3 (character, optional): The label at the lowest level (not recommended).

row_groups

A data frame describing of how to group the rows in row_info. Can consist of the following columns:

  • group (character): The corresponding group in row_info$group.

  • level1 (character): The label at the highest level.

  • level2 (character, optional): The label at the middle level.

  • level3 (character, optional): The label at the lowest level (not recommended).

palettes

A named list of palettes. Each entry in column_info$palette should have an entry in this object. If an entry is missing, the type of the column will be inferred (categorical or numerical) and one of the default palettes will be applied. Alternatively, the name of one of the standard palette names can be used:

  • numerical: "Greys", "Blues", "Reds", "YlOrBr", "Greens"

  • categorical: "Set3", "Set1", "Set2", "Dark2"

legends

A list of legends to add to the plot. Each entry in column_info$legend should have a corresponding entry in this object. Each entry should be a list with the following names:

  • palette (character): The palette to use for the legend. Must be a value in palettes.

  • geom (character): The geom of the legend. Must be one of: "funkyrect", "circle", "rect", "bar", "pie", "text", "image".

  • title (character, optional): The title of the legend. Defaults to the palette name.

  • enabled (logical, optional): Whether or not to add the legend. Defaults to TRUE.

  • labels (character, optional): The labels to use for the legend. The defaults depend on the selected geom.

  • size (numeric, optional): The size of the listed geoms. The defaults depend on the selected geom.

  • color (character, optional): The color of the listed geoms. The defaults depend on the selected geom.

  • values (optional): Used as values for the text and image geoms.

  • label_width (numeric, optional): The width of the labels (only when geom is text or pie). Defaults to 1 for text and 2 for images.

  • value_width (numeric, optional): The width of the values (only for geom = "text"). Defaults to 2.

  • label_hjust (numeric, optional): The horizontal alignment of the labels (only when geom is circle, rect or funkyrect). Defaults to 0.5.

position_args

Sets parameters that affect positioning within a plot, such as row and column dimensions, annotation details, and the expansion directions of the plot. See position_arguments() for more information.

scale_column

Whether or not to apply min-max scaling to each numerical column.

add_abc

Whether or not to add subfigure labels to the different columns groups.

col_annot_offset

DEPRECATED: use position_args = position_arguments(col_annot_offset = ...) instead.

col_annot_angle

DEPRECATED: use position_args = position_arguments(col_annot_angle = ...) instead.

expand

DEPRECATED: use position_args = position_arguments(expand_* = ...) instead.

Value

A ggplot. .$width and .$height are suggested dimensions for storing the plot with ggsave().

Examples

library(tibble, warn.conflicts = FALSE)

data("mtcars")

data <- rownames_to_column(mtcars, "id")

funky_heatmap(data)
#>  No column info was provided, assuming all columns in `data` are to be plotted.
#>  Column info did not contain column `name`, using `id` to generate it.
#>  Column info did not contain information on which columns to plot, inferring from `data` types.
#>  Column info did not contain group information, assuming columns are ungrouped.
#>  Column info did not contain a column called 'palette', generating palettes based on the 'geom' column.
#>  Column info did not contain a column called 'width', generating options based on the 'geom' column.
#>  Column info did not contain a column called 'legend', generating options based on the 'geom' column.
#>  No row info was provided, assuming all rows in `data` are to be plotted.
#>  Row info did not contain group information, assuming rows are ungrouped.
#>  No palettes were provided, trying to automatically assign palettes.
#>  Palette named 'numerical_palette' was not defined. Assuming palette is numerical. Automatically selected palette 'Blues'.
#>  No legends were provided, trying to automatically infer legends.
#>  Some palettes were not used in the column info, adding legends for them.
#>  Legend 1 did not contain a geom, inferring from the column info.
#>  Legend 1 did not contain labels, inferring from the geom.
#>  Legend 1 did not contain size, inferring from the labels.
#>  Legend 1 did not contain color, inferring from the palette.