View source: R/effect_heatmap.R
plot_effect_heatmap | R Documentation |
Draws a heatmap of e.g. correlations between variables (see perform_correlation_tests). It is possible to draw only the lower triangular of the heatmap, order rows and columns with hierarchical clustering, and add circles for p-values.
plot_effect_heatmap(
data,
x,
y,
effect,
p = NULL,
p_limit = 0.1,
point_size_range = c(1, 6),
log2_effect = FALSE,
discretize_effect = FALSE,
breaks = 5,
clustering = TRUE,
dist_method = "euclidean",
clust_method = "ward.D2",
lower_tri = FALSE,
reverse_y = TRUE,
use_coord_fixed = TRUE,
symmetric_aspect_ratio = TRUE,
title = NULL,
subtitle = NULL,
fill_scale = NA
)
data |
a data frame with x and y variables and the effect (used to fill the tiles) |
x , y |
the column names of data with the x and y variables |
effect |
the column name of the effect, e.g. correlation |
p |
optional, the column name with p-values. If provided, points that scale by p-value are drawn on top of the heatmap tiles |
p_limit |
numeric, only p-values below the limit are plotted as points |
point_size_range |
a numeric vector of length 2. The upper and lower limits for the point sizes. This needs to be adjusted to make the point size look good when compared to the tiles |
log2_effect |
logical, whether the effect should be plotted on a logarithmic scale (in case of fold change etc.) |
discretize_effect |
logical, whether the effect range should be divided into discrete levels instead of using a continuous scale. Can sometimes make patterns more visible, but the hard limits can blur the big picture as well. |
breaks |
if |
clustering |
logical, whether the order of rows and columns should be ordered by hierarchical clustering? |
dist_method |
distance method used in clustering, see |
clust_method |
clustering method used in clustering, see |
lower_tri |
logical, should only the lower triangular be plotted? |
reverse_y |
logical, if |
use_coord_fixed |
logical, should the heatmap tiles be squares?
If yes, this uses |
symmetric_aspect_ratio |
logical, should the plot panel be a square? If yes, uses ggplot2::theme(aspect.ratio = 1). |
title , subtitle |
the title and subtitle of the plot |
fill_scale |
fill scale for the heatmap as returned by a ggplot function. Set to NA to choose the appropriate scale based on the class of the effect variable. |
All missing effects between variables are replaced by 0 before clustering,
since hclust
can't deal with missing values.
a ggplot object
cut
for discretizing the effect, dist
for distance calculation for clustering,
hclust
for hierarchical clustering.
# Compute correlations between variables
correlations <- perform_correlation_tests(example_set,
x = featureNames(example_set),
duplicates = TRUE
)
# Minimal example
plot_effect_heatmap(correlations, x = "X", y = "Y", effect = "Correlation_coefficient")
# Lower triangular with discrete effect and p-value dots
plot_effect_heatmap(correlations,
x = "X", y = "Y", effect = "Correlation_coefficient",
p = "Correlation_P", point_size_range = c(2, 8),
discretize_effect = TRUE, breaks = 7, lower_tri = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.