Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .codeocean/app-panel.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## development version

- Hide the count subtype parameter and automatically use the `voom` subtype when plotting normalized counts (#11, @phoman14).
- Sync Code Ocean app panel parameter descriptions with MOSuite package documentation for MOSuite v0.4.1 (#7, @phoman14).
- Improved the Code Ocean parameter UI for the plot expr heatmap capsule (#4, @phoman14).
- Use MOSuite v0.3.2. (#1, @kelly-sovacool)
Expand Down
20 changes: 12 additions & 8 deletions code/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down Expand Up @@ -308,5 +303,14 @@ plot_expr_heatmap(
assign_color_to_sample_groups = parse_optional_vector(
args$assign_color_to_sample_groups
),
group_colors = parse_optional_vector(args$group_colors)
group_colors = parse_optional_vector(args$group_colors),
heatmap_color_scheme = args$heatmap_color_scheme,
autoscale_heatmap_color = args$autoscale_heatmap_color,
set_min_heatmap_color = args$set_min_heatmap_color,
set_max_heatmap_color = args$set_max_heatmap_color,
aspect_ratio = args$aspect_ratio,
legend_font_size = args$legend_font_size,
gene_name_font_size = args$gene_name_font_size,
sample_name_font_size = args$sample_name_font_size,
display_numbers = args$display_numbers
)
28 changes: 28 additions & 0 deletions tests/testthat/helper-cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
36 changes: 36 additions & 0 deletions tests/testthat/test-main.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
test_that("every app panel parameter is accepted and used by main.R", {
repo_root <- normalizePath(
file.path(testthat::test_path(), "..", ".."),
mustWork = TRUE
)
panel <- jsonlite::fromJSON(
file.path(repo_root, ".codeocean", "app-panel.json")
)
main_text <- paste(
readLines(file.path(repo_root, "code", "main.R"), warn = FALSE),
collapse = "\n"
)
param_names <- panel$parameters$param_name
expect_true(length(param_names) > 0)
for (param_name in param_names) {
expect_match(
main_text,
sprintf('"--%s"', param_name),
fixed = TRUE,
info = sprintf("main.R should define a --%s CLI argument", param_name)
)
expect_match(
main_text,
sprintf("args$%s", param_name),
fixed = TRUE,
info = sprintf("main.R should read args$%s", param_name)
)
}
})

test_that("main.R CLI creates expression heatmap plot", {
setup <- setup_cli_workspace("mosuite_plot_expr_heatmap_test_")
on.exit(unlink(setup$workspace, recursive = TRUE), add = TRUE)
Expand All @@ -12,6 +42,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)
Expand Down
Loading