Skip to content

Commit

Permalink
(v2.1.1.9121) support tidymodels
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Dec 19, 2024
1 parent 8249cfd commit 15fc72f
Show file tree
Hide file tree
Showing 16 changed files with 638 additions and 89 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
^tests/testthat/_snaps$
^vignettes/AMR\.Rmd$
^vignettes/AMR_intro\.png$
^vignettes/AMR_with_tidymodels\.Rmd$
^vignettes/benchmarks\.Rmd$
^vignettes/benchmarks\.Rmd\.not$
^vignettes/datasets\.Rmd$
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: AMR
Version: 2.1.1.9120
Date: 2024-12-15
Version: 2.1.1.9121
Date: 2024-12-19
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by
Expand Down Expand Up @@ -47,6 +47,7 @@ Suggests:
rvest,
skimr,
tibble,
tidymodels,
tidyselect,
tinytest,
vctrs,
Expand Down
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AMR 2.1.1.9120
# AMR 2.1.1.9121

*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*

Expand Down Expand Up @@ -30,6 +30,8 @@ This package now supports not only tools for AMR data analysis in clinical setti
* New function `rescale_mic()`, which allows users to rescale MIC values to a manually set range. This is the powerhouse behind the `scale_*_mic()` functions, but it can be used independently to, for instance, compare equality in MIC distributions by rescaling them to the same range first.
* **Support for Python**
* While using R for the heavy lifting, [our 'AMR' Python Package](https://pypi.org/project/AMR/) was developed to run the AMR R package natively in Python. The Python package will always have the same version number as the R package, as it is built automatically with every code change.
* **Support for `tidymodels`**
* All antimicrobial selectors (such as `aminoglycosides()` and `betalactams()`) are now supported in `tidymodels` packages such as `recipe` and `parsnip`. See for more info [our tutorial](https://msberends.github.io/AMR/articles/AMR_with_tidymodels.html) on using AMR function for predictive modelling.
* **Other**
* New function `mo_group_members()` to retrieve the member microorganisms of a microorganism group. For example, `mo_group_members("Strep group C")` returns a vector of all microorganisms that belong to that group.

Expand Down Expand Up @@ -73,7 +75,9 @@ This package now supports not only tools for AMR data analysis in clinical setti
* Updated the prevalence calculation to include genera from the World Health Organization's (WHO) Priority Pathogen List
* Improved algorithm of `first_isolate()` when using the phenotype-based method, to prioritise records with the highest availability of SIR values
* `scale_y_percent()` can now cope with ranges outside the 0-100% range
* Support for new Dutch national MDRO guideline (SRI-richtlijn BRMO, Nov 2024)
* MDRO determination (using `mdro()`)
* Implemented the new Dutch national MDRO guideline (SRI-richtlijn BRMO, Nov 2024)
* Added arguments `esbl`, `carbapenemase`, `mecA`, `mecC`, `vanA`, `vanB` to denote column names or logical values indicating presence of these genes (or production of their proteins)

## Other
* Greatly improved `vctrs` integration, a Tidyverse package working in the background for many Tidyverse functions. For users, this means that functions such as `dplyr`'s `bind_rows()`, `rowwise()` and `c_across()` are now supported for e.g. columns of class `mic`. Despite this, this `AMR` package is still zero-dependent on any other package, including `dplyr` and `vctrs`.
Expand Down
2 changes: 1 addition & 1 deletion PythonPackage/AMR/AMR.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: AMR
Version: 2.1.1.9120
Version: 2.1.1.9121
Summary: A Python wrapper for the AMR R package
Home-page: https://github.com/msberends/AMR
Author: Matthijs Berends
Expand Down
4 changes: 2 additions & 2 deletions PythonPackage/AMR/AMR/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ def mdr_tb(x = None, *args, **kwargs):
def mdr_cmi2012(x = None, *args, **kwargs):
"""See our website of the R package for the manual: https://msberends.github.io/AMR/index.html"""
return convert_to_python(amr_r.mdr_cmi2012(x = None, *args, **kwargs))
def eucast_exceptional_phenotypes(x = None, *args, **kwargs):
def eucast_exceptional_phenotypes(*args, **kwargs):
"""See our website of the R package for the manual: https://msberends.github.io/AMR/index.html"""
return convert_to_python(amr_r.eucast_exceptional_phenotypes(x = None, *args, **kwargs))
return convert_to_python(amr_r.eucast_exceptional_phenotypes(*args, **kwargs))
def mean_amr_distance(x, *args, **kwargs):
"""See our website of the R package for the manual: https://msberends.github.io/AMR/index.html"""
return convert_to_python(amr_r.mean_amr_distance(x, *args, **kwargs))
Expand Down
Binary file not shown.
Binary file removed PythonPackage/AMR/dist/amr-2.1.1.9120.tar.gz
Binary file not shown.
Binary file added PythonPackage/AMR/dist/amr-2.1.1.9121.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion PythonPackage/AMR/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='AMR',
version='2.1.1.9120',
version='2.1.1.9121',
packages=find_packages(),
install_requires=[
'rpy2',
Expand Down
5 changes: 4 additions & 1 deletion R/aa_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ get_current_data <- function(arg_name, call) {
for (env in frms[which(with_mask)]) {
if (is.function(env$mask$current_rows) && (valid_df(env$data) || valid_df(env$`.data`))) {
# an element `.data` or `data` (containing all data) and `mask` (containing functions) will be in the environment when using dplyr verbs
# we use their mask$current_rows() to get the group rows, since dplyr::cur_data_all() is deprecated and will be removed in the future
# we use their mask$current_rows() below to get the group rows, since dplyr::cur_data_all() is deprecated and will be removed in the future
# e.g. for `example_isolates %>% group_by(ward) %>% mutate(first = first_isolate(.))`
if (valid_df(env$data)) {
# support for dplyr 1.1.x
Expand All @@ -1008,6 +1008,9 @@ get_current_data <- function(arg_name, call) {
if (valid_df(env$`.data`)) {
# an element `.data` will be in the environment when using dplyr::select()
return(env$`.data`)
} else if (valid_df(env$data)) {
# an element `data` will be in the environment when using older dplyr versions, or tidymodels
return(env$data)
} else if (valid_df(env$xx)) {
# an element `xx` will be in the environment for rows + cols in base R, e.g. `example_isolates[c(1:3), carbapenems()]`
return(env$xx)
Expand Down
Loading

0 comments on commit 15fc72f

Please sign in to comment.