heatmap_column_group_labels | R Documentation |
Add Heatmap column group labels, specifically for ComplexHeatmap output.
heatmap_column_group_labels(
hm_group_list,
hm_drawn = NULL,
se = NULL,
add_group_label = TRUE,
add_group_line = TRUE,
add_group_box = FALSE,
group_line_buffer = grid::unit(1, "mm"),
group_line_lwd = 2,
group_line_requires_label = TRUE,
group_box_lwd = 2,
group_box_outer = TRUE,
font_cex = 1,
hm_title_base = NULL,
hm_body_base = NULL,
hm_title_base_default = "centered\nexpression_column_title_",
hm_body_base_default = "centered\nexpression_heatmap_body_1_",
y_offset_lines = 0,
endlines = 1,
use_gridtext = TRUE,
verbose = FALSE,
...
)
hm_group_list |
|
hm_drawn |
|
se |
|
add_group_label |
|
add_group_line |
|
add_group_box |
|
group_line_buffer |
|
group_line_lwd |
|
group_line_requires_label |
|
group_box_lwd |
|
group_box_outer |
|
font_cex |
|
hm_title_base |
|
hm_body_base |
|
hm_title_base_default , hm_body_base_default |
|
y_offset_lines |
|
endlines |
|
use_gridtext |
|
verbose |
|
... |
additional arguments are ignored. |
This function is currently experimental, and is intended only for
a specific scenario, to augment a ComplexHeatmap::Heatmap
object,
as produced by heatmap_se()
, that used the argument column_split
to sub-divide the heatmap columns into subgroups.
This function draws labels above the heatmap to describe group
factor values associated with column splits.
When there are multiple layers of grouping, this function will
also draw multiple layers. For example, when columns are split
by column_split=c("Treatment", "Time")
, it will produce a heatmap
where each column slice has one combination of Treatment and Time.
This function can be used to add a layer of labels by "Time"
,
and a layer of labels by "Treatment"
. The labels are shown by default
with a broad underline to indicate contiguous column slices that
contain the same "Treatment"
or "Time"
values.
The output can provide a cleaner visualization than the alternative of displaying colorized annotation boxes at the top of the heatmap.
There are two strategies for defining the column group data to display:
This option is recommended as the "easiest" method. It requires:
hm_group_list
provides a character
vector of colnames(colData(se))
.
Note that the columns are applied bottom-to-top, so it is sometimes
helpful to supply columns in reverse order for column_split
.
se
must be provided, since it supplies colData(se)
Each value in hm_group_list
is applied from bottom-to-top, to define
a row of labels. By default, add_group_line=TRUE
, so labels are also
underlined to indicate samples included in each group.
This option is recommended when labeling a subset of column slices, or when the column slice groups need to be customized in some way.
The Heatmap column_title
should (usually) be empty, so that no text
labels are drawn which may overlap the labels drawn by this function.
Use column_title=" "
(with a whitespace character) to prevent
ComplexHeatmap::Heatmap()
from using its internal default text label.
There usually needs to be whitespace above the heatmap, which
can be accomplished when drawing a Heatmap object hm
like this:
ComplexHeatmap::draw(hm, column_title="\n\n\n\n")
When also displaying a heatmap title as defined by heatmap_se()
,
the adjustment can be done like this:
ComplexHeatmap::draw(hm, column_title=paste0(attr(hm, "hm_title"), "\n\n\n\n"))
The arguments hm_title_base
and hm_body_base
should match the
heatmap name, which is defined in heatmap_se()
with data_type
,
usually prefixed "centered\n"
when the data is centered by that
function. For example, when data_type="abundance"
, the corresponding
argument value should be
hm_title_base="centered\nabundance_column_title_"
.
use detect_heatmap_components()
to help identify the appropriate
grid
elements available to be used by this function.
When the heatmap contains "column_title"
elements defined in
ComplexHeatmap::list_components()
, and there is no element
"global_column_title"
, the y_offset_lines
is adjusted down so that
the position is inside the column_title region, typically below the
column_title when using trailing whitespace (see argument
hm_title_buffer
in heatmap_se()
). However, when element
"global_column_title"
is present, the y_offset_lines
are not adjusted,
so that the position is above the column_title region. In this case, to
position the labels below the column_title, you can adjust
y_offset_lines
down manually like this: y_offset_lines=-9
.
Automate determining the column_title grid layout name.
Specifically when only one heatmapname_column_title_1
is present,
but there are multiple column groups, it should take the x-axis
coordinate values (left and right boundaries) from the heatmap body
instead of the column_title region.
When add_group_box=TRUE
, and row_split
indicates multiple row
groups, it should calculate the y-axis coordinate values (top and bottom
boundaries) using the full set of row groups.
Enable blank annotations, either by passing a subset se
, or by
annotations with no associated label.
Other jamses heatmaps:
detect_heatmap_components()
,
heatmap_se()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.