% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_tests.R
\name{fit.lasso}
\alias{fit.lasso}
\title{Fit LASSO Regression for Multi-Gene Biomarker Discovery}
\usage{
fit.lasso(expression.matrix, phenotype.vector, alpha = 1, nfolds = 10)
}
\arguments{
\item{expression.matrix}{Numeric matrix of gene expression values as returned
by \code{extract.expression()$expression}. Rows are probes, columns are
samples. The matrix is transposed internally so samples become rows as
required by \code{glmnet}.}

\item{phenotype.vector}{Factor or integer vector of binary phenotype labels,
one per sample (e.g., \code{0} for control, \code{1} for disease). Must
be the same length as the number of columns in \code{expression.matrix}.}

\item{alpha}{Numeric. Elastic net mixing parameter. \code{1} (default) gives
pure LASSO; \code{0} gives Ridge; values between 0 and 1 give elastic net.}

\item{nfolds}{Integer. Number of cross-validation folds. Default is \code{10}.}
}
\value{
A \code{cv.glmnet} object. Key elements:
\describe{
\item{lambda.min}{Lambda with minimum cross-validated error.}
\item{lambda.1se}{Largest lambda within 1 SE of the minimum (sparser model).}
\item{glmnet.fit}{The full sequence of fitted models across lambda values.}
}
Extract selected genes with \code{coef(fit, s = "lambda.1se")}; probes with
non-zero coefficients are the LASSO-selected biomarkers.
}
\description{
Applies cross-validated LASSO logistic regression to identify a sparse set
of genes that jointly predict a binary phenotype. Unlike univariate tests,
LASSO accounts for the joint contribution of all genes simultaneously,
automatically penalizing redundant predictors.
}
\details{
LASSO is suited to high-dimensional genomic data where the number of genes
far exceeds samples. It shrinks most coefficients to exactly zero, retaining
only genes with independent predictive value. This complements
\code{run.limma.de()} - while limma ranks genes by individual differential
expression, LASSO identifies the minimal subset with non-redundant joint
predictive signal.
}
\examples{
\donttest{
# Synthetic example — small expression matrix with binary outcome
set.seed(42)
expr.mat <- matrix(rnorm(200), nrow = 20, ncol = 10)
rownames(expr.mat) <- paste0("probe", 1:20)
colnames(expr.mat) <- paste0("sample", 1:10)
phenotype.binary <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
lasso.fit <- fit.lasso(expr.mat, phenotype.binary)
coef(lasso.fit, s = "lambda.1se")
}

}
