Skip to content

Commit 0021f08

Browse files
Load mikropml with library() in preprocess script
Sometimes preprocess_data() throws an error when calling caret::dummyVars(): Error in get(ctr, mode = "function", envir = parent.frame()) : object 'contr.ltfr' of mode 'function' was not found Calls: <Anonymous> ... model.matrix -> model.matrix.default -> contrasts -> get This error happens sometimes when using categorical features, but not for all datasets with categorical features. It happened to Jay with her CRC datasets split by condition when the plate ID column was included as a feature. For some reason, loading either mikropml or caret with library() in scripts fixes the problem.
1 parent d510a1d commit 0021f08

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

code/preproc.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
source("code/log_smk.R")
2+
library(mikropml)
3+
24
doFuture::registerDoFuture()
35
future::plan(future::multicore, workers = snakemake@resources[["ncores"]])
46

57
data_raw <- readr::read_csv(snakemake@input[["csv"]])
6-
data_processed <- mikropml::preprocess_data(data_raw, outcome_colname = "dx")
8+
data_processed <- preprocess_data(data_raw, outcome_colname = "dx")
79

810
saveRDS(data_processed, file = snakemake@output[["rds"]])

0 commit comments

Comments
 (0)