plotHeatmap | R Documentation |
Heatmap
plotHeatmap(object, ...)
## S4 method for signature 'SingleCellExperiment'
plotHeatmap(object, ...)
## S4 method for signature 'SummarizedExperiment'
plotHeatmap(
object,
assay = 1L,
interestingGroups = NULL,
scale = c("row", "column", "none"),
clusteringMethod = "ward.D2",
clusterRows = TRUE,
clusterCols = TRUE,
showRownames = isTRUE(nrow(object) <= 30L),
showColnames = TRUE,
treeheightRow = 50L,
treeheightCol = 50L,
color = getOption(x = "acid.heatmap.color", default = AcidPlots::blueYellow),
legendColor = getOption(x = "acid.heatmap.legend.color", default =
AcidPlots::synesthesia),
breaks = seq(from = -3L, to = 3L, by = 0.25),
legendBreaks = seq(from = -3L, to = 3L, by = 1L),
borderColor = NULL,
title = NULL,
convertGenesToSymbols = showRownames,
...
)
object |
Object. |
... |
Passthrough arguments to |
assay |
|
interestingGroups |
|
scale |
|
clusteringMethod |
|
clusterRows , clusterCols |
|
showRownames , showColnames |
|
treeheightRow , treeheightCol |
|
color |
We generally recommend these hexadecimal functions from the viridis
package, in addition to our
Alternatively, colors can be defined manually using hexadecimal values
(e.g. |
legendColor |
|
breaks |
|
legendBreaks |
|
borderColor |
|
title |
|
convertGenesToSymbols |
|
Plot.
Here we're scaling simply by calculating the standard score (z-score).
mu: mean.
sigma: standard deviation.
x: raw score (e.g. count matrix).
z: standard score (z-score).
z = (x - mu) / sigma
See also:
pheatmap:::scale_rows()
.
scale()
for additional scaling approaches.
Row- and column-wise hierarchical clustering is performed when clusterRows
and/or clusterCols
are set to TRUE
. Internally, this calls hclust()
,
and defaults to the Ward method.
Automatic hierarchical clustering of rows and/or columns can error for some datasets. When this occurs, you'll likely see this error:
Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call
In this case, either set clusterRows
and/or clusterCols
to FALSE
, or
you can attempt to pass an hclust
object to these arguments. This is
recommended as an alternate approach to be used with pheatmap()
, which is
called internally by our plotting code. Here's how this can be accomplished:
mat <- assay(mat) dist <- dist(mat) hclust <- hclust(dist, method = "ward.D2")
Updated 2021-05-17.
Michael Steinbaugh, Rory Kirchner
pheatmap::pheatmap()
.
RColorBrewer::brewer.pal()
.
stats::cor()
.
stats::hclust()
.
data(
RangedSummarizedExperiment,
SingleCellExperiment_splatter,
package = "AcidTest"
)
## SummarizedExperiment ====
object <- RangedSummarizedExperiment
## Row scaling requires non-zero rows.
object <- AcidGenerics::nonzeroRowsAndCols(object)
## Symmetric row-scaled breaks (recommended).
plotHeatmap(
object,
scale = "row",
color = AcidPlots::blueYellow,
breaks = seq(from = -2L, to = 2L, by = 0.25),
legendBreaks = seq(from = -2L, to = 2L, by = 1L)
)
## Using custom hexadecimal color input.
if (goalie::isInstalled("RColorBrewer")) {
color <- rev(RColorBrewer::brewer.pal(n = 11L, name = "PuOr"))
color <- grDevices::colorRampPalette(color)
head(color)
plotHeatmap(
object = object,
scale = "row",
color = color,
breaks = seq(from = -2L, to = 2L, by = 0.25),
legendBreaks = seq(from = -2L, to = 2L, by = 1L)
)
}
## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
## Row scaling requires non-zero rows.
object <- AcidGenerics::nonzeroRowsAndCols(object)
plotHeatmap(object)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.