1
0
mirror of https://github.com/msberends/AMR.git synced 2026-04-28 10:23:53 +02:00

(v3.0.1.9047) fix #272

This commit is contained in:
2026-04-21 22:11:40 +02:00
parent 8ff5d4472a
commit e0f8cf0882
7 changed files with 19 additions and 20 deletions

View File

@@ -73,7 +73,6 @@ These steps integrate with \code{recipes::recipe()} and work like standard prepr
}
\examples{
if (require("tidymodels")) {
# The below approach formed the basis for this paper: DOI 10.3389/fmicb.2025.1582703
# Presence of ESBL genes was predicted based on raw MIC values.
@@ -92,13 +91,10 @@ if (require("tidymodels")) {
# Create and prep a recipe with MIC log2 transformation
mic_recipe <- recipe(esbl ~ ., data = training_data) \%>\%
# Optionally remove non-predictive variables
remove_role(genus, old_role = "predictor") \%>\%
# Apply the log2 transformation to all MIC predictors
step_mic_log2(all_mic_predictors()) \%>\%
# And apply the preparation steps
prep()
@@ -119,13 +115,15 @@ if (require("tidymodels")) {
bind_cols(out_testing)
# Evaluate predictions using standard classification metrics
our_metrics <- metric_set(accuracy,
recall,
precision,
sensitivity,
specificity,
ppv,
npv)
our_metrics <- metric_set(
accuracy,
recall,
precision,
sensitivity,
specificity,
ppv,
npv
)
metrics <- our_metrics(predictions, truth = esbl, estimate = .pred_class)
# Show performance

View File

@@ -79,12 +79,12 @@ if (require("dplyr")) {
# new ggplot2 plotting method using this package:
if (require("dplyr") && require("ggplot2")) {
ggplot_pca(pca_result)
ggplot_pca(pca_result)
}
if (require("dplyr") && require("ggplot2")) {
ggplot_pca(pca_result) +
scale_colour_viridis_d() +
labs(title = "Title here")
ggplot_pca(pca_result) +
scale_colour_viridis_d() +
labs(title = "Title here")
}
}
}

View File

@@ -321,7 +321,7 @@ if (require("ggplot2")) {
theme_minimal() +
geom_boxplot(fill = NA, colour = "grey30") +
geom_jitter(width = 0.25)
labs(title = "scale_y_mic()/scale_colour_sir() automatically applied")
labs(title = "scale_y_mic()/scale_colour_sir() automatically applied")
mic_sir_plot
}