Creates a heatmap from an assay stored in a
SummarizedExperiment or
TreeSummarizedExperiment. Features are shown as rows and
samples as columns.
plotHeatmap(x, ...)
# S4 method for class 'TreeSummarizedExperiment'
plotHeatmap(
x,
assay.type = NULL,
row.var = NULL,
col.var = NULL,
scale = FALSE,
center = FALSE,
tree.name = "phylo",
show.tree = FALSE,
...
)
# S4 method for class 'SummarizedExperiment'
plotHeatmap(
x,
assay.type = NULL,
row.var = NULL,
col.var = NULL,
scale = FALSE,
center = FALSE,
...
)a
SummarizedExperiment
object.
Additional parameters controlling the visualization. When
show.tree = TRUE, additional arguments are passed to
plotRowTree to control the appearance of the tree.
Additional parameters include, for example:
scales: Facet scaling passed to
ggplot2::facet_grid() or
ggh4x::facet_nested().
(Default: "free")
tree.width: Relative width of the tree panel when
show.tree = TRUE.
(Default: 0.2)
Character scalar value defining which assay data to
use. (Default: "relabundance")
NULL or character vector. Variables from
rowData(x) used for row facetting.
(Default: NULL)
NULL or character vector. Variables from
colData(x) used for column facetting.
(Default: NULL)
Logical scalar. Should assay values be scaled for each
feature across samples?
(Default: FALSE)
Logical scalar. Should assay values be centered for
each feature across samples?
(Default: FALSE)
Character scalar. Name of the row tree to display
when x is a TreeSummarizedExperiment.
(Default: "phylo")
Logical scalar. Should the row tree be displayed?
Only available for TreeSummarizedExperiment.
(Default: TRUE)
A ggplot2 object. If show.tree = TRUE, the returned object is
a combined patchwork object containing the row tree and the heatmap.
plotHeatmap visualizes values from an assay as a heatmap. Values
can be optionally centered and/or scaled across samples for each feature,
which is useful for highlighting relative abundance patterns rather than
absolute abundances.
Additional variables from rowData(x) and colData(x) can be
used to facet the heatmap. When multiple row or column variables are
provided, nested facets are created using
ggh4x.
For TreeSummarizedExperiment objects, a row tree can be displayed
alongside the heatmap. When a tree is shown, only leaf nodes are plotted
and the heatmap rows are reordered to match the tree tip order.
data(GlobalPatterns)
tse <- GlobalPatterns
tse <- agglomerateByPrevalence(tse, rank = "Class")
# Plot raw counts
plotHeatmap(
tse,
assay.type = "counts"
)
#> Error in plotHeatmap(tse, assay.type = "counts"): argument "features" is missing, with no default
# Scale and center each feature
plotHeatmap(
tse,
assay.type = "counts",
scale = TRUE,
center = TRUE
)
#> Error in plotHeatmap(tse, assay.type = "counts", scale = TRUE, center = TRUE): argument "features" is missing, with no default
# Facet samples by metadata
plotHeatmap(
tse,
assay.type = "counts",
col.var = "SampleType"
)
#> Error in plotHeatmap(tse, assay.type = "counts", col.var = "SampleType"): argument "features" is missing, with no default
# Add phylogeny
plotHeatmap(
tse,
assay.type = "counts",
show.tree = TRUE
)
#> Error in plotHeatmap(tse, assay.type = "counts", show.tree = TRUE): argument "features" is missing, with no default