Skip to contents

This function visualizes the relationship between the mean and variance of log2-transformed expression values across genes. A smooth 2D kernel density estimate is shown as a white-to-blue background, and genes falling in low-density regions are highlighted as black dots.

Usage

plot_mean_variance_density(
  X,
  title = NULL,
  x_label = NULL,
  y_label = NULL,
  offset = 0.5,
  density_grid_size = 500,
  outlier_quantile = 0.75,
  point_size = 1
)

Arguments

X

A numeric matrix or data.frame with samples in rows and genes in columns. Typically the output from limma::voom (i.e., voom(data)$E).

title

Optional title for the plot.

x_label

Optional label for the x-axis.

y_label

Optional label for the y-axis.

density_grid_size

Resolution of the KDE grid (default is 500).

outlier_quantile

Genes below this KDE quantile are shown as outliers (default is 0.75).

point_size

Size of points. Default is 1.

Value

A ggplot2 object displaying the mean-variance density plot.