mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:06:12 +01:00
fix sorting of MICs, MIC autoplot titles
This commit is contained in:
parent
c3ce1b551d
commit
d4490c7f25
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9033
|
||||
Date: 2024-05-24
|
||||
Version: 2.1.1.9034
|
||||
Date: 2024-05-30
|
||||
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
|
||||
|
3
NEWS.md
3
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 2.1.1.9033
|
||||
# AMR 2.1.1.9034
|
||||
|
||||
*(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!)*
|
||||
|
||||
@ -26,6 +26,7 @@ This package now supports not only tools for AMR data analysis in clinical setti
|
||||
* Added as valid levels: 4096, 6 powers of 0.0625, and 5 powers of 192 (192, 384, 576, 768, 960)
|
||||
* Added new argument `keep_operators` to `as.mic()`. This can be `"all"` (default), `"none"`, or `"edges"`. This argument is also available in the new `rescale_mic()` and `scale_*_mic()` functions.
|
||||
* Comparisons of MIC values are now more strict. For example, `>32` is higher than (and never equal to) `32`. Thus, `as.mic(">32") == as.mic(32)` now returns `FALSE`, and `as.mic(">32") > as.mic(32)` now returns `TRUE`.
|
||||
* Sorting of MIC values (using `sort()`) was fixed in the same manner; `<0.001` now gets sorted before `0.001`, and `>0.001` gets sorted after `0.001`.
|
||||
* Updated `italicise_taxonomy()` to support HTML output
|
||||
* `mo_info()` now contains an extra element `group_members`, with the contents of the new `mo_group_members()` function
|
||||
* 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`.
|
||||
|
@ -889,6 +889,7 @@ eucast_rules <- function(x,
|
||||
),
|
||||
type = "ansi"
|
||||
))
|
||||
cat("\n")
|
||||
warned <- FALSE
|
||||
}
|
||||
run_changes <- edit_sir(
|
||||
|
11
R/mic.R
11
R/mic.R
@ -495,12 +495,17 @@ rep.mic <- function(x, ...) {
|
||||
#' @noRd
|
||||
sort.mic <- function(x, decreasing = FALSE, ...) {
|
||||
x <- as.mic(x) # make sure that currently implemented MIC levels are used
|
||||
dbl <- as.double(x)
|
||||
# make sure that e.g. '<0.001' comes before '0.001', and '>0.001' comes after
|
||||
dbl[as.character(x) %like% "<[0-9]"] <- dbl[as.character(x) %like% "<[0-9]"] - 0.000002
|
||||
dbl[as.character(x) %like% "<="] <- dbl[as.character(x) %like% "<="] - 0.000001
|
||||
dbl[as.character(x) %like% ">="] <- dbl[as.character(x) %like% ">="] + 0.000001
|
||||
dbl[as.character(x) %like% ">[0-9]"] <- dbl[as.character(x) %like% ">[0-9]"] + 0.000002
|
||||
if (decreasing == TRUE) {
|
||||
ord <- order(-as.double(x))
|
||||
x[order(-dbl)]
|
||||
} else {
|
||||
ord <- order(as.double(x))
|
||||
x[order(dbl)]
|
||||
}
|
||||
x[ord]
|
||||
}
|
||||
|
||||
#' @method hist mic
|
||||
|
2
R/plot.R
2
R/plot.R
@ -309,7 +309,6 @@ autoplot.mic <- function(object,
|
||||
breakpoint_type = getOption("AMR_breakpoint_type", "human"),
|
||||
...) {
|
||||
stop_ifnot_installed("ggplot2")
|
||||
object <- as.mic(object) # make sure that currently implemented MIC levels are used
|
||||
meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE)
|
||||
meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE)
|
||||
meet_criteria(guideline, allow_class = "character", has_length = 1)
|
||||
@ -327,6 +326,7 @@ autoplot.mic <- function(object,
|
||||
title <- gsub(" +", " ", paste0(title, collapse = " "))
|
||||
}
|
||||
|
||||
object <- as.mic(object) # make sure that currently implemented MIC levels are used
|
||||
x <- range_as_table(object, expand = expand)
|
||||
cols_sub <- plot_colours_subtitle_guideline(
|
||||
x = x,
|
||||
|
3
R/sir.R
3
R/sir.R
@ -884,6 +884,9 @@ as_sir_method <- function(method_short,
|
||||
if (length(mo) == 1) {
|
||||
mo <- rep(mo, length(x))
|
||||
}
|
||||
if (length(ab) == 1) {
|
||||
ab <- rep(ab, length(x))
|
||||
}
|
||||
if (is.null(uti)) {
|
||||
uti <- NA
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user