Skip to contents

Generates an upper-triangle heatmap of correlations between exposure variables, with side annotation bars indicating variable categories.

Usage

plot_heatmap_correlate_exposure(
  expomicset,
  exposure_cols = NULL,
  corr_threshold = NULL,
  annotation_colors = NULL,
  low = "#006666",
  mid = "white",
  high = "#8E0152",
  midpoint = 0
)

Arguments

expomicset

A MultiAssayExperiment object containing exposure data and correlation results.

exposure_cols

A character vector of exposure variable names to include in the plot. If NULL, includes all.

corr_threshold

A numeric value for filtering correlations by absolute value (e.g., 0.2).

annotation_colors

Optional named character vector of colors for exposure categories.

low

Color for strong negative correlations. Default is "#006666".

mid

Color for zero correlation. Default is "white".

high

Color for strong positive correlations. Default is "#8E0152".

midpoint

Midpoint for the color scale. Default is 0.

Value

A ggplot2 object assembled using patchwork, showing the correlation heatmap and annotation bars.

Details

This function:

  • Uses precomputed correlations from metadata(expomicset)$exposure_correlation$correlation_table.

  • Filters to an upper triangle matrix (i.e., only combinations where var1 <= var2).

  • Applies optional thresholding with corr_threshold to simplify visualization.

  • Adds top and left annotation bars colored by category_1 and category_2, respectively.

  • Harmonizes category colors across both axes using a single legend.

If annotation_colors is not supplied, a default palette is used. The resulting plot includes the heatmap, the sidebars, and a unified legend for variable categories.

Examples

if (FALSE) { # \dontrun{
plot_heatmap_correlate_exposure(expom)
plot_heatmap_correlate_exposure(expom, exposure_cols = c("pm25", "no2", "age"))
plot_heatmap_correlate_exposure(expom, corr_threshold = 0.2)
} # }