From eefc56e630c915f308dc82b78b97835b195ea5bf Mon Sep 17 00:00:00 2001 From: phoman14 Date: Mon, 3 Aug 2026 22:10:51 -0400 Subject: [PATCH 1/2] fix: derive norm count subtype internally --- .codeocean/app-panel.json | 9 --------- code/main.R | 9 ++------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.codeocean/app-panel.json b/.codeocean/app-panel.json index 22c1eab..06cd004 100644 --- a/.codeocean/app-panel.json +++ b/.codeocean/app-panel.json @@ -77,15 +77,6 @@ "batch" ] }, - { - "id": "sub_count_type_id", - "category": "FvI4Z2eb9sjL47Jt", - "name": "Sub count type", - "param_name": "sub_count_type", - "description": "Used if count_type is a list in the counts slot. This must be a name in moo@counts[[count_type]].", - "type": "text", - "value_type": "string" - }, { "id": "sample_id_colname_id", "category": "FvI4Z2eb9sjL47Jt", diff --git a/code/main.R b/code/main.R index a3eee69..c84e82d 100644 --- a/code/main.R +++ b/code/main.R @@ -14,12 +14,6 @@ setup_capsule_environment() parser <- ArgumentParser() parser$add_argument("--count_type", type = "character", default = "filt") -parser$add_argument( - "--sub_count_type", - type = "character", - default = NULL, - help = "Sub count type if count_type is a list" -) parser$add_argument( "--sample_id_colname", type = "character", @@ -262,6 +256,7 @@ parser$add_argument( ) args <- parser$parse_args() +sub_count_type <- if (identical(args$count_type, "norm")) "voom" else NULL # load multiOmicDataSet from data directory moo <- load_moo_from_data_dir() @@ -270,7 +265,7 @@ moo <- load_moo_from_data_dir() plot_expr_heatmap( moo, count_type = args$count_type, - sub_count_type = args$sub_count_type, + sub_count_type = sub_count_type, sample_id_colname = args$sample_id_colname, feature_id_colname = args$feature_id_colname, group_colname = args$group_colname, From 382f569a056547a54cee6704dd8039cb3da2d6aa Mon Sep 17 00:00:00 2001 From: phoman14 Date: Mon, 3 Aug 2026 22:21:16 -0400 Subject: [PATCH 2/2] test: cover supported count types --- tests/testthat/helper-cli.R | 28 ++++++++++++++++++++++++++++ tests/testthat/test-main.R | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/tests/testthat/helper-cli.R b/tests/testthat/helper-cli.R index 658b2b5..259d2ef 100644 --- a/tests/testthat/helper-cli.R +++ b/tests/testthat/helper-cli.R @@ -73,3 +73,31 @@ common_cli_args <- c( "--display_gene_names=FALSE", "--display_sample_names=TRUE" ) + +expect_main_runs_with_count_type <- function(count_type) { + setup <- setup_cli_workspace( + paste0("mosuite_plot_expr_heatmap_", count_type, "_test_") + ) + on.exit(unlink(setup$workspace, recursive = TRUE), add = TRUE) + + old_wd <- getwd() + setwd(setup$code_dir) + on.exit(setwd(old_wd), add = TRUE) + + exit_code <- system2( + "Rscript", + args = c( + "main.R", + sprintf("--count_type=%s", count_type), + "--display_gene_names=FALSE", + "--display_sample_names=TRUE" + ) + ) + expect_equal( + exit_code, + 0, + info = paste("main.R should plot", count_type, "counts") + ) + + expect_plot_created(setup$results_dir) +} diff --git a/tests/testthat/test-main.R b/tests/testthat/test-main.R index 5b25f8d..ba87fc6 100644 --- a/tests/testthat/test-main.R +++ b/tests/testthat/test-main.R @@ -12,6 +12,12 @@ test_that("main.R CLI creates expression heatmap plot", { expect_plot_created(setup$results_dir) }) +test_that("main.R CLI plots supported count types", { + for (count_type in c("raw", "filt", "norm", "batch")) { + expect_main_runs_with_count_type(count_type) + } +}) + test_that("run wrapper executes and creates expression heatmap plot", { setup <- setup_cli_workspace("mosuite_plot_expr_heatmap_run_test_") on.exit(unlink(setup$workspace, recursive = TRUE), add = TRUE)