From 1227e2c60c141d7ab3c1498d53183fd50d8bc4dc Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Dec 2025 08:48:41 +0000 Subject: [PATCH] Built site for AMR@3.0.1.9007: a5c6aa9 --- 404.html | 2 +- LICENSE-text.html | 2 +- articles/AMR.html | 18 +- articles/AMR.md | 8 +- articles/AMR_for_Python.html | 2 +- articles/AMR_with_tidymodels.html | 305 ++++++++++++++++-- articles/AMR_with_tidymodels.md | 251 +++++++++++++- .../figure-html/unnamed-chunk-14-1.png | Bin 65285 -> 32166 bytes .../figure-html/unnamed-chunk-15-1.png | Bin 140523 -> 71804 bytes .../figure-html/unnamed-chunk-21-1.png | Bin 0 -> 65285 bytes .../figure-html/unnamed-chunk-22-1.png | Bin 0 -> 140523 bytes articles/EUCAST.html | 2 +- articles/PCA.html | 8 +- articles/WHONET.html | 4 +- articles/WISCA.html | 2 +- articles/datasets.html | 4 +- articles/index.html | 2 +- authors.html | 2 +- index.html | 2 +- llms.txt | 2 + news/index.html | 20 +- news/index.md | 25 +- pkgdown.yml | 2 +- reference/AMR-deprecated.html | 2 +- reference/AMR-options.html | 2 +- reference/AMR.html | 2 +- reference/WHOCC.html | 2 +- reference/WHONET.html | 2 +- reference/ab_from_text.html | 2 +- reference/ab_property.html | 2 +- reference/add_custom_antimicrobials.html | 2 +- reference/add_custom_microorganisms.html | 2 +- reference/age.html | 22 +- reference/age.md | 20 +- reference/age_groups.html | 2 +- reference/all_disk.html | 8 + reference/all_disk_predictors.html | 8 + reference/all_mic.html | 8 + reference/all_mic_predictors.html | 8 + reference/all_sir.html | 8 + reference/all_sir_predictors.html | 8 + reference/amr-tidymodels.html | 234 ++++++++++++++ reference/amr-tidymodels.md | 192 +++++++++++ reference/antibiogram.html | 16 +- reference/antibiogram.md | 18 +- reference/antimicrobial_selectors.html | 5 +- reference/antimicrobial_selectors.md | 3 + reference/antimicrobials.html | 2 +- reference/as.ab.html | 2 +- reference/as.av.html | 2 +- reference/as.disk.html | 2 +- reference/as.mic.html | 2 +- reference/as.mo.html | 2 +- reference/as.sir.html | 14 +- reference/as.sir.md | 12 +- reference/atc_online.html | 2 +- reference/av_from_text.html | 2 +- reference/av_property.html | 2 +- reference/availability.html | 2 +- reference/bug_drug_combinations.html | 2 +- reference/clinical_breakpoints.html | 8 +- reference/clinical_breakpoints.md | 2 +- reference/count.html | 2 +- reference/custom_eucast_rules.html | 2 +- reference/custom_mdro_guideline.html | 2 +- reference/dosage.html | 2 +- reference/esbl_isolates.html | 112 +++++++ reference/esbl_isolates.md | 58 ++++ reference/eucast_rules.html | 2 +- reference/example_isolates.html | 2 +- reference/example_isolates_unclean.html | 2 +- reference/export_ncbi_biosample.html | 2 +- reference/first_isolate.html | 2 +- reference/g.test.html | 2 +- reference/get_episode.html | 116 +++---- reference/get_episode.md | 114 +++---- reference/ggplot_pca.html | 2 +- reference/ggplot_sir.html | 2 +- reference/guess_ab_col.html | 2 +- reference/index.html | 9 +- reference/index.md | 2 + reference/intrinsic_resistant.html | 2 +- reference/italicise_taxonomy.html | 2 +- reference/join.html | 2 +- reference/key_antimicrobials.html | 2 +- reference/kurtosis.html | 6 +- reference/kurtosis.md | 4 +- reference/like.html | 4 +- reference/like.md | 2 + reference/mdro.html | 2 +- reference/mean_amr_distance.html | 88 ++--- reference/mean_amr_distance.md | 86 ++--- reference/microorganisms.codes.html | 2 +- reference/microorganisms.groups.html | 2 +- reference/microorganisms.html | 2 +- reference/mo_matching_score.html | 2 +- reference/mo_property.html | 2 +- reference/mo_source.html | 2 +- reference/pca.html | 2 +- reference/plot-1.png | Bin 35350 -> 37129 bytes reference/plot-10.png | Bin 70715 -> 74261 bytes reference/plot-12.png | Bin 86421 -> 90034 bytes reference/plot-13.png | Bin 85572 -> 81952 bytes reference/plot-14.png | Bin 38976 -> 38850 bytes reference/plot-15.png | Bin 55162 -> 55112 bytes reference/plot-16.png | Bin 37343 -> 35083 bytes reference/plot-17.png | Bin 53379 -> 51225 bytes reference/plot-18.png | Bin 51169 -> 49038 bytes reference/plot-19.png | Bin 43411 -> 44054 bytes reference/plot-2.png | Bin 59674 -> 62752 bytes reference/plot-3.png | Bin 58827 -> 61489 bytes reference/plot-4.png | Bin 56679 -> 56174 bytes reference/plot-9.png | Bin 92180 -> 83411 bytes reference/plot.html | 2 +- reference/proportion.html | 2 +- reference/random-1.png | Bin 32918 -> 33633 bytes reference/random-2.png | Bin 48276 -> 49329 bytes reference/random.html | 36 +-- reference/random.md | 34 +- reference/resistance_predict.html | 2 +- reference/skewness.html | 4 +- reference/skewness.md | 2 +- reference/step_mic_log2.html | 8 + reference/step_sir_numeric.html | 8 + reference/top_n_microorganisms.html | 2 +- reference/translate.html | 2 +- search.json | 2 +- sitemap.xml | 2 + 128 files changed, 1616 insertions(+), 440 deletions(-) create mode 100644 articles/AMR_with_tidymodels_files/figure-html/unnamed-chunk-21-1.png create mode 100644 articles/AMR_with_tidymodels_files/figure-html/unnamed-chunk-22-1.png create mode 100644 reference/all_disk.html create mode 100644 reference/all_disk_predictors.html create mode 100644 reference/all_mic.html create mode 100644 reference/all_mic_predictors.html create mode 100644 reference/all_sir.html create mode 100644 reference/all_sir_predictors.html create mode 100644 reference/amr-tidymodels.html create mode 100644 reference/amr-tidymodels.md create mode 100644 reference/esbl_isolates.html create mode 100644 reference/esbl_isolates.md create mode 100644 reference/step_mic_log2.html create mode 100644 reference/step_sir_numeric.html diff --git a/404.html b/404.html index 3f7e7ffa8..2d4812c11 100644 --- a/404.html +++ b/404.html @@ -31,7 +31,7 @@ AMR (for R) - 3.0.1.9004 + 3.0.1.9007 + + + + + +
+
+
+ +
+

This family of functions allows using AMR-specific data types such as <sir> and <mic> inside tidymodels pipelines.

+
+ +
+

Usage

+
all_sir()
+
+all_sir_predictors()
+
+all_mic()
+
+all_mic_predictors()
+
+all_disk()
+
+all_disk_predictors()
+
+step_mic_log2(recipe, ..., role = NA, trained = FALSE, columns = NULL,
+  skip = FALSE, id = recipes::rand_id("mic_log2"))
+
+step_sir_numeric(recipe, ..., role = NA, trained = FALSE, columns = NULL,
+  skip = FALSE, id = recipes::rand_id("sir_numeric"))
+
+ +
+

Arguments

+ + +
recipe
+

A recipe object. The step will be added to the sequence of +operations for this recipe.

+ + +
...
+

One or more selector functions to choose variables for this step. +See selections() for more details.

+ + +
role
+

Not used by this step since no new variables are created.

+ + +
trained
+

A logical to indicate if the quantities for preprocessing have +been estimated.

+ + +
skip
+

A logical. Should the step be skipped when the recipe is baked by +bake()? While all operations are baked when prep() is run, some +operations may not be able to be conducted on new data (e.g. processing the +outcome variable(s)). Care should be taken when using skip = TRUE as it +may affect the computations for subsequent operations.

+ + +
id
+

A character string that is unique to this step to identify it.

+ +
+
+

Details

+

You can read more in our online AMR with tidymodels introduction.

+

Tidyselect helpers include:

  • all_sir() and all_sir_predictors() to select <sir> columns

  • +
  • all_mic() and all_mic_predictors() to select <mic> columns

  • +
  • all_disk() and all_disk_predictors() to select <disk> columns

  • +

Pre-processing pipeline steps include:

  • step_sir_numeric() to convert SIR columns to numeric (via as.numeric()), to be used with all_sir_predictors(): "S" = 1, "I"/"SDD" = 2, "R" = 3. All other values are rendered NA. Keep this in mind for further processing, especially if the model does not allow for NA values.

  • +
  • step_mic_log2() to convert MIC columns to numeric (via as.numeric()) and apply a log2 transform, to be used with all_mic_predictors()

  • +

These steps integrate with recipes::recipe() and work like standard preprocessing steps. They are useful for preparing data for modelling, especially with classification models.

+
+ + +
+

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.
+
+
+  # example data set in the AMR package
+  esbl_isolates
+
+  # Prepare a binary outcome and convert to ordered factor
+  data <- esbl_isolates %>%
+    mutate(esbl = factor(esbl, levels = c(FALSE, TRUE), ordered = TRUE))
+
+  # Split into training and testing sets
+  split <- initial_split(data)
+  training_data <- training(split)
+  testing_data <- testing(split)
+
+  # 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()
+
+  # View prepped recipe
+  mic_recipe
+
+  # Apply the recipe to training and testing data
+  out_training <- bake(mic_recipe, new_data = NULL)
+  out_testing <- bake(mic_recipe, new_data = testing_data)
+
+  # Fit a logistic regression model
+  fitted <- logistic_reg(mode = "classification") %>%
+    set_engine("glm") %>%
+    fit(esbl ~ ., data = out_training)
+
+  # Generate predictions on the test set
+  predictions <- predict(fitted, out_testing) %>%
+    bind_cols(out_testing)
+
+  # Evaluate predictions using standard classification metrics
+  our_metrics <- metric_set(accuracy,
+                            recall,
+                            precision,
+                            sensitivity,
+                            specificity,
+                            ppv,
+                            npv)
+  metrics <- our_metrics(predictions, truth = esbl, estimate = .pred_class)
+
+  # Show performance
+  metrics
+}
+#> Loading required package: tidymodels
+#> ── Attaching packages ────────────────────────────────────── tidymodels 1.4.1 ──
+#>  broom        1.0.11      rsample      1.3.1 
+#>  dials        1.4.2       tailor       0.1.0 
+#>  infer        1.1.0       tidyr        1.3.2 
+#>  modeldata    1.5.1       tune         2.0.1 
+#>  parsnip      1.4.0       workflows    1.3.0 
+#>  purrr        1.2.0       workflowsets 1.1.1 
+#>  recipes      1.3.1       yardstick    1.3.2 
+#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
+#>  purrr::discard() masks scales::discard()
+#>  dplyr::filter()  masks stats::filter()
+#>  dplyr::lag()     masks stats::lag()
+#>  recipes::step()  masks stats::step()
+#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
+#> # A tibble: 7 × 3
+#>   .metric     .estimator .estimate
+#>   <chr>       <chr>          <dbl>
+#> 1 accuracy    binary         0.936
+#> 2 recall      binary         0.954
+#> 3 precision   binary         0.925
+#> 4 sensitivity binary         0.954
+#> 5 specificity binary         0.917
+#> 6 ppv         binary         0.925
+#> 7 npv         binary         0.948
+
+
+
+ + +
+ + + + + + + diff --git a/reference/amr-tidymodels.md b/reference/amr-tidymodels.md new file mode 100644 index 000000000..23ece0840 --- /dev/null +++ b/reference/amr-tidymodels.md @@ -0,0 +1,192 @@ +# AMR Extensions for Tidymodels + +This family of functions allows using AMR-specific data types such as +`` and `` inside `tidymodels` pipelines. + +## Usage + +``` r +all_sir() + +all_sir_predictors() + +all_mic() + +all_mic_predictors() + +all_disk() + +all_disk_predictors() + +step_mic_log2(recipe, ..., role = NA, trained = FALSE, columns = NULL, + skip = FALSE, id = recipes::rand_id("mic_log2")) + +step_sir_numeric(recipe, ..., role = NA, trained = FALSE, columns = NULL, + skip = FALSE, id = recipes::rand_id("sir_numeric")) +``` + +## Arguments + +- recipe: + + A recipe object. The step will be added to the sequence of operations + for this recipe. + +- ...: + + One or more selector functions to choose variables for this step. See + [`selections()`](https://recipes.tidymodels.org/reference/selections.html) + for more details. + +- role: + + Not used by this step since no new variables are created. + +- trained: + + A logical to indicate if the quantities for preprocessing have been + estimated. + +- skip: + + A logical. Should the step be skipped when the recipe is baked by + [`bake()`](https://recipes.tidymodels.org/reference/bake.html)? While + all operations are baked when + [`prep()`](https://recipes.tidymodels.org/reference/prep.html) is run, + some operations may not be able to be conducted on new data (e.g. + processing the outcome variable(s)). Care should be taken when using + `skip = TRUE` as it may affect the computations for subsequent + operations. + +- id: + + A character string that is unique to this step to identify it. + +## Details + +You can read more in our online [AMR with tidymodels +introduction](https://amr-for-r.org/articles/AMR_with_tidymodels.html). + +Tidyselect helpers include: + +- `all_sir()` and `all_sir_predictors()` to select + [``](https://amr-for-r.org/reference/as.sir.md) columns + +- `all_mic()` and `all_mic_predictors()` to select + [``](https://amr-for-r.org/reference/as.mic.md) columns + +- `all_disk()` and `all_disk_predictors()` to select + [``](https://amr-for-r.org/reference/as.disk.md) columns + +Pre-processing pipeline steps include: + +- `step_sir_numeric()` to convert SIR columns to numeric (via + [`as.numeric()`](https://rdrr.io/r/base/numeric.html)), to be used + with `all_sir_predictors()`: `"S"` = 1, `"I"`/`"SDD"` = 2, `"R"` = 3. + All other values are rendered `NA`. Keep this in mind for further + processing, especially if the model does not allow for `NA` values. + +- `step_mic_log2()` to convert MIC columns to numeric (via + [`as.numeric()`](https://rdrr.io/r/base/numeric.html)) and apply a + log2 transform, to be used with `all_mic_predictors()` + +These steps integrate with +[`recipes::recipe()`](https://recipes.tidymodels.org/reference/recipe.html) +and work like standard preprocessing steps. They are useful for +preparing data for modelling, especially with classification models. + +## See also + +[`recipes::recipe()`](https://recipes.tidymodels.org/reference/recipe.html), +[`as.sir()`](https://amr-for-r.org/reference/as.sir.md), +[`as.mic()`](https://amr-for-r.org/reference/as.mic.md), +[`as.disk()`](https://amr-for-r.org/reference/as.disk.md) + +## Examples + +``` r +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. + + + # example data set in the AMR package + esbl_isolates + + # Prepare a binary outcome and convert to ordered factor + data <- esbl_isolates %>% + mutate(esbl = factor(esbl, levels = c(FALSE, TRUE), ordered = TRUE)) + + # Split into training and testing sets + split <- initial_split(data) + training_data <- training(split) + testing_data <- testing(split) + + # 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() + + # View prepped recipe + mic_recipe + + # Apply the recipe to training and testing data + out_training <- bake(mic_recipe, new_data = NULL) + out_testing <- bake(mic_recipe, new_data = testing_data) + + # Fit a logistic regression model + fitted <- logistic_reg(mode = "classification") %>% + set_engine("glm") %>% + fit(esbl ~ ., data = out_training) + + # Generate predictions on the test set + predictions <- predict(fitted, out_testing) %>% + bind_cols(out_testing) + + # Evaluate predictions using standard classification metrics + our_metrics <- metric_set(accuracy, + recall, + precision, + sensitivity, + specificity, + ppv, + npv) + metrics <- our_metrics(predictions, truth = esbl, estimate = .pred_class) + + # Show performance + metrics +} +#> Loading required package: tidymodels +#> ── Attaching packages ────────────────────────────────────── tidymodels 1.4.1 ── +#> ✔ broom 1.0.11 ✔ rsample 1.3.1 +#> ✔ dials 1.4.2 ✔ tailor 0.1.0 +#> ✔ infer 1.1.0 ✔ tidyr 1.3.2 +#> ✔ modeldata 1.5.1 ✔ tune 2.0.1 +#> ✔ parsnip 1.4.0 ✔ workflows 1.3.0 +#> ✔ purrr 1.2.0 ✔ workflowsets 1.1.1 +#> ✔ recipes 1.3.1 ✔ yardstick 1.3.2 +#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ── +#> ✖ purrr::discard() masks scales::discard() +#> ✖ dplyr::filter() masks stats::filter() +#> ✖ dplyr::lag() masks stats::lag() +#> ✖ recipes::step() masks stats::step() +#> Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred +#> # A tibble: 7 × 3 +#> .metric .estimator .estimate +#> +#> 1 accuracy binary 0.936 +#> 2 recall binary 0.954 +#> 3 precision binary 0.925 +#> 4 sensitivity binary 0.954 +#> 5 specificity binary 0.917 +#> 6 ppv binary 0.925 +#> 7 npv binary 0.948 +``` diff --git a/reference/antibiogram.html b/reference/antibiogram.html index 3ae4a7ad4..2f145f4f8 100644 --- a/reference/antibiogram.html +++ b/reference/antibiogram.html @@ -9,7 +9,7 @@ Adhering to previously described approaches (see Source) and especially the Baye AMR (for R) - 3.0.1.9004 + 3.0.1.9007 + + + + + +
+
+
+ +
+

A data set containing 500 microbial isolates with MIC values of common antibiotics and a binary esbl column for extended-spectrum beta-lactamase (ESBL) production. This data set contains randomised fictitious data but reflects reality and can be used to practise AMR-related machine learning, e.g., classification modelling with tidymodels.

+
+ +
+

Usage

+
esbl_isolates
+
+ +
+

Format

+

A tibble with 500 observations and 19 variables:

  • esbl
    Logical indicator if the isolate is ESBL-producing

  • +
  • genus
    Genus of the microorganism

  • +
  • AMC:COL
    MIC values for 17 antimicrobial agents, transformed to class mic (see as.mic())

  • +
+
+

Details

+

See our tidymodels integration for an example using this data set.

+
+ +
+

Examples

+
esbl_isolates
+#> # A tibble: 500 × 19
+#>    esbl  genus   AMC   AMP   TZP   CXM   FOX   CTX   CAZ   GEN   TOB   TMP   SXT
+#>    <lgl> <chr> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic>
+#>  1 FALSE Esch…    32    32     4    64    64  8.00  8.00     1     1  16.0    20
+#>  2 FALSE Esch…    32    32     4    64    64  4.00  8.00     1     1  16.0   320
+#>  3 FALSE Esch…     4     2    64     8     4  8.00  0.12    16    16   0.5    20
+#>  4 FALSE Kleb…    32    32    16    64    64  8.00  8.00     1     1   0.5    20
+#>  5 FALSE Esch…    32    32     4     4     4  0.25  2.00     1     1  16.0   320
+#>  6 FALSE Citr…    32    32    16    64    64 64.00 32.00     1     1   0.5    20
+#>  7 FALSE Morg…    32    32     4    64    64 16.00  2.00     1     1   0.5    20
+#>  8 FALSE Prot…    16    32     4     1     4  8.00  0.12     1     1  16.0   320
+#>  9 FALSE Ente…    32    32     8    64    64 32.00  4.00     1     1   0.5    20
+#> 10 FALSE Citr…    32    32    32    64    64  8.00 64.00     1     1  16.0   320
+#> # ℹ 490 more rows
+#> # ℹ 6 more variables: NIT <mic>, FOS <mic>, CIP <mic>, IPM <mic>, MEM <mic>,
+#> #   COL <mic>
+
+
+
+ + +
+ + + + + + + diff --git a/reference/esbl_isolates.md b/reference/esbl_isolates.md new file mode 100644 index 000000000..107f2b7da --- /dev/null +++ b/reference/esbl_isolates.md @@ -0,0 +1,58 @@ +# Data Set with 500 ESBL Isolates + +A data set containing 500 microbial isolates with MIC values of common +antibiotics and a binary `esbl` column for extended-spectrum +beta-lactamase (ESBL) production. This data set contains randomised +fictitious data but reflects reality and can be used to practise +AMR-related machine learning, e.g., classification modelling with +[tidymodels](https://amr-for-r.org/articles/AMR_with_tidymodels.html). + +## Usage + +``` r +esbl_isolates +``` + +## Format + +A [tibble](https://tibble.tidyverse.org/reference/tibble.html) with 500 +observations and 19 variables: + +- `esbl` + Logical indicator if the isolate is ESBL-producing + +- `genus` + Genus of the microorganism + +- `AMC:COL` + MIC values for 17 antimicrobial agents, transformed to class + [`mic`](https://amr-for-r.org/reference/as.mic.md) (see + [`as.mic()`](https://amr-for-r.org/reference/as.mic.md)) + +## Details + +See our [tidymodels +integration](https://amr-for-r.org/reference/amr-tidymodels.md) for an +example using this data set. + +## Examples + +``` r +esbl_isolates +#> # A tibble: 500 × 19 +#> esbl genus AMC AMP TZP CXM FOX CTX CAZ GEN TOB TMP SXT +#> +#> 1 FALSE Esch… 32 32 4 64 64 8.00 8.00 1 1 16.0 20 +#> 2 FALSE Esch… 32 32 4 64 64 4.00 8.00 1 1 16.0 320 +#> 3 FALSE Esch… 4 2 64 8 4 8.00 0.12 16 16 0.5 20 +#> 4 FALSE Kleb… 32 32 16 64 64 8.00 8.00 1 1 0.5 20 +#> 5 FALSE Esch… 32 32 4 4 4 0.25 2.00 1 1 16.0 320 +#> 6 FALSE Citr… 32 32 16 64 64 64.00 32.00 1 1 0.5 20 +#> 7 FALSE Morg… 32 32 4 64 64 16.00 2.00 1 1 0.5 20 +#> 8 FALSE Prot… 16 32 4 1 4 8.00 0.12 1 1 16.0 320 +#> 9 FALSE Ente… 32 32 8 64 64 32.00 4.00 1 1 0.5 20 +#> 10 FALSE Citr… 32 32 32 64 64 8.00 64.00 1 1 16.0 320 +#> # ℹ 490 more rows +#> # ℹ 6 more variables: NIT , FOS , CIP , IPM , MEM , +#> # COL +``` diff --git a/reference/eucast_rules.html b/reference/eucast_rules.html index 836e500aa..262a8dab5 100644 --- a/reference/eucast_rules.html +++ b/reference/eucast_rules.html @@ -9,7 +9,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied AMR (for R) - 3.0.1.9004 + 3.0.1.9007