| foresttopr | R Documentation |
foresttopr() creates a forest plot visualizing effect estimates and
confidence intervals across one or more datasets. The function supports
odds ratios (OR) and regression coefficients (beta), allows matching rows
across datasets by a key column, and optionally displays human-readable
labels from a separate annotation column.
Effect estimates are automatically standardized across input datasets, and confidence intervals are derived preferentially from explicit bounds, standard errors, or p-values when necessary.
foresttopr(
dat = NULL,
legend_labels = NULL,
colors = NULL,
key_col = "ID",
label_col = NULL,
effect_type = c("OR", "beta"),
xlim = NULL,
xbreaks = NULL,
xlabel = NULL,
size = 2.5,
shape = 16,
alpha = 1,
points_dist = 0.6,
band_color = "grey96",
band_border_color = "grey96",
band_border_linewidth = 0.01,
sign_thresh = NULL,
ylabel_order = NULL,
scale = 1,
title = NULL,
title_text_size = 15,
axis_text_size = 12,
axis_title_size = 14,
show_shape_legend = TRUE,
show_color_legend = TRUE,
legend_position = "right",
legend_nrow = NULL,
legend_name = NULL,
legend_title_size = axis_text_size * 0.95,
legend_text_size = axis_text_size * 0.85,
match_on_gene = FALSE
)
dat |
A data frame or a list of data frames containing association results. Each data frame must contain an effect estimate column (e.g. OR or BETA) and a p-value column. If a single data frame is provided, it is internally wrapped into a list. |
legend_labels |
A character vector of labels corresponding to each
dataset in |
colors |
A character vector of colors to use for each dataset.
If |
key_col |
Character scalar giving the column name used to match rows
across datasets (e.g. gene identifier or variant ID). Defaults to |
label_col |
Optional character scalar giving the column name in the
reference dataset (the first element of |
effect_type |
Character scalar specifying the effect scale to plot.
Either |
xlim |
Numeric length-2 vector giving x-axis limits. If |
xbreaks |
Numeric vector or function specifying x-axis breaks.
If |
xlabel |
Character scalar giving the x-axis label. If |
size |
Numeric scalar or vector controlling point sizes for each dataset. |
shape |
Integer scalar or vector specifying point shapes for each dataset. |
alpha |
Numeric scalar or vector specifying point transparency. |
points_dist |
Numeric scalar controlling horizontal separation of points from different datasets within the same row. |
band_color |
Background color for alternating row bands. |
band_border_color |
Color for row band borders. |
band_border_linewidth |
Numeric scalar giving the line width for row band borders. |
sign_thresh |
Optional numeric scalar specifying a p-value threshold for highlighting statistically significant points via shape encoding. |
ylabel_order |
Optional character vector specifying the order of
rows on the y-axis. If |
scale |
Numeric scalar used to globally scale text and point sizes. |
title |
Optional character scalar giving the plot title. |
title_text_size |
Numeric scalar controlling title text size. |
axis_text_size |
Numeric scalar controlling axis text size. |
axis_title_size |
Numeric scalar controlling axis title text size. |
show_shape_legend |
Logical; whether to display the shape legend. |
show_color_legend |
Logical; whether to display the color legend. |
legend_position |
Character string specifying legend position.
One of |
legend_nrow |
Optional integer specifying the number of rows in the legend. |
legend_name |
Optional character scalar giving the legend title. |
legend_title_size |
Numeric scalar controlling legend title text size. |
legend_text_size |
Numeric scalar controlling legend text size. |
match_on_gene |
Logical; if |
A ggplot2 object representing the forest plot.
ggplot
foresttopr(
dat = list(
CD_UKBB |>
dplyr::arrange(P) |>
head(n = 10) |>
annotate_with_nearest_gene(),
CD_FINNGEN
),
key_col = "ID",
label_col = "Gene_Symbol",
legend_labels = c("CD_UKBB", "CD_FINNGEN"),
effect_type = "beta"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.