Skip to content

Commit

Permalink
feat: check that each sample only appears in one group
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Dec 7, 2023
1 parent 11429ab commit 30673c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/local/check_contrasts/templates/check_contrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ main <- function(contrasts_filename = "${contrasts}",

#' Check an individual contrast comparison
check_contrast <- function(contrast_name, contrasts_lst) {
curr_contrast <- contrasts_lst[[contrast_name]]
# Ensure contrast has exactly two groups to compare
contrast_len <- length(contrasts_lst[[contrast_name]])
contrast_len <- length(curr_contrast)
assert_that(
contrast_len == 2,
msg = glue("Contrasts must have only two groups per comparison, but {contrast_name} has {contrast_len}")
)
# TODO: check that each sample only appears in one group
group_names <- names(curr_contrast)
assert_that(
length(intersect(curr_contrast[[group_names[1]]], curr_contrast[[group_names[2]]])) == 0,
msg = glue("Each sample can only appear in one group per contrast ({contrast_name})")
)
}

#' Combine sample sheet with contrast group
Expand Down

0 comments on commit 30673c9

Please sign in to comment.