Skip to contents

Automatically selects between Welch's and Student's t-test based on the result of a variance equality test, then returns a unified result structure regardless of which branch was taken.

Usage

adaptive.t.test(df, alpha = 0.05)

Arguments

df

A data frame containing at least two columns:

expression

Numeric vector of gene expression values.

group

Character or factor vector with exactly two group labels.

alpha

Numeric. Significance level for the variance equality test (var.test()). Default is 0.05.

Value

A named list with three elements:

variance.test

The result object from var.test() or oneway.test(), depending on the branch taken.

t.test

The result object from t.test().

p.value

Numeric. The p-value from the t-test.

Details

If var.test() returns a p-value below alpha, variances are considered unequal and Welch's t-test (var.equal = FALSE) is used. Otherwise, Student's t-test (var.equal = TRUE) is applied alongside a one-way ANOVA as a confirmatory check. The returned list is consumed internally by analyze.gene().

Examples

# \donttest{
# Build a minimal example data frame
analysis.df <- data.frame(
  expression = c(1.2, 2.3, 1.8, 2.1, 3.4, 2.9, 3.1, 2.7),
  group = rep(c("normal", "RCC"), each = 4)
)
result <- adaptive.t.test(analysis.df, alpha = 0.05)
result$p.value
#> [1] 0.005946574
# }