Skip to content

Commit

Permalink
scientific notation for MICs
Browse files Browse the repository at this point in the history
  • Loading branch information
msberends committed Oct 20, 2023
1 parent bcab4bc commit ca72a64
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: AMR
Version: 2.1.0.9003
Version: 2.1.0.9004
Date: 2023-10-20
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# AMR 2.1.0.9003
# AMR 2.1.0.9004

* Fix for selecting first isolates using the phenotype-based method
* This included too many isolates when patients had altering antibiograms within the same bacterial species
* See for more info [our issue #122](https://github.com/msberends/AMR/issues/122)
* Added 1,366 LOINC codes to the `antibiotics` data set and updated to the latest version (LOINC v2.76)
* MICs can now be used in complex number calculations
* MICs can now be used in complex number calculations and allow scientific number format as input (e.g., `as.mic("1.28e-2")`)
* Fix rounding MICs on latest R beta ('R-devel')
* Removed unneeded note about the used language when option `AMR_locale` is set
* Fixed non-ASCII characters in documentation, according to CRAN maintainers
Expand Down
3 changes: 2 additions & 1 deletion R/aa_globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TAXONOMY_VERSION <- list(
),
SNOMED = list(
accessed_date = as.Date("2021-07-01"),
citation = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS). US Edition of SNOMED CT from 1 September 2020. Value Set Name 'Microoganism', OID 2.16.840.1.114222.4.11.1009 (v12).",
citation = "Public Health Information Network Vocabulary Access and Distribution System (PHIN VADS). US Edition of SNOMED CT from 1 September 2020. Value Set Name 'Microorganism', OID 2.16.840.1.114222.4.11.1009 (v12).",
url = "https://phinvads.cdc.gov"
),
LOINC = list(
Expand All @@ -113,6 +113,7 @@ TAXONOMY_VERSION <- list(
)

globalVariables(c(
".GenericCallEnv",
".mo",
".rowid",
".syndromic_group",
Expand Down
2 changes: 2 additions & 0 deletions R/mic.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ as.mic <- function(x, na.rm = FALSE) {

# comma to period
x <- gsub(",", ".", x, fixed = TRUE)
# transform scientific notation
x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"] <- as.double(x[x %like% "[-]?[0-9]+([.][0-9]+)?e[-]?[0-9]+"])
# transform Unicode for >= and <=
x <- gsub("\u2264", "<=", x, fixed = TRUE)
x <- gsub("\u2265", ">=", x, fixed = TRUE)
Expand Down
13 changes: 13 additions & 0 deletions inst/tinytest/test-first_isolate.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ expect_equal(
1373
)

# for phenotype determination
expect_equal(AMR:::duplicated_antibiogram("SSSS", points_threshold = 2, ignore_I = TRUE, type = "points"),
FALSE)
expect_equal(AMR:::duplicated_antibiogram(c("RRR", "SSS"),
points_threshold = 2, ignore_I = TRUE, type = "points"),
c(FALSE, FALSE))
expect_equal(AMR:::duplicated_antibiogram(c("RRR", "RRR", "SSS"),
points_threshold = 2, ignore_I = TRUE, type = "points"),
c(FALSE, TRUE, FALSE))
expect_equal(AMR:::duplicated_antibiogram(c("RRR", "RSS", "SSS", "RSS", "RRR", "RRR", "SSS", "RSS", "RSR", "RRR"),
points_threshold = 2, ignore_I = TRUE, type = "points"),
c(FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE))

# Phenotype-based, using key antimicrobials
expect_equal(
sum(first_isolate(
Expand Down
2 changes: 1 addition & 1 deletion man/as.mo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/microorganisms.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mo_property.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ca72a64

Please sign in to comment.