Creates a volcano plot using ggplot2 based on specified x and y variables, highlighting points that exceed significance and effect size thresholds.
Usage
plot_volcano(
data,
x_var,
y_var,
sig_thr = NULL,
effect_thr = NULL,
x_label = NULL,
y_label = paste0("-log10(", y_var, ")"),
title = NULL,
point_size = 0.5
)
Arguments
- data
A data frame containing the variables to be plotted.
- x_var
A string specifying the name of the column to be used as the x-axis (e.g., effect size or test statistic).
- y_var
A string specifying the name of the column to be used for computing
-log10(p)
on the y-axis (typically a p-value or adjusted p-value).- sig_thr
Optional numeric value specifying the significance threshold for p-values. If
NULL
, no significance filtering is applied.- effect_thr
Optional numeric value specifying the minimum absolute effect size threshold. If
NULL
, no effect size filtering is applied.- x_label
Optional string for the x-axis label. If
NULL
, usesx_var
as default.- y_label
Optional string for the y-axis label. Default is
paste0("-log10(", y_var, ")")
.- title
Optional string for the plot title.
- point_size
Numeric value for the size of the points in the scatter plot. Default is
0.5
.
Examples
df <- data.frame(
feature = LETTERS[1:10],
T_obs = rnorm(10),
p_value = runif(10),
p_adj = p.adjust(runif(10))
)
plot_volcano(df, x_var = "T_obs", y_var = "p_adj", sig_thr = 0.05, effect_thr = 1)