Internal function for calculating 3-class group test (either one-way ANOVA or Kruskal-Wallis test) and pairwise tests (either t-test or Wilcoxon test) on multi-column data against an outcome parameter with 3 levels.

calc_pvals(
  outcome,
  data,
  pcutoff = 0.05,
  padj.method = "BH",
  group_test = c("anova", "kruskal.test"),
  pairwise_test = c("t.test", "wilcoxon"),
  exact = FALSE,
  filter_pairwise = TRUE
)

Arguments

outcome

Outcome vector with 3 groups, ideally as a factor. If it is not a factor, this will be coerced to a factor. This must have exactly 3 levels.

data

Dataframe or matrix with variables in columns

pcutoff

Cut-off for p-value significance

padj.method

Can be any method available in p.adjust or "qvalue". The option "none" is a pass-through.

group_test

Specifies statistical test for 3-class group comparison. "anova" means one-way ANOVA, "kruskal.test" means Kruskal-Wallis test.

pairwise_test

Specifies statistical test for pairwise comparisons

exact

Logical which is only used with pairwise_test = "wilcoxon"

filter_pairwise

Logical. If TRUE (the default) p-value adjustment on pairwise statistical tests is only conducted on attributes which reached the threshold for significance after p-value adjustment on the group statistical test.

Value

Returns a list with first element representing a data frame of unadjusted p-values and the second element adjusted p-values. Each dataframe contains 4 columns: the first column is the 3-way comparison (LRT or ANOVA). Columns 2-4 are pairwise comparisons between groups A vs B, A vs C and B vs C, where A, B, C are the 3 levels in the outcome factor.