Skip to contents

Performs pairwise and paired t-tests. The R default is Welch's t-test (unequal variances), use var.equal = TRUE for Student's t-test. Use is_paired for paired t-tests.

Usage

perform_t_test(
  object,
  formula_char,
  is_paired = FALSE,
  id = NULL,
  all_features = FALSE,
  assay.type = NULL,
  ...
)

Arguments

object

a SummarizedExperiment or MetaboSet object

formula_char

character, the formula to be used in the linear model (see Details)

is_paired

logical, use paired t-test

id

character, name of the subject identification column for paired version

all_features

should all features be included in FDR correction?

assay.type

character, assay to be used in case of multiple assays

...

other parameters passed to t.test

Value

A data frame with the results.

Details

P-values of each comparison are corrected separately from each other.

See also

Examples

data(example_set)
# Including QCs as a study group for example
t_test_results <- perform_t_test(example_set, 
  formula_char = "Feature ~ Group")
#> The functionality of this function has changed. It now encompasses pairwise and paired t-tests.
#> Remember that t.test returns difference between group means in different order than lm.
#> This function mimics this behavior, so the effect size is mean of first level minus mean of second level.
#> INFO [2025-06-23 22:37:38] Starting tests for A & B
#> INFO [2025-06-23 22:37:38] Tests performed
#> INFO [2025-06-23 22:37:38] Starting tests for A & QC
#> INFO [2025-06-23 22:37:38] Tests performed
#> Joining with `by = join_by(Feature_ID)`
#> INFO [2025-06-23 22:37:38] Starting tests for B & QC
#> INFO [2025-06-23 22:37:38] Tests performed
#> Joining with `by = join_by(Feature_ID)`
# Using paired mode (pairs with QC are skipped as there are no common IDs in 
# 'example_set')
t_test_results <- perform_t_test(example_set,
  formula_char = "Feature ~ Time", is_paired = TRUE, id = "Subject_ID")
#> The functionality of this function has changed. It now encompasses pairwise and paired t-tests.
#> Remember that t.test returns difference between group means in different order than lm.
#> This function mimics this behavior, so the effect size is mean of first level minus mean of second level.
#> INFO [2025-06-23 22:37:38] Starting paired tests for 1 & 2
#> INFO [2025-06-23 22:37:38] Found 20 complete pairs.
#> INFO [2025-06-23 22:37:38] Paired tests performed.
#> INFO [2025-06-23 22:37:38] Starting paired tests for 1 & QC
#> INFO [2025-06-23 22:37:38] Found 0 complete pairs.
#> Warning: Skipped 1 & QC: no common IDs.
#> Joining with `by = join_by(Feature_ID)`
#> INFO [2025-06-23 22:37:38] Starting paired tests for 2 & QC
#> INFO [2025-06-23 22:37:38] Found 0 complete pairs.
#> Warning: Skipped 2 & QC: no common IDs.
#> Joining with `by = join_by(Feature_ID)`
# Only two groups
t_test_results <- perform_t_test(drop_qcs(example_set),
  formula_char = "Feature ~ Group")
#> The functionality of this function has changed. It now encompasses pairwise and paired t-tests.
#> Remember that t.test returns difference between group means in different order than lm.
#> This function mimics this behavior, so the effect size is mean of first level minus mean of second level.
#> INFO [2025-06-23 22:37:38] Starting tests for A & B
#> INFO [2025-06-23 22:37:39] Tests performed