diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.yml b/.github/ISSUE_TEMPLATE/1-bug-report.yml index 9d2b2a4c1..5bdbc2190 100644 --- a/.github/ISSUE_TEMPLATE/1-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/1-bug-report.yml @@ -22,9 +22,9 @@ body: label: Minimal Reproducible Example (optional) description: Please include a short R code snippet that reproduces the problem, if possible. placeholder: - e.g.\n\n - ```r
- ab_name("amoxicillin/clavulanic acid", language = "es")\n + e.g. + ```r + ab_name("amoxicillin/clavulanic acid", language = "es") ``` validations: required: false diff --git a/DESCRIPTION b/DESCRIPTION index 78686eac2..c9c2f25e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 3.0.1.9007 +Version: 3.0.1.9008 Date: 2026-01-06 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 60e0cb992..155d0c23f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 3.0.1.9007 +# AMR 3.0.1.9008 ### New * Integration with the **tidymodels** framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes` diff --git a/vignettes/AMR_with_tidymodels.Rmd b/vignettes/AMR_with_tidymodels.Rmd index 9e6b2da02..156dfc14e 100644 --- a/vignettes/AMR_with_tidymodels.Rmd +++ b/vignettes/AMR_with_tidymodels.Rmd @@ -1,6 +1,6 @@ --- title: "AMR with tidymodels" -output: +output: rmarkdown::html_vignette: toc: true toc_depth: 3 @@ -8,7 +8,7 @@ vignette: > %\VignetteIndexEntry{AMR with tidymodels} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} -editor_options: +editor_options: chunk_output_type: console --- @@ -208,7 +208,7 @@ predictions %>% ### **Conclusion** -In this post, we demonstrated how to build a machine learning pipeline with the `tidymodels` framework and the `AMR` package. By combining selector functions like `aminoglycosides()` and `betalactams()` with `tidymodels`, we efficiently prepared data, trained a model, and evaluated its performance. +In this example, we demonstrated how to build a machine learning pipeline with the `tidymodels` framework and the `AMR` package. By combining selector functions like `aminoglycosides()` and `betalactams()` with `tidymodels`, we efficiently prepared data, trained a model, and evaluated its performance. This workflow is extensible to other antimicrobial classes and resistance patterns, empowering users to analyse AMR data systematically and reproducibly. @@ -267,10 +267,9 @@ testing_data <- testing(split) # Define the recipe mic_recipe <- recipe(esbl ~ ., data = training_data) %>% remove_role(genus, old_role = "predictor") %>% # Remove non-informative variable - step_mic_log2(all_mic_predictors()) #%>% # Log2 transform all MIC predictors - # prep() + step_mic_log2(all_mic_predictors()) # Log2 transform all MIC predictors -mic_recipe +prep(mic_recipe) ``` **Explanation:** @@ -315,7 +314,7 @@ fitted <- fit(workflow_model, training_data) # Generate predictions predictions <- predict(fitted, testing_data) %>% - bind_cols(predict(fitted, out_testing, type = "prob")) %>% # add probabilities + bind_cols(predict(fitted, testing_data, type = "prob")) %>% # add probabilities bind_cols(testing_data) # Evaluate model performance @@ -331,7 +330,7 @@ metrics - `predict()`: Produces predictions for unseen test data. - `metric_set()`: Allows evaluating multiple classification metrics. This will make `our_metrics` to become a function that we can use to check the predictions with. -It appears we can predict ESBL gene presence with a positive predictive value (PPV) of `r round(metrics[metrics$.metric == "ppv", ]$.estimate, 3) * 100`% and a negative predictive value (NPV) of `r round(metrics[metrics$.metric == "npv", ]$.estimate, 3) * 100` using a simplistic logistic regression model. +It appears we can predict ESBL gene presence with a positive predictive value (PPV) of `r round(metrics[metrics$.metric == "ppv", ]$.estimate, 3) * 100`% and a negative predictive value (NPV) of `r round(metrics[metrics$.metric == "npv", ]$.estimate, 3) * 100`% using a simplistic logistic regression model. ### **Visualising Predictions** @@ -361,14 +360,15 @@ predictions %>% colour = correct)) + scale_colour_manual(values = c(Right = "green3", Wrong = "red2"), name = "Correct?") + - geom_point() + + geom_point() + scale_y_continuous(labels = function(x) paste0(x * 100, "%"), limits = c(0.5, 1)) + theme_minimal() ``` + ### **Conclusion** -In this example, we showcased how the new `AMR`-specific recipe steps simplify working with `` columns in `tidymodels`. The `step_mic_log2()` transformation converts ordered MICs to log2-transformed numerics, improving compatibility with classification models. +In this example, we showcased how the new `AMR`-specific recipe steps simplify working with `` columns in `tidymodels`. The `step_mic_log2()` transformation converts MICs (with or without operators) to log2-transformed numerics, improving compatibility with classification models. This pipeline enables realistic, reproducible, and interpretable modelling of antimicrobial resistance data. @@ -487,7 +487,7 @@ fitted_workflow_time <- resistance_workflow_time %>% # Make predictions predictions_time <- fitted_workflow_time %>% predict(test_time) %>% - bind_cols(test_time) + bind_cols(test_time) # Evaluate model metrics_time <- predictions_time %>%