Skip to main content

Generate contrasts for a two-factor design

Description

Reads an annotation file and adds ContrastName/Contrast columns using annotation_add_contrasts.

Usage

run_contrasts_twofactor(
  annotation_file,
  f1,
  f2,
  interactions = TRUE,
  decreasing = FALSE
)

Arguments

annotation_file path to annotation CSV/TSV/XLSX
f1 primary factor column name
f2 secondary factor column name
interactions logical; include interaction contrasts? Default TRUE.
decreasing logical; sort the levels of both factors in decreasing order. The contrasts subtract the first level, so with levels PKD1 and WT the default gives WT_vs_PKD1 and TRUE gives PKD1_vs_WT. Default FALSE.

Value

data.frame with ContrastName and Contrast columns added

Examples

library("prolfquapp")

csv <- system.file("application/contrasts/scenario2_two_factor.csv",
  package = "prolfquapp")
result <- run_contrasts_twofactor(csv, f1 = "treatment", f2 = "time")
unique(result[!is.na(result$ContrastName), c("ContrastName", "Contrast")])
# A tibble: 4 × 2
  ContrastName                           Contrast                               
  <chr>                                  <chr>                                  
1 MINOCA_vs_MI                           (G_MINOCA_T0 + G_MINOCA_T150)/2 - (G_M…
2 MINOCA_vs_MI_at_T0                     G_MINOCA_T0 - G_MI_T0                  
3 MINOCA_vs_MI_at_T150                   G_MINOCA_T150 - G_MI_T150              
4 interaction_MINOCA_vs_MI_at_T150_vs_T0 (G_MINOCA_T150 - G_MI_T150) - (G_MINOC…