% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/foresttopr.R
\name{get_matching_snps}
\alias{get_matching_snps}
\title{Match association results across datasets by variant key}
\usage{
get_matching_snps(
  dfs,
  labels,
  gene_col = "ID",
  label_col = NULL,
  effect_type = c("OR", "beta")
)
}
\arguments{
\item{dfs}{A list of data frames containing variant-level association
results. Each data frame must contain chromosome and position columns
(\code{CHROM}, \code{POS}) and effect size information.}

\item{labels}{A character vector of dataset labels of the same length as
\code{dfs}. These labels identify the source of each matched effect estimate.}

\item{gene_col}{Character scalar specifying a column name in the reference
dataset used for labeling rows (e.g. gene or variant identifier).
Defaults to \code{"ID"}. This column is not used for matching.}

\item{label_col}{Optional character scalar specifying an alternative column
name in the reference dataset to use as a human-readable row label.
If \code{NULL}, \code{gene_col} is used for labeling.}

\item{effect_type}{Character scalar specifying the effect scale to use.
Either \code{"OR"} (odds ratio) or \code{"beta"} (regression coefficient).
Matching is case-insensitive. Effect estimates are converted between
scales as needed.}
}
\value{
A data frame containing matched variant-level effect estimates with
the following columns:
\describe{
\item{key}{Variant key constructed from chromosome and position.}
\item{label}{Row label used for display purposes.}
\item{set}{Dataset identifier corresponding to \code{labels}.}
\item{or}{Effect estimate on the requested scale.}
\item{p}{P-value associated with the effect estimate.}
\item{lcl}{Lower confidence interval bound.}
\item{ucl}{Upper confidence interval bound.}
}
}
\description{
\code{get_matching_snps()} aligns rows from multiple variant-level association
result tables using a genomic variant key constructed from chromosome and
position (e.g. \code{"CHR:POS"}). Effect estimates and confidence intervals are
standardized across datasets, while row labels are taken from the reference
dataset (the first element of \code{dfs}).

The function supports allele-aware matching and automatically corrects
effect directions when reference and alternate alleles are flipped between
datasets.

This function is typically used internally by \code{\link{foresttopr}} when
variant-level columns are detected, but may also be called directly to
prepare matched variant-level effect tables.
}
\details{
Variants are matched across datasets using a key constructed from
chromosome and position. Reference and alternate alleles are compared
between datasets, and effect estimates are automatically flipped when
allele orientation differs.

Confidence intervals are derived preferentially from explicit bounds,
standard errors, or p-values, depending on availability.

The returned table contains one row per matched variant per dataset.
}
\seealso{
\code{\link{foresttopr}}, \code{\link{get_matching_genes}}
}
\keyword{internal}
