Create a complex heatmap using base graphics
heat_map(
x,
scale = FALSE,
scale_method = "range",
dist_method = "euclidean",
clust_method = "complete",
round = 2,
tree = FALSE,
tree_x = NULL,
tree_size_x = 1,
tree_scale_x = FALSE,
tree_cut_x = NULL,
tree_split_x = 1,
tree_label_x = FALSE,
tree_label_size_x = 0.1,
tree_label_col_x = "grey40",
tree_label_col_alpha_x = 1,
tree_label_text_x = NA,
tree_label_text_font_x = 1,
tree_label_text_size_x = 1,
tree_label_text_col_x = "black",
tree_label_text_col_alpha_x = 1,
tree_y = NULL,
tree_size_y = 1,
tree_scale_y = FALSE,
tree_cut_y = NULL,
tree_split_y = 1,
tree_label_y = FALSE,
tree_label_size_y = 0.1,
tree_label_col_y = "grey40",
tree_label_col_alpha_y = 1,
tree_label_text_y = NA,
tree_label_text_font_y = 1,
tree_label_text_size_y = 1,
tree_label_text_col_y = "black",
tree_label_text_col_alpha_y = 1,
cell_shape = "rect",
cell_size = FALSE,
cell_col_palette = c("red", "blue", "green", "orange", "magenta", "purple"),
cell_col_scale,
cell_col_alpha = 1,
cell_col_empty = "white",
cell_border_line_type = 1,
cell_border_line_width = 1,
cell_border_line_col = "black",
cell_border_line_col_alpha = 1,
cell_text = FALSE,
cell_text_font = 1,
cell_text_size = 1,
cell_text_col = "white",
cell_text_col_alpha = 1,
bar_size_x = 1,
bar_values_x = NULL,
bar_label_x = NULL,
bar_label_text_font_x = 1,
bar_label_text_size_x = 1,
bar_label_text_col_x = "black",
bar_label_text_col_alpha_x = 1,
bar_fill_x = "grey40",
bar_fill_alpha_x = 1,
bar_line_type_x = 1,
bar_line_width_x = 1,
bar_line_col_x = "black",
bar_line_col_alpha_x = 1,
bar_size_y = 1,
bar_values_y = NULL,
bar_label_y = NULL,
bar_label_text_font_y = 1,
bar_label_text_size_y = 1,
bar_label_text_col_y = "black",
bar_label_text_col_alpha_y = 1,
bar_fill_y = "grey40",
bar_fill_alpha_y = 1,
bar_line_type_y = 1,
bar_line_width_y = 1,
bar_line_col_y = "black",
bar_line_col_alpha_y = 1,
axis_text_x = NULL,
axis_text_side_x = "bottom",
axis_text_font_x = 1,
axis_text_size_x = 1,
axis_text_col_x = "black",
axis_text_col_alpha_x = 1,
axis_text_angle_x = 3,
axis_text_adjust_x = 0.45,
axis_label_x = NULL,
axis_label_font_x = 2,
axis_label_size_x = 1.2,
axis_label_col_x = "black",
axis_label_col_alpha_x = 1,
axis_ticks_length_x = 1,
axis_text_y = NULL,
axis_text_side_y = "left",
axis_text_font_y = 1,
axis_text_size_y = 1,
axis_text_col_y = "black",
axis_text_col_alpha_y = 1,
axis_text_angle_y = 1,
axis_text_adjust_y = 0.45,
axis_label_y = NULL,
axis_label_font_y = 2,
axis_label_size_y = 1.2,
axis_label_col_y = "black",
axis_label_col_alpha_y = 1,
axis_ticks_length_y = 1,
margins = c(NA, NA, NA, NA),
title = NULL,
title_text_font = 2,
title_text_size = 1.5,
title_text_col = "black",
title_text_col_alpha = 1,
legend = TRUE,
legend_size = 1,
legend_col_scale_size = 1,
legend_title = NULL,
legend_title_text_font = 2,
legend_title_text_size = 1,
legend_title_text_col = "black",
legend_title_text_col_alpha = 1,
legend_text_font = 1,
legend_text_size = 1,
legend_text_col = "black",
legend_text_col_alpha = 1,
popup = TRUE,
popup_size = c(7, 7),
...
)
matrix or data.frame containing the data to display in the heatmap.
logical indicating whether the data should be scaled prior to
constructing the heatmap. Addition options include "column"
or
"row"
to indicate whether scaling should be performed across
rows
or columns
.
indicates the type of scaling to perform on rows
or columns
as indicated by scale
, options include
"range"
, "mean"
or "zscore"
. Set to "range"
by
default.
indicates the type of distance metric to use when
constructing dendrograms, set to "euclidean"
distance by default.
See ?dist
for alternatives.
indicates the type of agglomeration method to use when
constructing performing hierarchical clustering, set to "complete"
by default. See ?hclust
for alternatives.
indicates the number of decimal places to round values when
cell_text = TRUE
and values are displayed in the heatmap, set to 2
decimal places by default
options include "row"
, "y"
, "column"
,
"x"
or "both"
to indicate the axes for which dendrograms
should be constructed, set to FALSE by default. This argument overrides the
tree_x
and tree_y
arguments.
logical indicating whether dendrograms should be constructed for the x axis (columns), set to NULL by default.
numeric to control the height of the dendrogram for the x axis, set to 1 by default.
logical indicating whether the branch heights of the x axis dendrogram should be scaled for better visualisation, set to FALSE by default.
either a numeric ranging from 0 to 1 indicating the branch cut height for x axis dendrogram or an integer indicating the desired number of clusters to obtain by cutting the x axis dendrogram. Alternatively, clusters can be manually defined by specifying the number of columns to include in each cluster (i.e. c(3,4,5)).
a numeric to control the spacing between x axis tree splits, set to 1 by default. Setting the argument to 0 will remove a axis tree splits.
logical indicating whether a label should be added for
each cluster within the x axis tree when tree_cut_x
is specified,
set to FALSE by default.
numeric to control the height of the tree cluster labels for the x axis tree, set to 0.1 by default.
vector of colours to use for x axis tree cluster labels, set to "grey40" by default.
numeric to control the transparency of the x axis tree cluster labels, set to 1 by default to use solid colours.
a vector of text to include in the x axis tree cluster labels, set to NA by default.
a vector of font types to use for text in x
axis cluster labels, set to 1 by default for plain text. See font
in
?par
for alternatives.
a vector of numerics to control the size of the text in the x axis cluster labels, set to 1 by default.
a vector of colours to control the colour of
text in x axis cluster labels, set to "black"
by default.
a vector of numerics to control the transparency of text in x axis cluster labels, set to 1 by default to use solid colours.
logical indicating whether dendrograms should be constructed for the y axis (rows), set to NULL by default.
numeric to control the width of the dendrogram for the y axis, set to 1 by default.
logical indicating whether the branch heights of the y axis dendrogram should be scaled for better visualisation, set to FALSE by default.
either a numeric ranging from 0 to 1 indicating the branch cut height for y axis dendrogram or an integer indicating the desired number of clusters to obtain by cutting the y axis dendrogram. Alternatively, clusters can be manually defined by specifying the number of rows to include in each cluster (i.e. c(3,4,5)).
a numeric to control the spacing between y axis tree splits, set to 1 by default. Setting the argument to 0 will remove a axis tree splits.
logical indicating whether a label should be added for
each cluster within the y axis tree when tree_cut_y
is specified,
set to FALSE by default.
numeric to control the width of the tree cluster labels for the y axis tree, set to 0.1 by default.
vector of colours to use for y axis tree cluster labels, set to "grey40" by default.
numeric to control the transparency of the y axis tree cluster labels, set to 1 by default to use solid colours.
a vector of text to include in the y axis tree cluster labels, set to NA by default.
a vector of font types to use for text in y
axis cluster labels, set to 1 by default for plain text. See font
in
?par
for alternatives.
a vector of numerics to control the size of the text in the y axis cluster labels, set to 1 by default.
a vector of colours to control the colour of
text in y axis cluster labels, set to "black"
by default.
a vector of numerics to control the transparency of text in y axis cluster labels, set to 1 by default to use solid colours.
indicates the shape to use for the cells in the heatmap,
options include "rect"
, "circle"
or "diamond"
.
logical indicating whether each cell in the heatmap should
be scaled by the value in x
, set to FALSE by default. Alternatively,
a matrix of the same dimensions as x
containing the values by which
the size of each cell should be scaled.
a vector of colours from which colours are selected for columns containing non-numeric data.
a vector of colours to use for the colour scale of numeric values, set to a hybrid colour-blind friendly viridis colour palette by default.
a numeric to control the fill transparency of cells within the heatmap, set to 1 by default to use solid colours.
a colour to use for missing values in x
, set to
"white"
by default.
a integer to indicate the type of line to use
for cell borders, set to 1 by default for solid lines. See lty
in
?par
for alternatives.
a numeric to control the with of cell borders, set to 1 by default.
indicates the colour to use for cell borders, set
to "black"
by default.
numeric to control the transparency of cell borders, set to 1 by default to use solid colours.
logical indicating whether the values in x
should be
displayed in each cell of the heatmap, set to FALSE by default.
an integer to control the font face of cell text, set
to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of cell text, set to 1 by default.
colour to use for cell text, set to "white"
by
default,
numeric ranging from 0 to 1 to control the transparency of cell text, set to 1 by default to use solid colours for cell text.
numeric to control the height of x axis bar plot, set to 1 by default.
a vector of values to display in x axis bar plot,
supplied in the order matching the original columns of x
or named
with the column names of x
. The values supplied to
bar_values_x
will be internally reordered to match the order of
columns as determined by hierarchical clustering.
axis label to use for the x axis bar plot.
font to use for the axis label of the x axis bar
plot, set to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of the axis text in x axis bar plots, set to 1 by default.
colour to use for the axis text in x axis bar
plot, set to "black"
by default.
numeric ranging from 0 to 1 to control the transparency of axis text in x axis bar plot, set to 1 by default to use solid colours.
a vector of colours to use for the bars in the x axis bar
plot, set to "grey40"
by default.
a numeric ranging from 0 to 1 to control the fill transparency of bars in x axis bar plot, set to 1 by default to use solid colours.
integer to control the line type of bar borders in the
x axis bar plot, set to 1 by default to use solid lines. See lty
in
?par
for alternatives.
numeric to control the width bar borders in x axis bar plot, set to 1 by default.
colour to use for bar borders in x axis bar plot, set
to "black"
by default.
numeric ranging from 0 to 1 to control the transparency of bar borders in x axis bar plot, set to 1 by default.
numeric to control the width of y axis bar plot, set to 1 by default.
a vector of values to display in y axis bar plot,
supplied in the order matching the original rownames of x
or named
with the row names of x
. The values supplied to bar_values_y
will be internally reordered to match the order of rows as determined by
hierarchical clustering.
axis label to use for the y axis bar plot.
font to use for the axis label of the y axis bar
plot, set to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of the axis text in y axis bar plots, set to 1 by default.
colour to use for the axis text in y axis bar
plot, set to "black"
by default.
numeric ranging from 0 to 1 to control the transparency of axis text in y axis bar plot, set to 1 by default to use solid colours.
a vector of colours to use for the bars in the y axis bar
plot, set to "grey40"
by default.
a numeric ranging from 0 to 1 to control the fill transparency of bars in y axis bar plot, set to 1 by default to use solid colours.
integer to control the line type of bar borders in the
y axis bar plot, set to 1 by default to use solid lines. See lty
in
?par
for alternatives.
numeric to control the width bar borders in y axis bar plot, set to 1 by default.
colour to use for bar borders in y axis bar plot, set
to "black"
by default.
numeric ranging from 0 to 1 to control the transparency of bar borders in y axis bar plot, set to 1 by default.
vector of text to use for x axis labels supplied in the
order matching the constructed heatmap, set to NULL by default to use the
column names of x
.
indicates whether the x axis text should be on the
1 - "bottom"
or 3 - "top"
of the heatmap, set to
"bottom"
by default. All other heatmap components, including the
tree, tree labels and bar plot will be positioned on the opposite side to
the axis text.
integer to control the font face of x axis labels,
set to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of x axis text, set to 1 by default.
colour to use for x axis text labels, set to
"black"
by default.
numeric ranging from 0 to 1 to control the transparency of x axis text labels, set to 1 by default to use solid text colours.
integer to control the angle of x axis text labels
relative to the x axis, set to 3 by default. See las
in ?par
for alternatives.
numeric to adjust position x axis text relative to x axis ticks, set to 0.45 by default.
label to use for the x axis.
integer to control the font face of the x axis label, set to 2 by default.
numeric to control the size of the x axis label, set to 1.2 by default.
colour to use for x axis label text, set to
"black"
by default.
numeric ranging from 0 to 1 to control the transparency of the x axis label text, set to 1 by default to use solid colours.
numeric to control the length of the x axis ticks, set to 1 by default.
vector of text to use for y axis labels supplied in the
order matching the constructed heatmap, set to NULL by default to use the
row names of x
.
indicates whether the y axis text should be on the
2 - "left"
or 4 - "right"
of the heatmap, set to
"left"
by default. All other heatmap components, including the tree,
tree labels and bar plot will be positioned on the opposite side to the
axis text.
integer to control the font face of y axis labels,
set to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of y axis text, set to 1 by default.
colour to use for y axis text labels, set to
"black"
by default.
numeric ranging from 0 to 1 to control the transparency of y axis text labels, set to 1 by default to use solid text colours.
integer to control the angle of y axis text labels
relative to the y axis, set to 3 by default. See las
in ?par
for alternatives.
numeric to adjust position y axis text relative to y axis ticks, set to 0.45 by default.
label to use for the y axis.
integer to control the font face of the y axis label, set to 2 by default.
numeric to control the size of the y axis label, set to 1.2 by default.
colour to use for y axis label text, set to
"black"
by default.
numeric ranging from 0 to 1 to control the transparency of the y axis label text, set to 1 by default to use solid colours.
numeric to control the length of the y axis ticks, set to 1 by default.
vector of numerics to control the size of the margins around
the bottom
, left
, top
and right
of the heatmap.
Setting any of these values to NA will allow for internal computation of
optimal heatmap margins.
text to include in the title above the heatmap.
integer to control the font face for the heatmap
title, set to 2 by default. See font
in ?par
for
alternatives.
numeric to control the size of the text in the heatmap title, set to 1.2 by default.
colour to use for text in heatmap title, set to
"black"
by default.
numeric ranging from 0 to 1 to control the transparency of text in heatmap title, set to 1 by default for solid colours.
logical indicating whether to include a legend in the heatmap,
set to TRUE by default. Alternatively, "size"
, "shape"
or
"both"
to indicate the type(s) of legends to include in the heatmap.
numeric to control the amount of space allocated to the legend, set to 1 by default.
numeric to control the width of the legend colour scale relative to the allocated space for the legend, set to 1 by default. legend_title = NULL,
a vector of length two containing text to be displayed above the cell colour and size legends respectively.
integer to control the font face for the
heatmap legends, set to 2 by default for bold font. See font
in
?par
for alternatives.
numeric to control the size of the text in the heatmap legend titles, set to 1 by default.
colour to use for text in heatmap legend titles,
set to "black"
by default.
numeric ranging from 0 to 1 to control the transparency of text in heatmap legend titles, set to 1 by default for solid colours.
integer to control the font face for legend text, set
to 1 by default. See font
in ?par
for alternatives.
numeric to control the size of text in the legend, set to 1 by default.
colour to use for text in the legend, set to
"black"
.
numeric to control the transparency of text in the legend, set to 1 by default to use solid colours.
logical indicating whether the heatmap should be constructed in a popup window, set to TRUE by default.
vector to control the height and width of the popup window
in inches, set to c(7,7)
.
not in use.
a recorded heatmap.