Skip to content

Commit 8cdfeb8

Browse files
fix: re-use helper functions from MOSuite
1 parent c7a9041 commit 8cdfeb8

2 files changed

Lines changed: 6 additions & 54 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## development version
44

5+
- Fix: remove `regex_moo` parameter from configuration. multiOmicDataSet input files are now required to follow the standardized naming pattern (`.*\.rds$`).
6+
57
## v1.0
68

79
Initial release

code/main.R

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@ library(readr)
77
library(stringr)
88
library(dplyr)
99

10-
# set up results directory
11-
results_dir <- file.path('..','results')
12-
plots_dir <- file.path(results_dir, 'figures')
13-
options(moo_plots_dir = plots_dir, moo_save_plots = TRUE)
14-
15-
# log installed packages & versions
16-
pkg_versions <- tibble::as_tibble(installed.packages())
17-
write_csv(pkg_versions, file.path(results_dir, 'r-packages.csv'))
10+
# set up capsule environment
11+
setup_capsule_environment()
1812

1913
# parse CLI arguments
2014
parser <- ArgumentParser()
@@ -34,52 +28,8 @@ parser$add_argument("--plot_title", type="character", default="PCA 3D", help="Ti
3428

3529
args <- parser$parse_args()
3630

37-
parse_optional_vector <- function(x) {
38-
if (is.null(x) || identical(x, "") || length(x) == 0) {
39-
return(NULL)
40-
}
41-
return(trimws(unlist(strsplit(x, ","))))
42-
}
43-
44-
parse_vector_with_default <- function(x, default) {
45-
parsed <- parse_optional_vector(x)
46-
if (is.null(parsed)) {
47-
return(default)
48-
}
49-
return(parsed)
50-
}
51-
52-
# validate inputs
53-
regex_moo <- ".*\\.rds$"
54-
data_files <- list.files(file.path('../data'), recursive = TRUE, full.names = TRUE)
55-
moo_files <- Filter(\(x) str_detect(x, regex(regex_moo, ignore_case = TRUE)), data_files)
56-
57-
if (length(moo_files) == 0) {
58-
stop(glue("No files matching regex: {regex_moo}"))
59-
}
60-
moo_filename <- moo_files[1]
61-
moo <- read_rds(moo_filename)
62-
message(glue('Reading multiOmicDataSet from {moo_filename}'))
63-
if (!inherits(moo, 'MOSuite::multiOmicDataSet')) {
64-
stop(glue('The input is not a multiOmicDataSet. class: {class(moo)}'))
65-
}
66-
67-
# parse samples_to_rename
68-
parse_samples_to_rename <- function(x) {
69-
if (is.null(x) || identical(x, "") || length(x) == 0) {
70-
return(NULL)
71-
}
72-
pairs <- trimws(unlist(strsplit(x, ",")))
73-
result <- list()
74-
for (pair in pairs) {
75-
parts <- trimws(unlist(strsplit(pair, ":")))
76-
if (length(parts) == 2) {
77-
result[[parts[1]]] <- parts[2]
78-
}
79-
}
80-
if (length(result) == 0) return(NULL)
81-
return(result)
82-
}
31+
# load multiOmicDataSet from data directory
32+
moo <- load_moo_from_data_dir()
8333

8434
# run MOSuite
8535
plot_pca(

0 commit comments

Comments
 (0)