Title: | Generating Funky Heatmaps for Data Frames |
---|---|
Description: | 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. Saelens et al. (2019) <doi:10.1038/s41587-019-0071-9>. |
Authors: | Robrecht Cannoodt [aut, cre] (<https://orcid.org/0000-0003-3641-729X>, rcannood), Wouter Saelens [aut] (<https://orcid.org/0000-0002-7114-6248>, zouter), Louise Deconinck [ctb] (<https://orcid.org/0000-0001-8100-6823>, LouiseDck), Artuur Couckuyt [ctb] , Nick Markov [ctb] (<https://orcid.org/0000-0002-3659-4387>, mxposed), Luke Zappia [ctb] (<https://orcid.org/0000-0001-7744-8565>, lazappi) |
Maintainer: | Robrecht Cannoodt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.6.0 |
Built: | 2024-11-13 22:21:06 UTC |
Source: | https://github.com/funkyheatmap/funkyheatmap |
This data was generated by running the data-raw/dynbenchmark_data.R
script.
It is used in the vignette named "vignette("dynbenchmark")
" to regenerate
the results figures in Saelens et al. 2019.
dynbenchmark_data
dynbenchmark_data
An object of class list
of length 6.
Saelens W, Cannoodt R, Todorov H, Saeys Y (2019). “A comparison of single-cell trajectory inference methods.” Nature Biotechnology. doi:10.1038/s41587-019-0071-9.
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.
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 )
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 )
data |
A data frame with items by row and features in the columns.
Must contain one column named |
column_info |
A data frame describing which columns in
|
row_info |
A data frame describing the rows of
|
column_groups |
A data frame describing of how to group the columns
in
|
row_groups |
A data frame describing of how to group the rows
in
|
palettes |
A named list of palettes. Each entry in
|
legends |
A list of legends to add to the plot. Each entry in
|
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 |
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 |
col_annot_angle |
DEPRECATED: use |
expand |
DEPRECATED: use |
A ggplot. .$width
and .$height
are suggested dimensions for
storing the plot with ggplot2::ggsave()
.
library(tibble, warn.conflicts = FALSE) data("mtcars") data <- rownames_to_column(mtcars, "id") funky_heatmap(data)
library(tibble, warn.conflicts = FALSE) data("mtcars") data <- rownames_to_column(mtcars, "id") funky_heatmap(data)
Does what ggplot2::geom_rect()
does, only curvier. Use the radius
aesthetic
to change the corner radius.
geom_rounded_rect( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
geom_rounded_rect( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom_rect()
and geom_tile()
's respond differently to scale
transformations due to their parameterisation. In geom_rect()
, the scale
transformation is applied to the corners of the rectangles. In geom_tile()
,
the transformation is applied only to the centres and its size is determined
after transformation.
geom_tile()
understands the following aesthetics (required aesthetics are in bold):
Note that geom_raster()
ignores colour
.
Learn more about setting these aesthetics in vignette("ggplot2-specs")
.
library(ggplot2) df <- data.frame( x = rep(c(2, 5, 7, 9, 12), 2), y = rep(c(1, 2), each = 5), z = factor(rep(1:5, each = 2)), w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2) ) ggplot(df) + geom_rounded_rect( aes( xmin = x - w / 2, xmax = x + w / 2, ymin = y, ymax = y + 1, radius = .5, fill = z ), colour = "white" )
library(ggplot2) df <- data.frame( x = rep(c(2, 5, 7, 9, 12), 2), y = rep(c(1, 2), each = 5), z = factor(rep(1:5, each = 2)), w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2) ) ggplot(df) + geom_rounded_rect( aes( xmin = x - w / 2, xmax = x + w / 2, ymin = y, ymax = y + 1, radius = .5, fill = z ), colour = "white" )
This function sets parameters that affect positioning within a plot, such as row and column dimensions, annotation details, and the expansion directions of the plot.
position_arguments( row_height = 1, row_space = 0.1, row_bigspace = 1.2, col_width = 1, col_space = 0.1, col_bigspace = 0.5, col_annot_offset = 3, col_annot_angle = 30, expand_xmin = 0, expand_xmax = 2, expand_ymin = 0, expand_ymax = 0 )
position_arguments( row_height = 1, row_space = 0.1, row_bigspace = 1.2, col_width = 1, col_space = 0.1, col_bigspace = 0.5, col_annot_offset = 3, col_annot_angle = 30, expand_xmin = 0, expand_xmax = 2, expand_ymin = 0, expand_ymax = 0 )
row_height |
The height of the rows. |
row_space |
The space between rows. |
row_bigspace |
The large space between row groups. |
col_width |
The width of the columns. |
col_space |
The space between columns. |
col_bigspace |
The large space between column groups. |
col_annot_offset |
How much the column annotation will be offset by. |
col_annot_angle |
The angle of the column annotation labels. |
expand_xmin |
The minimum expansion of the plot in the x direction. |
expand_xmax |
The maximum expansion of the plot in the x direction. |
expand_ymin |
The minimum expansion of the plot in the y direction. |
expand_ymax |
The maximum expansion of the plot in the y direction. |
A list of plot positioning parameters.
position_arguments(row_height = 1.2, col_width = 1.5, expand_xmax = 3)
position_arguments(row_height = 1.2, col_width = 1.5, expand_xmax = 3)
Scale a vector to the range [0, 1]
scale_minmax(x)
scale_minmax(x)
x |
A numeric vector |
A numeric vector scaled to the range [0, 1]
scale_minmax(c(1, 2, 3))
scale_minmax(c(1, 2, 3))
This dataset was generated by running the data-raw/scib_summary.R
script.
This script downloads data for the RNA tasks from the
scIB reproducibility repository
and summarises it similarly (but not exactly like) what was done in the
original paper to give a final ranking of the top performing methods.
It is used in the scIB vignette (vignette("scIB")
) to reproduce
the overall summary figure in Luecken et al. 2021.
scib_summary
scib_summary
An object of class tbl_df
(inherits from tbl
, data.frame
) with 20 rows and 27 columns.
Luecken MD, Büttner M, Chaichoompu K, Danese A, Interlandi M, Mueller MF, Strobl DC, Zappia L, Dugas M, Colomé-Tatché M, Theis FJ (2021). “Benchmarking atlas-level data integration in single-cell genomics.” Nature methods. doi:10.1038/s41592-021-01336-8.
Verify the integrity of the column groups object
verify_column_groups(column_groups, column_info)
verify_column_groups(column_groups, column_info)
column_groups |
A data frame describing of how to group the columns
in
|
column_info |
A data frame describing which columns in
|
The column groups object with all expected columns.
library(tibble) column_groups <- tribble( ~group, ~level1, "foo", "Foo", "bar", "Bar" ) column_info <- tribble( ~id, ~geom, ~group, "name", "text", NA_character_, "foo1", "funkyrect", "foo", "foo2", "funkyrect", "foo", "bar1", "funkyrect", "bar", "bar2", "funkyrect", "bar" ) verify_column_groups(column_groups, column_info)
library(tibble) column_groups <- tribble( ~group, ~level1, "foo", "Foo", "bar", "Bar" ) column_info <- tribble( ~id, ~geom, ~group, "name", "text", NA_character_, "foo1", "funkyrect", "foo", "foo2", "funkyrect", "foo", "bar1", "funkyrect", "bar", "bar2", "funkyrect", "bar" ) verify_column_groups(column_groups, column_info)
Verify the integrity of the column info object
verify_column_info(column_info, data)
verify_column_info(column_info, data)
column_info |
A data frame describing which columns in
|
data |
A data frame with items by row and features in the columns.
Must contain one column named |
The column info object with all expected columns.
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, "name", "text", "x", "funkyrect", "y", "funkyrect" ) verify_column_info(column_info, data)
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, "name", "text", "x", "funkyrect", "y", "funkyrect" ) verify_column_info(column_info, data)
Verify the integrity of the data object
verify_data(data)
verify_data(data)
data |
A data frame with items by row and features in the columns.
Must contain one column named |
A verified data object
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) verify_data(data)
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) verify_data(data)
Verify the integrity of the legends object
verify_legends(legends, palettes, column_info, data)
verify_legends(legends, palettes, column_info, data)
legends |
A list of legends to add to the plot. Each entry in
|
palettes |
A named list of palettes. Each entry in
|
column_info |
A data frame describing which columns in
|
data |
A data frame with items by row and features in the columns.
Must contain one column named |
The legends object in the expected format.
library(tibble) library(grDevices) library(RColorBrewer) # explicit form data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, ~palette, "name", "text", NA, "foo", "funkyrect", "pal1", "bar", "funkyrect", "pal2" ) palettes <- list( pal1 = rev(brewer.pal(9, "Greys")[-1]), pal2 = rev(brewer.pal(9, "Reds")[-8:-9]) ) legends <- list() verify_legends(legends, palettes, column_info, data)
library(tibble) library(grDevices) library(RColorBrewer) # explicit form data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, ~palette, "name", "text", NA, "foo", "funkyrect", "pal1", "bar", "funkyrect", "pal2" ) palettes <- list( pal1 = rev(brewer.pal(9, "Greys")[-1]), pal2 = rev(brewer.pal(9, "Reds")[-8:-9]) ) legends <- list() verify_legends(legends, palettes, column_info, data)
Verify the integrity of the palettes object
verify_palettes(palettes, column_info, data)
verify_palettes(palettes, column_info, data)
palettes |
A named list of palettes. Each entry in
|
column_info |
A data frame describing which columns in
|
data |
A data frame with items by row and features in the columns.
Must contain one column named |
The palettes object with all expected columns.
library(tibble) library(grDevices) library(RColorBrewer) # explicit form data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, ~palette, "name", "text", NA, "foo", "funkyrect", "pal1", "bar", "funkyrect", "pal2" ) palettes <- list( pal1 = rev(brewer.pal(9, "Greys")[-1]), pal2 = rev(brewer.pal(9, "Reds")[-8:-9]) ) verify_palettes(palettes, column_info, data) # implicit palettes palettes <- list( pal1 = "Greys", pal2 = "Reds" ) verify_palettes(palettes, column_info, data) # passing a tibble should also work (for backwards compatibility) palettes <- tribble( ~palette, ~colours, "pal1", rev(brewer.pal(9, "Greys")[-1]), "pal2", rev(brewer.pal(9, "Reds")[-8:-9]) ) verify_palettes(palettes, column_info, data)
library(tibble) library(grDevices) library(RColorBrewer) # explicit form data <- tribble( ~id, ~name, ~x, ~y, "foo", "Foo", 0.5, 0.7, "bar", "Bar", 1.0, 0.1 ) column_info <- tribble( ~id, ~geom, ~palette, "name", "text", NA, "foo", "funkyrect", "pal1", "bar", "funkyrect", "pal2" ) palettes <- list( pal1 = rev(brewer.pal(9, "Greys")[-1]), pal2 = rev(brewer.pal(9, "Reds")[-8:-9]) ) verify_palettes(palettes, column_info, data) # implicit palettes palettes <- list( pal1 = "Greys", pal2 = "Reds" ) verify_palettes(palettes, column_info, data) # passing a tibble should also work (for backwards compatibility) palettes <- tribble( ~palette, ~colours, "pal1", rev(brewer.pal(9, "Greys")[-1]), "pal2", rev(brewer.pal(9, "Reds")[-8:-9]) ) verify_palettes(palettes, column_info, data)
Verify the integrity of the row groups object
verify_row_groups(row_groups, row_info)
verify_row_groups(row_groups, row_info)
row_groups |
A data frame describing of how to group the rows
in
|
row_info |
A data frame describing the rows of
|
The row groups object with all expected rows.
library(tibble) row_groups <- tribble( ~group, ~level1, "foo", "Foo", "bar", "Bar" ) row_info <- tribble( ~id, ~group, "name", NA_character_, "foo1", "foo", "foo2", "foo", "bar1", "bar", "bar2", "bar" ) verify_row_groups(row_groups, row_info)
library(tibble) row_groups <- tribble( ~group, ~level1, "foo", "Foo", "bar", "Bar" ) row_info <- tribble( ~id, ~group, "name", NA_character_, "foo1", "foo", "foo2", "foo", "bar1", "bar", "bar2", "bar" ) verify_row_groups(row_groups, row_info)
Verify the integrity of the row info object
verify_row_info(row_info, data)
verify_row_info(row_info, data)
row_info |
A data frame describing the rows of
|
data |
A data frame with items by row and features in the columns.
Must contain one column named |
The row info object with all expected columns.
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo1", "Foo1", 0.5, 0.7, "foo2", "Foo2", 0.5, 0.8, "bar1", "Bar1", 1.0, 0.2, "bar2", "Bar2", 1.0, 0.1 ) row_info <- tribble( ~id, ~group, "foo1", "foo", "foo2", "foo", "bar1", "bar", "bar2", "bar" ) verify_row_info(row_info, data)
library(tibble) data <- tribble( ~id, ~name, ~x, ~y, "foo1", "Foo1", 0.5, 0.7, "foo2", "Foo2", 0.5, 0.8, "bar1", "Bar1", 1.0, 0.2, "bar2", "Bar2", 1.0, 0.1 ) row_info <- tribble( ~id, ~group, "foo1", "foo", "foo2", "foo", "bar1", "bar", "bar2", "bar" ) verify_row_info(row_info, data)