Skip to contents

This function overlays a heatmap of residuals on a melatonin profile plot, visualizing the goodness of fit across the Region of Interest (ROI) search grid.

Usage

plot_roi_heatmap(
  plot,
  data = NULL,
  roi_grid = NULL,
  residuals = NULL,
  datetime_ref = NULL
)

Arguments

plot

A ggplot object. The base plot to which the heatmap should be added.

data

A dataframe containing the melatonin profile with datetime and melatonin values.

roi_grid

A dataframe containing roi grid points (ROI search area).

residuals

A numeric vector of residuals corresponding to roi_grid.

Value

A ggplot object with the residual heatmap overlay.

Details

  • The color gradient represents residual values, with lower residuals indicating better fit.

  • Residuals are log-transformed for visualization.

Examples

if (FALSE) { # \dontrun{
  plot <- ggplot2::ggplot(profile_data, ggplot2::aes(x = datetime, y = melatonin)) +
      ggplot2::geom_point()
  plot <- plot_roi_heatmap(plot, data = profile_data, roi_grid = grid, residuals = res)
} # }