perform_t_test: Welch Two-Sample t-Test for Differential Gene Expression

View source: R/T-Test.R

perform_t_testR Documentation

Welch Two-Sample t-Test for Differential Gene Expression

Description

Performs an independent two-sample Welch t-test for every gene (row) in the expression matrix, applies Benjamini-Hochberg (BH) correction, and returns a results table together with the list of significant DEGs.

Usage

perform_t_test(
  dataframe,
  con1,
  con2,
  exp1,
  exp2,
  alpha = 0.05,
  annot_df = NULL
)

Arguments

dataframe

A numeric matrix or data.frame of gene expression values (rows = genes, columns = samples). Values are automatically log2- transformed when they appear to be on a linear / intensity scale.

con1

Integer. Index of the first control column.

con2

Integer. Index of the last control column.

exp1

Integer. Index of the first experiment column.

exp2

Integer. Index of the last experiment column.

alpha

Numeric significance threshold for BH-adjusted p-values (default 0.05).

annot_df

Optional annotation data.frame with columns ID and Gene.Symbol (or Gene.symbol). When NULL (default) row names of dataframe are used as gene identifiers.

Value

A named list:

Table

Data.frame with columns G_Symbol, log2FC, statistic.t, p.value, BH, fdr.

DEGs

Data.frame of gene identifiers whose BH-adjusted p-value is \le alpha.

Examples

library(DGEAR)
data("gene_exp_data")
result <- perform_t_test(dataframe = gene_exp_data,
                         con1 = 1, con2 = 10,
                         exp1 = 11, exp2 = 20)
head(result$Table)
result$DEGs

DGEAR documentation built on July 3, 2026, 9:07 a.m.