limma.dif: Differential Expression Analysis Using Limma

View source: R/feature_selection.R

limma.difR Documentation

Differential Expression Analysis Using Limma

Description

Performs differential expression analysis using the limma package on a given gene expression dataset. Constructs a design matrix from phenotype data, fits a linear model, applies contrasts, and computes statistics for differential expression.

Usage

limma.dif(exprdata, pdata, contrastfml)

Arguments

exprdata

A matrix with rownames as features like gene symbols or cgi, and colnames as samples.

pdata

A two-column dataframe where the first column matches the colnames of exprdata and the second column contains the grouping variable.

contrastfml

A character vector for contrasts to be tested (see ?makeContrasts for more details).

Value

Returns a dataframe from limma::topTable, which includes genes as rows and columns like genelist, logFC, AveExpr, etc.

Examples

# Toy example with 100 genes and 6 samples
set.seed(123)
exprdata <- matrix(
  rnorm(100 * 6),
  nrow = 100,
  ncol = 6,
  dimnames = list(
    paste0("gene", 1:100),
    paste0("sample", 1:6)
  )
)

# Phenotype data: 3 vs 3
pdata <- data.frame(
  sample = colnames(exprdata),
  group = rep(c("group1", "group2"), each = 3),
  stringsAsFactors = FALSE
)

# Differential expression: group1 vs group2
res <- limma.dif(
  exprdata = exprdata,
  pdata = pdata,
  contrastfml = "group1 - group2"
)
head(res)

IOBR documentation built on May 30, 2026, 5:07 p.m.