mirror of
https://github.com/msberends/AMR.git
synced 2026-05-14 03:50:49 +02:00
* Add parallel computing support to antibiogram() and wisca() (#281) For WISCA: simulations are distributed across (group, chunk) job pairs via future.apply::future_lapply(), keeping all workers active even when the regimen count is smaller than nbrOfWorkers(). Sequential fallback with progress ticker is preserved when parallel = FALSE or workers = 1. For grouped antibiograms: each group is processed by a separate worker, mirroring the row-batch approach in as.sir(). Same gate pattern as as.sir() (PR #280): requires a non-sequential future::plan() to be active; auto-upgrades to parallel = TRUE when a parallel plan is detected; throws an informative error otherwise. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF * Fix version to 3.0.1.9055 and update CLAUDE.md version formula Uses origin/${defaultbranch} (with a fetch) instead of the local branch ref so the commit count is never stale after a merge. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF * Fix non-ASCII characters in antibiogram.R Replace en/em dashes and non-breaking spaces with ASCII equivalents to satisfy R CMD check portability requirement. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF * Update auto-generated Rd files after documentation rebuild https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF * Move parallel gate to top of antibiogram.default() like sir.R The gate was inside the wisca==TRUE block, so parallel=TRUE with a sequential plan was silently ignored for non-WISCA antibiograms. Now the gate runs unconditionally at the top of the function, identical to the as.sir() pattern: error on explicit parallel=TRUE with sequential plan, auto-upgrade when a non-sequential plan is already active. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF * Fix parallel WISCA returning all NA; strengthen tests; add sequential hint Bug: lapply() over a factor yields length-1 factor elements (integer codes), while for() over a factor yields character strings. The job list stored j\$group as a factor integer, but the reassembly loop compared it with identical(j\$group, g) where g was character -- always FALSE, so no simulation chunks were ever assembled and coverage stayed NA throughout. Fix: convert unique_groups to character before building jobs so both the job list and the reassembly loop use the same type. Tests: replaced na.rm = TRUE guards with explicit anyNA() checks so the test suite would have caught the all-NA result immediately. Also adds a sequential-mode performance hint (analogous to sir.R lines 1116-1127) when simulations >= 500 and >= 3 regimens. https://claude.ai/code/session_01FC43syPbzhGmKgrrVNHjnF --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,8 @@ antibiogram(x, antimicrobials = where(is.sir), mo_transform = "shortname",
|
||||
ifelse(wisca, 14, 18)), col_mo = NULL, language = get_AMR_locale(),
|
||||
minimum = 30, combine_SI = TRUE, sep = " + ", sort_columns = TRUE,
|
||||
wisca = FALSE, simulations = 1000, conf_interval = 0.95,
|
||||
interval_side = "two-tailed", info = interactive(), ...)
|
||||
interval_side = "two-tailed", info = interactive(), parallel = FALSE,
|
||||
...)
|
||||
|
||||
wisca(x, antimicrobials = where(is.sir), ab_transform = "name",
|
||||
syndromic_group = NULL, only_all_tested = FALSE, digits = 1,
|
||||
@@ -33,7 +34,7 @@ wisca(x, antimicrobials = where(is.sir), ab_transform = "name",
|
||||
col_mo = NULL, language = get_AMR_locale(), combine_SI = TRUE,
|
||||
sep = " + ", sort_columns = TRUE, simulations = 1000,
|
||||
conf_interval = 0.95, interval_side = "two-tailed",
|
||||
info = interactive(), ...)
|
||||
info = interactive(), parallel = FALSE, ...)
|
||||
|
||||
retrieve_wisca_parameters(wisca_model, ...)
|
||||
|
||||
@@ -80,7 +81,7 @@ retrieve_wisca_parameters(wisca_model, ...)
|
||||
|
||||
\item{digits}{Number of digits to use for rounding the antimicrobial coverage, defaults to 1 for WISCA and 0 otherwise.}
|
||||
|
||||
\item{formatting_type}{Numeric value (1–22 for WISCA, 1-12 for non-WISCA) indicating how the 'cells' of the antibiogram table should be formatted. See \emph{Details} > \emph{Formatting Type} for a list of options.}
|
||||
\item{formatting_type}{Numeric value (1-22 for WISCA, 1-12 for non-WISCA) indicating how the 'cells' of the antibiogram table should be formatted. See \emph{Details} > \emph{Formatting Type} for a list of options.}
|
||||
|
||||
\item{col_mo}{Column name of the names or codes of the microorganisms (see \code{\link[=as.mo]{as.mo()}}) - the default is the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.}
|
||||
|
||||
@@ -104,6 +105,8 @@ retrieve_wisca_parameters(wisca_model, ...)
|
||||
|
||||
\item{info}{A \link{logical} to indicate info should be printed - the default is \code{TRUE} only in interactive mode.}
|
||||
|
||||
\item{parallel}{A \link{logical} to indicate if parallel computing must be used, defaults to \code{FALSE}. Requires the \code{\link[future.apply:future_lapply]{future.apply}} package. For WISCA, Monte Carlo simulations are distributed across workers; for grouped antibiograms, each group is processed by a separate worker. \strong{A non-sequential \code{\link[future:plan]{future::plan()}} must already be active before setting \code{parallel = TRUE}} -- for example, \code{future::plan(future::multisession)}. An error is thrown if \code{parallel = TRUE} is used without a plan set by the user.}
|
||||
|
||||
\item{...}{When used in \link[knitr:kable]{R Markdown or Quarto}: arguments passed on to \code{\link[knitr:kable]{knitr::kable()}} (otherwise, has no use).}
|
||||
|
||||
\item{wisca_model}{The outcome of \code{\link[=wisca]{wisca()}} or \code{\link[=antibiogram]{antibiogram(..., wisca = TRUE)}}.}
|
||||
|
||||
@@ -45,9 +45,8 @@ A list with class \code{"htest"} containing the following
|
||||
\item{residuals}{the Pearson residuals,
|
||||
\code{(observed - expected) / sqrt(expected)}.}
|
||||
\item{stdres}{standardized residuals,
|
||||
\code{(observed - expected) / sqrt(V)}, where \code{V} is the
|
||||
residual cell variance (Agresti, 2007, section 2.4.5
|
||||
for the case where \code{x} is a matrix, \code{n * p * (1 - p)} otherwise).}
|
||||
\code{(observed - expected) / sqrt(V)}, where \code{V} is the residual cell variance (Agresti, 2007,
|
||||
section 2.4.5 for the case where \code{x} is a matrix, \code{n * p * (1 - p)} otherwise).}
|
||||
}
|
||||
\description{
|
||||
\code{\link[=g.test]{g.test()}} performs chi-squared contingency table tests and goodness-of-fit tests, just like \code{\link[=chisq.test]{chisq.test()}} but is more reliable (1). A \emph{G}-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a \strong{\emph{G}-test of goodness-of-fit}), or to see whether the proportions of one variable are different for different values of the other variable (called a \strong{\emph{G}-test of independence}).
|
||||
|
||||
@@ -32,7 +32,7 @@ pca(x, ..., retx = TRUE, center = TRUE, scale. = TRUE, tol = NULL,
|
||||
standard deviations are less than or equal to \code{tol} times the
|
||||
standard deviation of the first component.) With the default null
|
||||
setting, no components are omitted (unless \code{rank.} is specified
|
||||
less than \code{min(dim(x))}.). Other settings for \code{tol} could be
|
||||
less than \code{min(dim(x))}.). Other settings for tol could be
|
||||
\code{tol = 0} or \code{tol = sqrt(.Machine$double.eps)}, which
|
||||
would omit essentially constant components.}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user