% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mr_transform.R
\name{harmonize_mr_data}
\alias{harmonize_mr_data}
\title{Harmonize exposure and outcome SNP data}
\usage{
harmonize_mr_data(
  df,
  Outcome = NULL,
  Exposure = NULL,
  beta_sign = c("positive", "negative")
)
}
\arguments{
\item{df}{Data frame containing required columns: \code{beta_exposure},
\code{se_exposure}, \code{beta_outcome}, \code{se_outcome},
\code{Outcome}, \code{Exposure}. Allele columns may be supplied as
\code{NEA_exposure}/\code{EA_exposure}/\code{NEA_outcome}/\code{EA_outcome},
or as \code{ALLELE1} (NEA) / \code{ALLELE0} (EA) which are treated as
exposure alleles.}

\item{Outcome}{Optional; character string to set as the Outcome name when
the column is absent from \code{df}.}

\item{Exposure}{Optional; character string to set as the Exposure name when
the column is absent from \code{df}.}

\item{beta_sign}{Character string controlling the target sign for
\code{beta_exposure} after harmonization. One of \code{"positive"}
(default, forces beta_exposure >= 0) or \code{"negative"} (forces
beta_exposure <= 0). When a row is flipped, \code{beta_outcome} is
negated as a side effect and all allele columns are swapped consistently.}
}
\value{
A named list with two elements:
  \describe{
    \item{\code{check_df}}{Full working data frame retaining all allele
      columns after harmonization. Useful for quality-checking results.}
    \item{\code{input_df}}{Slim data frame ready for MR analysis, with
      columns: Instrument, beta_exposure, se_exposure, beta_outcome,
      se_outcome, Outcome, Exposure, ALLELE1, ALLELE0, A1FREQ.}
  }
}
\description{
Takes a data frame that already contains all required MR columns, aligns
outcome alleles to the exposure strand (Step 1), then standardizes the sign
of \code{beta_exposure} (Step 2). Returns both a full working data frame
(\code{check_df}) and a slim, renamed input data frame (\code{input_df}),
mirroring the output of \code{format_mr_input()}.
}
\examples{
result1 <- harmonize_mr_data(df = fi_49item)
head(result1$check_df)
head(result1$input_df)

# Force all exposure betas to be negative
result2 <- harmonize_mr_data(df = fi_49item, beta_sign = "negative")
head(result2$input_df)
}
