Skip to content

Commit

Permalink
(v2.1.1.9126) implemented WISCA! Also added top_n_microorganisms()
Browse files Browse the repository at this point in the history
…and fixed Python wrapper
  • Loading branch information
msberends committed Jan 26, 2025
1 parent 92c4fc0 commit 66833b4
Show file tree
Hide file tree
Showing 46 changed files with 1,825 additions and 1,881 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: AMR
Version: 2.1.1.9125
Date: 2025-01-17
Version: 2.1.1.9126
Date: 2025-01-26
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 @@ -59,4 +59,4 @@ License: GPL-2 | file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Roxygen: list(markdown = TRUE, old_usage = TRUE)
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ S3method(Ops,mic)
S3method(Summary,mic)
S3method(all,amr_selector)
S3method(all,amr_selector_any_all)
S3method(antibiogram,default)
S3method(antibiogram,grouped_df)
S3method(any,amr_selector)
S3method(any,amr_selector_any_all)
S3method(as.data.frame,ab)
Expand Down Expand Up @@ -219,6 +221,7 @@ export(g.test)
export(geom_sir)
export(get_AMR_locale)
export(get_episode)
export(get_long_numeric_format)
export(get_mo_source)
export(ggplot_pca)
export(ggplot_sir)
Expand Down Expand Up @@ -335,9 +338,11 @@ export(streptogramins)
export(susceptibility)
export(tetracyclines)
export(theme_sir)
export(top_n_microorganisms)
export(translate_AMR)
export(trimethoprims)
export(ureidopenicillins)
export(wisca)
importFrom(graphics,arrows)
importFrom(graphics,axis)
importFrom(graphics,barplot)
Expand Down
15 changes: 10 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# AMR 2.1.1.9125
# AMR 2.1.1.9126

*(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).)*

#### A New Milestone: AMR v3.0 with One Health Support (= Human + Veterinary + Environmental)
This package now supports not only tools for AMR data analysis in clinical settings, but also for veterinary and environmental microbiology. This was made possible through a collaboration with the [University of Prince Edward Island's Atlantic Veterinary College](https://www.upei.ca/avc), Canada. To celebrate this great improvement of the package, we also updated the package logo to reflect this change.

## Breaking
* Removed all functions and references that used the deprecated `rsi` class, which were all replaced with their `sir` equivalents over a year ago
* Removed all functions and references that used the deprecated `rsi` class, which were all replaced with their `sir` equivalents two years ago

## New
* **One Health implementation**
Expand All @@ -16,6 +16,8 @@ This package now supports not only tools for AMR data analysis in clinical setti
* The `antibiotics` data set contains all veterinary antibiotics, such as pradofloxacin and enrofloxacin. All WHOCC codes for veterinary use have been added as well.
* `ab_atc()` now supports ATC codes of veterinary antibiotics (that all start with "Q")
* `ab_url()` now supports retrieving the WHOCC url of their ATCvet pages
* Support for WISCA antibiograms**
* The `antibiogram()` function now supports creating true Weighted-Incidence Syndromic Combination Antibiograms (WISCA), a powerful Bayesian method for estimating regimen coverage probabilities using pathogen incidence and antimicrobial susceptibility data. WISCA offers improved precision for syndrome-specific treatment, even in datasets with sparse data. A dedicated `wisca()` function is also available for easy usage.
* **Major update to fungal taxonomy and tools for mycologists**
* MycoBank has now been integrated as the primary taxonomic source for fungi. The `microorganisms` data set has been enriched with new columns (`mycobank`, `mycobank_parent`, and `mycobank_renamed_to`) that provide detailed information for fungal species.
* A remarkable addition of over 20,000 new fungal records
Expand All @@ -33,7 +35,9 @@ This package now supports not only tools for AMR data analysis in clinical setti
* **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 these AMR functions for predictive modelling.
* **Other**
* New function `top_n_microorganisms()` to filter a data set to the top *n* of any taxonomic property, e.g., filter to the top 3 species, filter to any species in the top 5 genera, or filter to the top 3 species in each of the top 5 genera
* 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.


## Changed
* SIR interpretation
Expand Down Expand Up @@ -68,12 +72,12 @@ This package now supports not only tools for AMR data analysis in clinical setti
* Updated all antibiotic DDDs from WHOCC
* Added over 1,500 trade names for antibiotics
* Fix for using a manual value for `mo_transform` in `antibiogram()`
* Fixed a bug for when `antibiogram()` returns an empty data set
* Fix for mapping 'high level' antibiotics in `as.ab()` (amphotericin B-high, gentamicin-high, kanamycin-high, streptomycin-high, tobramycin-high)
* Improved overall algorithm of `as.ab()` for better performance and accuracy
* Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically:
* More weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species
* Genera from the World Health Organization's (WHO) Priority Pathogen List now have the highest prevalence
* Fixed a bug for when `antibiogram()` returns an empty data set
* Fixed a bug for `sir_confidence_interval()` when there are no isolates available
* 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
Expand All @@ -83,14 +87,15 @@ This package now supports not only tools for AMR data analysis in clinical setti
* 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
* Added Dr. Larisse Bolton as contributor for her fantastic implementation of WISCA in a mathematically solid way
* Added Matthew Saab, Dr. Jordan Stull, and Prof. Javier Sanchez as contributors for their tremendous input on veterinary breakpoints and interpretations
* 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`.
* Greatly updated and expanded documentation
* Added Larisse Bolton, Jordan Stull, Matthew Saab, and Javier Sanchez as contributors, to thank them for their valuable input
* Stopped support for SAS (`.xpt`) files, since their file structure and extremely inefficient and requires more disk space than GitHub allows in a single commit.

## Older Versions

This changelog only contains changes from AMR v3.0 (October 2024) and later.
This changelog only contains changes from AMR v3.0 (February 2025) and later.

* For prior v2 versions, please see [our v2 archive](https://github.com/msberends/AMR/blob/v2.1.1/NEWS.md).
* For prior v1 versions, please see [our v1 archive](https://github.com/msberends/AMR/blob/v1.8.2/NEWS.md).
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.2
Name: AMR
Version: 2.1.1.9125
Version: 2.1.1.9126
Summary: A Python wrapper for the AMR R package
Home-page: https://github.com/msberends/AMR
Author: Matthijs Berends
Expand Down
2 changes: 2 additions & 0 deletions PythonPackage/AMR/AMR/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .functions import age
from .functions import age_groups
from .functions import antibiogram
from .functions import wisca
from .functions import amr_class
from .functions import amr_selector
from .functions import aminoglycosides
Expand Down Expand Up @@ -201,5 +202,6 @@
from .functions import sir_predict
from .functions import ggplot_sir_predict
from .functions import skewness
from .functions import top_n_microorganisms
from .functions import reset_AMR_locale
from .functions import translate_AMR
9 changes: 6 additions & 3 deletions PythonPackage/AMR/AMR/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
RESET = '\033[0m'

import os
import sys
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr, isinstalled
import pandas as pd
import importlib.metadata as metadata

# Get the path to the virtual environment
venv_path = os.getenv('VIRTUAL_ENV') # Path to the active virtual environment
venv_path = sys.prefix

# Define R library path within the venv
r_lib_path = os.path.join(venv_path, "R_libs")
Expand All @@ -19,10 +20,12 @@
# Set the R library path in .libPaths
base = importr('base')
base._libPaths(r_lib_path)
r_amr_lib_path = base._libPaths()[0]

# Check if the AMR package is installed in R
if not isinstalled('AMR'):
if not isinstalled('AMR', lib_loc = r_amr_lib_path):
utils = importr('utils')
print(f"{BLUE}AMR:{RESET} Installing AMR package to {BLUE}{r_amr_lib_path}/{RESET}...", flush=True)
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)

# Python package version of AMR
Expand All @@ -37,7 +40,7 @@
# Compare R and Python package versions
if r_amr_version != python_amr_version:
try:
print(f"{BLUE}AMR:{RESET} Updating package version{RESET}", flush=True)
print(f"{BLUE}AMR:{RESET} Updating AMR package in {BLUE}{r_amr_lib_path}/{RESET}...", flush=True)
utils = importr('utils')
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
except Exception as e:
Expand Down
Loading

0 comments on commit 66833b4

Please sign in to comment.