Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
de2fc86
Enhance plotting functions and documentation
AbhirupaGhosh Jan 20, 2026
c882078
Merge branch 'main' into plotting_ml_results
AbhirupaGhosh Jan 21, 2026
9486c55
Style code (GHA)
AbhirupaGhosh Jan 21, 2026
d3a97bf
Refactor plot functions to accept file inputs
AbhirupaGhosh May 29, 2026
2418366
Style code (GHA)
AbhirupaGhosh May 29, 2026
f2eb43c
Implement drug performance plotting functions in plot_ml.R
AbhirupaGhosh Jun 1, 2026
7ece644
Style code (GHA)
AbhirupaGhosh Jun 1, 2026
e818b35
Merge branch 'main' into plotting_ml_results
AbhirupaGhosh Jun 2, 2026
8050c96
Merge branch 'main' into plotting_ml_results
AbhirupaGhosh Jun 18, 2026
cb7c301
Merge remote-tracking branch 'origin/main' into plotting_ml_results
amcim Jun 25, 2026
6a2787e
adding back pr 23 changes and more runnable examples
amcim Jun 30, 2026
7177ab2
plot enhancements
AbhirupaGhosh Jul 1, 2026
49fc7e0
Style code (GHA)
AbhirupaGhosh Jul 1, 2026
2cb0e66
Update plot_ml.R
AbhirupaGhosh Jul 6, 2026
6d150d9
Style code (GHA)
AbhirupaGhosh Jul 6, 2026
1e42c53
Update plot_ml.R
AbhirupaGhosh Jul 7, 2026
4601ada
Style code (GHA)
AbhirupaGhosh Jul 7, 2026
34c691a
resolve comments and suggestions
AbhirupaGhosh Jul 7, 2026
aa2abd2
Style code (GHA)
AbhirupaGhosh Jul 7, 2026
769e69f
CI fixes and genome_drug metadata
amcim Jul 9, 2026
98f416c
Color changes in the plots
AbhirupaGhosh Jul 9, 2026
56db689
Fix plotting functions: restore genome_drug.genome_id, validation, cl…
eboyer221 Jul 21, 2026
8034bed
Refactor code structure for improved readability and maintainability
AbhirupaGhosh Jul 21, 2026
1eaf724
Remove bigger parquet files from extdata directory
AbhirupaGhosh Jul 22, 2026
b25ff0d
Pin vip to CRAN archive 0.4.6 (removed from CRAN 2026-07-08)
eboyer221 Jul 21, 2026
8b7a08a
Remove protein_names.parquet from extdata (unused, ~10MB)
eboyer221 Jul 22, 2026
0fb86a0
adding globals and remove genome_drug
amcim Jul 22, 2026
41ca2f1
Style code (GHA)
amcim Jul 22, 2026
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
14 changes: 13 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,49 @@ Depends:
R (>= 4.5.0)
Suggests:
BiocStyle,
ComplexHeatmap,
knitr,
rmarkdown,
testthat (>= 3.0.0),
xgboost
VignetteBuilder: knitr
Config/testthat/edition: 3
Remotes:
vip=url::https://cran.r-project.org/src/contrib/Archive/vip/vip_0.4.6.tar.gz
Imports:
arrow,
BiocParallel,
ComplexHeatmap,
DBI,
dplyr,
duckdb,
circlize,
forcats,
ggplot2,
ggrepel,
ggridges,
glmnet,
glue,
graphics,
grDevices,
jsonlite,
hardhat,
methods,
parsnip,
purrr,
patchwork,
RColorBrewer,
readr,
recipes,
rlang,
rsample,
scales,
sgof,
stats,
stringr,
tibble,
tidyr,
tune,
utils,
vip,
withr,
workflows,
Expand Down
14 changes: 13 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ export(getConfusionMatrix)
export(getNumFeat)
export(loadMLInputTibble)
export(plotBaselineComparison)
export(plotDefaultEval)
export(plotCM)
export(plotCrossDrug)
export(plotDrugDist)
export(plotDrugPerf)
export(plotFishers)
export(plotMDR)
export(plotPRC)
export(plotROC)
export(plotShuffleVsReal)
export(plotStratifiedPerf)
export(plotTopClusters)
export(plotTopFeatsVI)
export(predictML)
export(removeTopFeats)
Expand Down Expand Up @@ -87,6 +95,7 @@ importFrom(ggplot2,xlab)
importFrom(ggplot2,ylim)
importFrom(glmnet,glmnet)
importFrom(glue,glue)
importFrom(grDevices,colorRampPalette)
importFrom(graphics,barplot)
importFrom(hardhat,tune)
importFrom(jsonlite,fromJSON)
Expand Down Expand Up @@ -124,7 +133,10 @@ importFrom(rsample,validation_set)
importFrom(rsample,vfold_cv)
importFrom(stats,coef)
importFrom(stats,fisher.test)
importFrom(stats,median)
importFrom(stats,reformulate)
importFrom(stats,reorder)
importFrom(stats,sd)
importFrom(stringr,str_remove)
importFrom(stringr,str_split)
importFrom(tibble,add_column)
Expand Down
114 changes: 57 additions & 57 deletions R/arg_check_ml.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ NULL
"genome_drug.resistant_phenotype" %in% colnames(tibble),
"resistant_classes" %in% colnames(tibble)
)) {
stop(paste(
"The input tibble must have a target variable column named",
"either `genome_drug.resistant_phenotype` or `resistant_classes`, but",
stop(
"The input tibble must have a target variable column named ",
"either `genome_drug.resistant_phenotype` or `resistant_classes`, but ",
"not both."
))
)
}
}
}
Expand Down Expand Up @@ -107,11 +107,11 @@ NULL
is_train_val_test <- (train_prop > 0 && val_prop > 0 && test_prop > 0)

if (!(is_pure_cv || is_train_val_test)) {
stop(paste0(
stop(
"Unsupported split proportions. Use either:\n",
" - pure CV: split = c(1, 0)\n",
" - classical splits (train/val/test): c(train_prop, val_prop) with train > 0, val > 0, and test = 1 - train - val > 0."
))
)
}

# Sum must be <= 1 for all valid cases
Expand Down Expand Up @@ -192,10 +192,10 @@ NULL
}

if (smallest_n_obs_rs < 1 || smallest_n_obs_rs %% 1 != 0) {
stop(paste(
"The `smallest_n_obs_rs` argument must be a whole, positive",
stop(
"The `smallest_n_obs_rs` argument must be a whole, positive ",
"number greater than 0."
))
)
}
}

Expand All @@ -207,10 +207,10 @@ NULL
#'
.checkArgUsePCA <- function(use_pca) {
if (!is.logical(use_pca)) {
stop(paste(
"The `use_pca` argument can only take logical values:",
stop(
"The `use_pca` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand Down Expand Up @@ -240,10 +240,10 @@ NULL
#'
.checkArgMultiClass <- function(multi_class) {
if (!is.logical(multi_class)) {
stop(paste(
"The `multi_class` argument can only take logical values:",
stop(
"The `multi_class` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand Down Expand Up @@ -281,10 +281,10 @@ NULL
#'
.checkArgModel <- function(model) {
if (!(model %in% c("LR", "RF", "BT"))) {
stop(paste(
"The `model` argument must be one of:",
stop(
"The `model` argument must be one of: ",
"'LR' (logistic regression), 'RF' (random forest), 'BT' (boosted tree)."
))
)
}
}

Expand Down Expand Up @@ -434,10 +434,10 @@ NULL
#'
.checkArgSelectBestMetric <- function(select_best_metric) {
if (!(select_best_metric %in% c("f_meas", "pr_auc", "mcc", "bal_accuracy"))) {
stop(paste(
"The `select_best_metric` argument must be one of: 'f_meas',",
stop(
"The `select_best_metric` argument must be one of: 'f_meas', ",
"'pr_auc', 'mcc', 'bal_accuracy'."
))
)
}
}

Expand All @@ -453,10 +453,10 @@ NULL
.checkArgTibble(test_data_plus_predictions, ml = TRUE)

if (!(".pred_class" %in% colnames(test_data_plus_predictions))) {
stop(paste(
"`test_data_plus_predictions` is missing a `.pred_class`",
stop(
"`test_data_plus_predictions` is missing a `.pred_class` ",
"column. Try using the output of `predictML()`."
))
)
}
}

Expand Down Expand Up @@ -489,10 +489,10 @@ NULL
#'
.checkArgPropVITopFeats <- function(prop_vi_top_feats) {
if (!is.numeric(prop_vi_top_feats) || length(prop_vi_top_feats) != 2) {
stop(paste(
"The `prop_vi_top_feats` argument must be a vector of length",
stop(
"The `prop_vi_top_feats` argument must be a vector of length ",
"2 with numeric values."
))
)
}

if (any(prop_vi_top_feats > 1) || any(prop_vi_top_feats < 0)) {
Expand All @@ -515,10 +515,10 @@ NULL
#'
.checkArgShuffleLabels <- function(shuffle_labels) {
if (!is.logical(shuffle_labels)) {
stop(paste(
"The `shuffle_labels` argument can only take logical values:",
stop(
"The `shuffle_labels` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -530,10 +530,10 @@ NULL
#'
.checkArgReturnTuneRes <- function(return_tune_res) {
if (!is.logical(return_tune_res)) {
stop(paste(
"The `return_tune_res` argument can only take logical values:",
stop(
"The `return_tune_res` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -545,10 +545,10 @@ NULL
#'
.checkArgReturnFit <- function(return_fit) {
if (!is.logical(return_fit)) {
stop(paste(
"The `return_fit` argument can only take logical values:",
stop(
"The `return_fit` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -561,10 +561,10 @@ NULL
#'
.checkArgReturnPred <- function(return_pred) {
if (!is.logical(return_pred)) {
stop(paste(
"The `return_pred` argument can only take logical values:",
stop(
"The `return_pred` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -576,10 +576,10 @@ NULL
#'
.checkArgVerbose <- function(verbose) {
if (!is.logical(verbose)) {
stop(paste(
"The `verbose` argument can only take logical values:",
stop(
"The `verbose` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand Down Expand Up @@ -613,10 +613,10 @@ NULL
#'
.checkArgByVI <- function(by_vi) {
if (!is.logical(by_vi)) {
stop(paste(
"The `by_vi` argument can only take logical values:",
stop(
"The `by_vi` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -629,10 +629,10 @@ NULL
#'
.checkArgByNum <- function(by_num) {
if (!is.logical(by_num)) {
stop(paste(
"The `by_num` argument can only take logical values:",
stop(
"The `by_num` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand All @@ -657,10 +657,10 @@ NULL
}

if (any(diff(percent_removal_vec) <= 0)) {
stop(paste(
"The elements of `percent_removal_vec` must be in ascending",
stop(
"The elements of `percent_removal_vec` must be in ascending ",
"order with no repeats."
))
)
}
}

Expand All @@ -673,10 +673,10 @@ NULL
#'
.checkArgReturnFeats <- function(return_feats) {
if (!is.logical(return_feats)) {
stop(paste(
"The `return_feats` argument can only take logical values:",
stop(
"The `return_feats` argument can only take logical values: ",
"`TRUE` or `FALSE`."
))
)
}
}

Expand Down Expand Up @@ -713,10 +713,10 @@ NULL
if (!(y_default_eval %in%
c("avg_f1_score", "avg_log2_apop", "avg_bal_acc", "avg_mcc", "avg_nmcc"))
) {
stop(paste(
"`y_default_eval` must be one of:",
stop(
"`y_default_eval` must be one of: ",
"'avg_f1_score', 'avg_log2_apop', 'avg_bal_acc', 'avg_mcc', 'avg_nmcc'."
))
)
}
}

Expand Down
Loading
Loading