% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DANDELION.R
\name{med_gene}
\alias{med_gene}
\title{Apply DANDELION to Identify Candidate Disease Proximal Genes}
\usage{
med_gene(
  p.trans,
  p.wes,
  ref.table,
  gene1.list,
  target.fdr = 0.1,
  dist = 5e+06,
  gene1.type = c("SNP", "Gene"),
  SNP.ref = NULL,
  n.cores = 1,
  verbose = FALSE
)
}
\arguments{
\item{p.trans}{A numeric matrix of trans-regulatory association p-values.
Rows are candidate disease proximal genes (\code{gene2}), and columns are
exposures (\code{gene1}), either distal genes or SNPs. Row names and column names
must be provided. (e.g., from trans-eQTL studies like eQTLGen)}

\item{p.wes}{A named numeric vector of gene-level trait association p-values (e.g., from WES burden tests or GWAS-based gene-level tests).
Note: Ensure that names (Gene Symbols) match the row names of \code{p.trans}}

\item{ref.table}{A data frame containing gene annotation and genomic positions.
Required columns are \code{gene_name}, \code{type}, \code{Chromosome}, \code{start}, and \code{end}.
\code{Chromosome} should use the format \code{chr1}, \code{chr2}, etc.}

\item{gene1.list}{A character vector of candidate exposures to analyze. These
values must be a subset of \code{colnames(p.trans)}.}

\item{target.fdr}{False Discovery Rate threshold. DANDELION uses this to decide which gene pairs are statistically significant. Default is 0.1.}

\item{dist}{The cis-window size (in base pairs). Genes within this distance from the exposure will be excluded to focus on true distal (trans) effects.
Default is 5e6.}

\item{gene1.type}{Exposure type. Must be either \code{"SNP"} or \code{"Gene"}.}

\item{SNP.ref}{Optional SNP annotation data frame used when \code{gene1.type = "SNP"}.
Required columns are \code{SNP}, \code{SNPPos}, and \code{SNPChr}. \code{SNPChr} can be \code{1} or
\code{chr1}; both formats are accepted.}

\item{n.cores}{Number of cores for parallel execution. On non-Windows systems,
values larger than 1 use \code{parallel::mclapply()}. On Windows, the function
falls back to single-core execution.}

\item{verbose}{Logical. If \code{TRUE}, progress messages are printed. Default is \code{FALSE}.}
}
\value{
A list with three elements: \code{gene1}, the analyzed exposures with at
least one valid DANDELION result; \code{mat.sig}, a matrix encoding significant
gene1-gene2 pairs; and \code{mat.p}, a matrix of DANDELION p-values.
}
\description{
Applies the DANDELION procedure to integrate trans-regulatory association
p-values and gene-level trait association p-values. The exposure side can be
either distal genes or SNPs. For clarity, exposures are referred to as
\code{gene1}, and candidate disease proximal genes are referred to as \code{gene2}.
}
\examples{
set.seed(1)
p.trans <- matrix(runif(60, 0.001, 0.9), nrow = 12, ncol = 5)
rownames(p.trans) <- paste0("G", 1:12)
colnames(p.trans) <- paste0("E", 1:5)
p.wes <- runif(12, 0.001, 0.9)
names(p.wes) <- paste0("G", 1:12)
ref.table <- data.frame(
  gene_name = c(paste0("G", 1:12), paste0("E", 1:5)),
  type = "protein_coding",
  Chromosome = "chr1",
  start = seq_len(17) * 1e7,
  end = seq_len(17) * 1e7 + 1000
)
res <- med_gene(
  p.trans = p.trans,
  p.wes = p.wes,
  ref.table = ref.table,
  gene1.list = colnames(p.trans),
  gene1.type = "Gene"
)

}
