% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_tests.R
\name{adjust.pvalues}
\alias{adjust.pvalues}
\title{Adjust P-Values for Multiple Comparisons}
\usage{
adjust.pvalues(p.values, method = "BH")
}
\arguments{
\item{p.values}{Numeric vector of raw p-values, one per gene or probe.}

\item{method}{Character. Correction method passed to \code{p.adjust()}.
Common options are \code{"BH"} (Benjamini-Hochberg), \code{"bonferroni"},
and \code{"holm"}. Default is \code{"BH"}.}
}
\value{
A numeric vector of adjusted p-values, the same length and order
as the input. For the BH method values represent the estimated false
discovery rate (FDR); for Bonferroni and Holm they represent the
family-wise error rate.
}
\description{
Applies a multiple testing correction to a vector of raw p-values, reducing
the false discovery rate when many genes are tested simultaneously.
}
\details{
When \code{analyze.gene()} is applied across many probes in a loop, each
test is performed independently and p-values are not corrected for
multiplicity. This function should be applied to the resulting p-value
vector before interpreting significance. BH correction is recommended for
exploratory genomic analyses; Bonferroni is more conservative and suited
to confirmatory settings. For genome-wide analysis, prefer
\code{run.limma.de()} which handles correction internally.
}
\examples{
\donttest{
geo <- extract.expression(load.geo.soft(accession = "GDS507", log.transform = TRUE))
probe.ids <- find.probe.by.gene(geo$gene, c("GENE1", "GENE2", "GENE3"))

raw.pvals <- sapply(probe.ids, function(id) {
  expr <- get.gene.expression(geo$expression, id)
  df <- build.analysis.df(expr, geo$phenotype, geo$gene)
  analyze.gene(df)$p.value
})
adj.pvals <- adjust.pvalues(raw.pvals, method = "BH")
}

}
