% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/grs.R
\name{grs_check}
\alias{grs_check}
\title{Check and export a GRS weights file}
\usage{
grs_check(file, dest = NULL)
}
\arguments{
\item{file}{Character scalar. Path to the input weights file.
Read via \code{data.table::fread} (format auto-detected; handles
CSV, TSV, space-delimited, etc.).}

\item{dest}{Character scalar or \code{NULL}. Output path for the validated,
space-delimited weights file. When \code{NULL} (default), no file is
written and the validated \code{data.table} is returned invisibly only.}
}
\value{
A \code{data.table} with columns \code{snp}, \code{effect_allele},
and \code{beta}, returned invisibly.
}
\description{
Reads a SNP weights file, validates its content, and writes a
plink2-compatible space-delimited output ready for upload to UKB RAP.
}
\details{
The input file must contain at least the three columns below (additional
columns are ignored):
\describe{
\item{\code{snp}}{SNP identifier, expected in \code{rs} + digits format.}
\item{\code{effect_allele}}{Effect allele; must be one of A / T / C / G.}
\item{\code{beta}}{Effect size (log-OR or beta coefficient); must be numeric.}
}

Checks performed:
\itemize{
\item Required columns present.
\item No \code{NA} values in the three required columns.
\item No duplicate \code{snp} identifiers.
\item \code{snp} matches \code{rs[0-9]+} pattern (warning if not).
\item \code{effect_allele} contains only A / T / C / G (warning if not).
\item \code{beta} is numeric (error if not).
}
}
\examples{
tmp_in <- tempfile(fileext = ".csv")
weights <- data.frame(
  snp           = c("rs1234567", "rs2345678", "rs3456789"),
  effect_allele = c("A", "T", "G"),
  beta          = c(0.12, -0.05, 0.23)
)
write.csv(weights, tmp_in, row.names = FALSE)

w <- grs_check(tmp_in)
w

# Save validated weights to a file
tmp_out <- tempfile(fileext = ".txt")
grs_check(tmp_in, dest = tmp_out)
}
