verify_palettes {funkyheatmap} | R Documentation |
Verify the integrity of the palettes object
Description
Verify the integrity of the palettes object
Usage
verify_palettes(palettes, column_info, data)
Arguments
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"
|
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.
|
data |
A data frame with items by row and features in the columns.
Must contain one column named "id" .
|
Value
The palettes object with all expected columns.
Examples
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)
[Package
funkyheatmap version 0.5.0
Index]