% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mr_forest.R
\name{GWAS_forest}
\alias{GWAS_forest}
\title{Generate Instrument-level Forest Plots for Mendelian Randomization}
\usage{
GWAS_forest(
  MR_input_data,
  report_form = "Beta",
  custom_xlim = NULL,
  dot_size = 2,
  axis_text_size = 10,
  axis_title_size = 12,
  digits = 2,
  label_text_size = 3,
  log_scale = FALSE
)
}
\arguments{
\item{MR_input_data}{Harmonised MR input data frame. Must contain Outcome, Exposure,
Instrument, beta_exposure, se_exposure, beta_outcome, and se_outcome columns.}

\item{report_form}{Character string or vector indicating the standard
output scale for each outcome (e.g., "Beta", "OR", "HR"). Defaults to "Beta".}

\item{custom_xlim}{Optional numeric vector of length 2 providing custom
limits for the x-axis. If NULL, limits are determined by the data.}

\item{dot_size}{Numeric value specifying the size of the points. Default is 2.}

\item{axis_text_size}{Numeric value specifying the font size for axis labels.
Default is 10.}

\item{axis_title_size}{Numeric value specifying the font size for axis titles.
Default is 12.}

\item{digits}{Integer specifying the number of decimal places for labels.
Default is 2.}

\item{label_text_size}{Numeric value specifying the size of estimate labels
(Beta/OR/HR and 95 percent CI) shown on the plot. Default is 3.}

\item{log_scale}{Logical; if \code{TRUE} and \code{report_form} is
\code{"OR"} or \code{"HR"}, estimates are kept on the log scale instead
of being exponentiated. The x-axis label becomes \code{log(OR)} or
\code{log(HR)} and the reference line is drawn at 0. Default is
\code{FALSE}.}
}
\value{
A \code{GWASForestPlots} object containing one \code{ggplot}
  per outcome-exposure pair, with instrument-level (SNP) causal estimates
  and a pooled IVW estimate. Use \code{export_forest_plots()} to
  write plots to disk with optional filtering.
}
\description{
Creates a forest plot for each instrument (SNP) within the MR analysis,
including a pooled IVW estimate at the top for comparison.
}
\examples{
\donttest{
data("merged_data")
input3 <- harmonize_mr_data(df = merged_data)$input_df

gwas_plots <- GWAS_forest(
  MR_input_data   = input3,
  report_form     = c("Beta","OR"),
  custom_xlim     = NULL,
  dot_size        = 2,
  axis_text_size  = 10,
  axis_title_size = 12,
  digits          = 2,
  label_text_size = 3,
  log_scale       = FALSE
)

# Retrieve the exact outcome/exposure labels stored in the object
out_name <- gwas_plots@outcomes[1]   # "fi_49item"
exp_name <- gwas_plots@exposures[1]  # "Zn"

# Export all instrument-level plots as PNG (commented — writes to disk)
# export_forest_plots(gwas_plots, save_dir = tempdir(), file_type = "jpeg")

# Export plots for one outcome only
# export_forest_plots(gwas_plots, save_dir = tempdir(), outcome = out_name)

# Export plots for one exposure only
# export_forest_plots(gwas_plots, save_dir = tempdir(), exposure = exp_name)

# Export one specific outcome-exposure pair
# export_forest_plots(gwas_plots, save_dir = tempdir(), outcome = out_name, exposure = exp_name)
}
}
