ggheatmap.Rdggheatmap() is the main function of the ggheatmap package. It constructs
a tile-able plot using ggplot and patchwork, that can be added to and used in
constructing panels.
ggheatmap(
table,
colv = NULL,
rowv = NULL,
hm_colors = "RdYlBu",
hm_color_values = NULL,
hm_color_breaks = waiver(),
hm_color_limits = NULL,
scale = FALSE,
center = FALSE,
cluster_rows = TRUE,
cluster_cols = TRUE,
dist_method = "euclidean",
clustering_method = "complete",
raster = FALSE,
rows_title = "",
column_title = "",
colors_title = "value",
fontsize = 11,
show_rownames = TRUE,
show_colnames = TRUE,
show_dend_row = TRUE,
show_dend_col = TRUE,
dend_lwd = 0.3,
dend_prop_row = 0.1,
dend_prop_col = 0.1,
group_track = TRUE,
group_label = FALSE,
group_track_topslack = 0,
group_label_angle = 0,
group_label_size = 3.5,
group_label_position = "center",
group_prop = 0.1,
group_colors = NULL,
group_lines = FALSE,
group_line_color = "black",
group_lty = "solid",
group_lwd = 0.3,
group_leg_ncol = 3,
row_facetting_space = 3,
colorbar_dir = "vertical"
)A table that can follow four formats:
If table is a data.frame or tbl and colv and rowv are provided,
colv will be plotted into the columns (observations), while the variables
provided as rowv will be plotted into the rows (variables).
If table is a grouped_tbl and cluster_cols = TRUE, a semi-supervised
clustering of the data will be performed instead only clustering within groups.
If table is a data.frame or tbl and only colv, all other columns
will be used as rowv.
If table is a matrix or data.frame and colv and rowv are NULL,
ggheatmap will plot it as-is (columns will be plotted as columns, rows as
rows of the heatmap). It is convenient, but less powerful.
Either NULL or the name of the column that contains the observation ID variable for the data.
Either NULL, a vector with names of columns to be plotted into the rows
of the heatmap, or a named list of vectors for a faceted plot (show_dend_row will then
be ignored).
Can be either:
A valid palette used by RColorBrewer. See: RColorBrewer::display.brewer.all()
A vector of colors to be interpolated
Either NULL or a vector of values used for interpolation
between colors. Passed to values from ggplot2::scale_fill_gradientn()
Breaks for heatmap colors. Passed to breaks from
ggplot2::scale_fill_gradientn()
A vector with length = 2 for limits of the heatmap
color scale. Passed to limits from ggplot2::scale_fill_gradientn().
If TRUE, data will be scaled (z-score)
If TRUE, data will be centered
If TRUE, rows will be clustered with stats::hclust()
If TRUE, columns will be clustered with stats::hclust()
Distance method passed to stats::dist(). Also supports
correlation distance (1-cor()), with dist_method passed to method from
stats::cor
Clustering method is passed to method from
stats::hclust()
If TRUE, ggplot2::geom_raster() will be used for the
heatmap tiles instead of ggplot2::geom_tile(). Will be recommended by
the function for large tables.
A title for row variables.
A title for the column variable.
A title for the color legend.
Base fontsize for plot, which will be used by the theme.
Ultimately passed to ggplot2::theme_minimal() as base_size.
If TRUE, row names will be shown in the heatmap.
If TRUE, column names will be shown in the heatmap.
If TRUE, the clustering dendrogram for the row variables will be shown to the left of the heatmap
If TRUE, the clustering dendrogram for the column variable will be shown on top of the heatmap.
Linewidth for the dendrogram drawing. Passed to ggtree::ggtree as size.
A value between 0 and 1. The proportion of the width occupied by the dendrogram.
A value between 0 and 1. The proportion of the height occupied by the dendrogram.
If table is a grouped_tbl and group_track = TRUE,
a track will be plot between the dendrogram and heatmap.
a logical indicating whether to label the groups directly.
If TRUE, show_dend_col will be set to FALSE.
a numeric, indicating space to add at the top of the group track. Useful for fitting names
an angle for the group labels
a numeric value to set the size of the group labels
one of: "left", "right" or "center", indicating where to write the group label if `group_label = TRUE
The proportion of the height of the heatmap that will be used for the group track.
A named vector with colors for each level in the grouping variable. If NULL, automatic colors will be used.
If TRUE, vertical lines will separate supervised clustering groups
Color of the vertical line
Group line type. See graphics::par
Group line width. See graphics::par
Number of columns in the groups legend. Passed to
ggplot2::guide_legend().
space in pts between row facets, if they exist
Places the colorbar either horizontal or vertically. See:
ggplot2::guide_colorbar
A ggplot object with class ggheatmap.