1
0
mirror of https://github.com/msberends/AMR.git synced 2026-03-11 15:47:54 +01:00
Commit Graph

1732 Commits

Author SHA1 Message Date
cba315c2e7 (v3.0.1.9032) fix unit tests 2026-03-08 20:36:15 +01:00
b6f8584994 (v3.0.1.9031) fix MDRO for non-RStudio terminal 2026-03-08 11:30:18 +01:00
e2102c081a (v3.0.1.9030) fix R 3.6 2026-03-07 18:07:24 +01:00
Matthijs Berends
9af726dcaa mdro(): infer base drug resistance from drug+inhibitor combination co… (#263)
* mdro(): infer base drug resistance from drug+inhibitor combination columns (#209)

When a base beta-lactam column (e.g., piperacillin/PIP) is absent but a
corresponding drug+inhibitor combination (e.g., piperacillin/tazobactam/TZP)
is present and resistant, resistance in the base drug is now correctly
inferred. This is clinically sound: resistance in a combination implies the
inhibitor provided no benefit, so the base drug is also resistant.

Susceptibility in a combination is NOT propagated to the base drug (the
inhibitor may be responsible for susceptibility), so only R values are
inferred; missing base drugs remain NA otherwise.

Implementation details:
- Uses AB_BETALACTAMS_WITH_INHIBITOR to identify all beta-lactam+inhibitor
  combinations present in the user's data
- Derives base drug AB codes by stripping the "/inhibitor" part from names
- Creates synthetic proxy columns (.sir_proxy_<AB>) in x, set to "R" when
  any matching combination is R, otherwise NA
- Proxy columns are added to cols_ab before drug variable assignment,
  so all existing guideline logic benefits without any changes
- Multiple combos for the same base drug are OR-ed (any R → R)
- Adds internal ab_without_inhibitor() helper for the name->base mapping
- Verbose mode reports which combinations are used for inference

Bumps version: 3.0.1.9028 -> 3.0.1.9029

https://claude.ai/code/session_01Cp154UtssHg84bw38xiiTG

* Add sir.R/mic.R fixes and mdro() unit tests; bump to 3.0.1.9030

R/sir.R (line 571):
  Guard purely numeric strings (e.g. "1", "8") from the Unicode letter
  filter. Values matching the broad SIR regex but consisting only of digits
  must not be stripped; add `x %unlike% "^[0-9+]$"` predicate.

R/mic.R (lines 220-222):
  Preserve the letter 'e' during Unicode-letter removal so that MIC values
  in scientific notation (e.g. "1e-3", "2.5e-2") survive the cleaning step.
  - Line 220: [\\p{L}] → [^e\\P{L}]  (remove all letters except 'e')
  - Line 222: [^0-9.><= -]+ → [^0-9e.><= -]+  (allow 'e' in whitelist)

tests/testthat/test-mdro.R:
  New tests for the drug+inhibitor inference added in the previous commit
  (issue #209):
  - TZP=R with no PIP column → PIP inferred R → MDRO class elevated
  - TZP=S with no PIP column → proxy col is NA (not S) → class lower
  - verbose mode emits "Inferring resistance" message
  - AMC=R with no AMX column runs without error (Enterococcus faecium)

https://claude.ai/code/session_01Cp154UtssHg84bw38xiiTG

* Fix version to single bump (9029) and update CLAUDE.md versioning rules

CLAUDE.md: Rewrite the "Version and date bump" subsection to document that:
- Exactly ONE version bump is allowed per PR (PRs are squash-merged into one
  commit on the default branch, so one commit = one version increment)
- The correct version is computed from git history:
    currentversion="${currenttag}.$((commits_since_tag + 9001 + 1))"
  with the +1 accounting for the PR's own squash commit not yet on the
  default branch
- Fall back to incrementing DESCRIPTION's version by 1 if git describe fails
- The Date: field tracks the date of the *last* PR commit (updated each time)

DESCRIPTION / NEWS.md: Correct the version from 3.0.1.9030 back to 3.0.1.9029.
Two version bumps were made across two commits in this PR; since it will be
squash-merged as one commit only one bump is correct. Also update Date to
today (2026-03-07).

https://claude.ai/code/session_01Cp154UtssHg84bw38xiiTG

* Fix stats::setNames, test accessor bug, and version script verification

R/mdro.R:
  Qualify setNames() as stats::setNames() in the drug+inhibitor inference
  block to satisfy R CMD CHECK's global-function checks.

tests/testthat/test-mdro.R:
  mdro() with verbose=FALSE returns an atomic ordered factor, not a
  data.frame. Fix three test errors introduced in the previous commit:
  - Line 320: result_no_pip$MDRO -> result_no_pip (factor, no $ accessor)
  - Line 328: result_tzp_s$MDRO / result_no_pip$MDRO -> direct factor refs
  - Line 347: expect_inherits(..., "data.frame") -> c("factor","ordered")
  Also fix the comment on line 347 to match the actual return type.

Version: confirmed at 3.0.1.9029 (no further bump; one bump already made
this PR). git describe failed (no tags in dev environment) — fallback
applies. The +1 in CLAUDE.md's formula is correct for tagged repos:
currentcommit + 9001 + 1 = 27 + 9001 + 1 = 9029 ✓

https://claude.ai/code/session_01Cp154UtssHg84bw38xiiTG

* Fix unit tests: use mrgn guideline and expect_message() for proxy tests

Three failures corrected:

1. Classification tests (lines 321, 329): The EUCAST guideline for
   P. aeruginosa already has OR logic (PIP OR TZP), so TZP=R alone
   satisfies it regardless of whether the PIP proxy exists. Switch to
   guideline="mrgn": the MRGN 4MRGN criterion for P. aeruginosa
   requires PIP=R explicitly (lines 1488-1496 of mdro.R), with no TZP
   fallback. Without the proxy: PIP missing -> not 4MRGN -> level 1.
   With the proxy (TZP=R infers PIP=R): 4MRGN reached -> level 3.
   The TZP=S case leaves proxy=NA, so PIP is still absent effectively
   -> level 1, which is < level 3 as expected.

2. Verbose/message test (line 335): message_() routes through message()
   to stderr, not cat() to stdout. expect_output() only captures stdout
   so it always saw nothing. Fix: use expect_message() instead, and
   remove the inner suppressMessages() that was swallowing the message
   before expect_message() could capture it.

Also trim two stale lines left over from the old expect_output block.

https://claude.ai/code/session_01Cp154UtssHg84bw38xiiTG

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-07 18:06:55 +01:00
daab605ca4 (v3.0.1.9028) fix unique CIDs 2026-03-06 18:53:42 +01:00
c0a394008e (v3.0.1.9027) Fixes #252 and add documentation update regarding #253 2026-03-06 13:10:33 +01:00
60e8f2bae6 (v3.0.1.9026) fix ab_group(NA) 2026-03-06 12:41:27 +01:00
Matthijs Berends
4e3ea95fbd Claude/fix issue 245 (#262)
* fix: restore valid AB codes mangled by generalise_antibiotic_name() (#245)

When as.ab() received a vector containing both valid AB codes (like ETH,
PHN, PHE, STH, THA, MTH, THI1) and an untranslatable value, the fast
path at line 100 was skipped. The slow path then applied
generalise_antibiotic_name(), which rewrites "TH"->"T" and "PH"->"F",
mangling these short AB codes (e.g. ETH->"ET", PHN->"FN") so they could
no longer be found in the lookup table.

Fix: save the pre-generalised values before applying
generalise_antibiotic_name(), then restore any elements that were already
valid AB codes in their original form.

https://claude.ai/code/session_01Sujw89qa48NoUmMPDBJLz9

* fix: use toupper() in AB code restoration to handle lowercase input (#245)

Ensures that lowercase user input (e.g. 'eth', 'phn') is matched
case-insensitively against the uppercase AB codes in $ab, and that
the restored value is stored in uppercase to match the lookup table.

https://claude.ai/code/session_01Sujw89qa48NoUmMPDBJLz9

* revert: remove unnecessary toupper() since x is already uppercased

https://claude.ai/code/session_01Sujw89qa48NoUmMPDBJLz9

* Revise versioning and date bump requirements for PRs

Updated versioning instructions for pull requests to include date bump.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-04 08:59:44 +01:00
0311834035 Merge branch 'main' of https://github.com/msberends/AMR 2026-03-03 15:44:34 +01:00
b6211931f8 (v3.0.1.9022) add ceftibuten/avibactam (CTA), kasugamycin (KAS), ostreogrycin (OST), thiostrepton (THS), xeruborbactam (XER), zorbamycin (ZOR) 2026-03-03 15:41:08 +01:00
Matthijs Berends
2c21eba04c add CLAUDE.md with project context for Claude Code (#261)
* add CLAUDE.md with project context for Claude Code

Provides development commands, architecture overview, file conventions,
custom S3 classes, data files, testing setup, and versioning guidelines
to help Claude Code assist effectively in this repository.

https://claude.ai/code/session_01L3fTxqsg3Gc6J1znpWN1Mx

* add CLAUDE.md to .Rbuildignore

Excludes the Claude Code context file from the R package build tarball.

https://claude.ai/code/session_01L3fTxqsg3Gc6J1znpWN1Mx

* document version-bump requirement for every PR in CLAUDE.md

Each PR must increment the .9zzz dev counter by 1 in both
DESCRIPTION (Version: field) and NEWS.md (top-level heading).

https://claude.ai/code/session_01L3fTxqsg3Gc6J1znpWN1Mx

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-27 17:13:11 +01:00
12cf144b19 (v3.0.1.9021) add guideline to resistance() and susceptibility() 2026-02-12 20:34:06 +01:00
499c830ee7 (v3.0.1.9020) unit test fixes 2026-02-09 13:16:36 +01:00
ba4c159154 (v3.0.1.9019) Wildtype/Non-wildtype support, and start with interpretive_rules()
Fixes #246
Fixes #254
Fixes #255
Fixes #256
2026-02-08 23:15:40 +01:00
2df2911cf4 (v3.0.1.9018) fixes #249
updates AB groups
2026-01-16 10:57:03 +01:00
fd50c51543 (v3.0.1.9017) fix documentation 2026-01-08 14:03:02 +01:00
cfd1922dd9 (v3.0.1.9016) fix unit test 2026-01-08 12:29:08 +01:00
7df28bce28 (v3.0.1.9015) fix translations 2026-01-08 10:21:48 +01:00
7b9c151241 (v3.0.1.9014) try-again fix 2026-01-07 15:10:21 +01:00
85e8e814e8 (v3.0.1.9013) fix translations 2026-01-07 13:30:54 +01:00
fa827f27f4 (v3.0.1.9012) fix translations 2026-01-07 11:00:58 +01:00
9d1b4565f6 (v3.0.1.9008) fix #246
Merge branch 'main' of https://github.com/msberends/AMR

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/sysdata.rda
#	data/antibiotics.rda
2026-01-06 23:11:34 +01:00
cfbbfb4fa5 (v3.0.1.9007) fix #246 2026-01-06 23:08:50 +01:00
35debe25ee (v3.0.1.9009) tidymodels vignette 2025-12-23 11:02:26 +01:00
e9cf3d5572 (v3.0.1.9008) tidymodels vignette 2025-12-22 19:04:39 +01:00
a5c6aa9fa8 (v3.0.1.9007) fix vignette 2025-12-22 09:34:58 +01:00
f6e28ac95c (v3.0.1.9006) Fix website 2025-12-21 12:29:46 +01:00
151af21f38 (v3.0.1.9005) re-add tidymodels implementation 2025-12-21 12:19:43 +01:00
225c73f7e7 (v3.0.1.9004) Revamp as.sir() interpretation for capped MICs
Fixes #243
Fixes #244
2025-12-15 13:18:13 +01:00
ba30b08f76 (v3.0.1.9003) Add taniborbactam and cefepime/taniborbactam 2025-11-24 11:24:02 +01:00
d366949f1b (v3.0.1.9002) replace WHONET directives with their GitHub repo 2025-10-13 22:12:48 +02:00
0b24967b23 (v3.0.1.9001) fix antibiogram 2025-09-30 10:54:07 +02:00
adee419f1c v3.0.1 v3.0.1 2025-09-20 17:14:07 +01:00
33fb1849eb (v3.0.0.9036) Prepare for v3.0.1 2025-09-19 12:23:59 +01:00
13f2a864da (v3.0.0.9035) fix mo_pathogenicity unit test following MycoBank bugfix 2025-09-18 14:22:52 +01:00
10ba36821e (v3.0.0.9034) fix MycoBank synonyms 2025-09-18 13:58:34 +01:00
5796e8f3a4 (v3.0.0.9033) rename workflow 2025-09-15 09:10:54 +02:00
b11866af57 (v3.0.0.9032) add GitHub Action for dev version of packages 2025-09-13 14:02:59 +02:00
e8c99f2775 (v3.0.0.9031) fix for ggplot2 2025-09-12 16:52:59 +02:00
5b99888151 (v3.0.0.9030) fix NEWS 2025-09-11 14:41:28 +02:00
c7b2acbeb6 (v3.0.0.9029) fix for vignette and envir data 2025-09-10 16:19:30 +02:00
1922fb5ff2 (v3.0.0.9028) fix as.ab() warning 2025-09-10 15:06:51 +02:00
4d7c4ca52c (v3.0.0.9027) skimr update and as.ab warning - fixes #234, fixes #232 2025-09-10 13:32:52 +02:00
d5a568318b (v3.0.0.9026) fix tidymodels doc 2025-09-04 15:03:28 +02:00
c1c49fa463 (v3.0.0.9025) fix todo tracker 2025-09-04 14:40:24 +02:00
d2ced1db61 (v3.0.0.9024) fix todo tracker 2025-09-04 14:28:01 +02:00
3d40b20c10 (v3.0.0.9023) update todo tracker 2025-09-04 14:04:22 +02:00
3ba1b8a10a (v3.0.0.9022) postpone new features - we like a clearly focussed bugfix release first 2025-09-03 15:39:44 +02:00
0744c6feee (v3.0.0.9021) checkouts 2025-09-03 12:12:05 +02:00
eca638529c new umcg logo and old CHECKOUT update 2025-09-03 11:49:10 +02:00