Commit Graph
83 Commits
Author SHA1 Message Date
Matthijs BerendsandClaude 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
Matthijs BerendsandClaude 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
Matthijs BerendsandClaude 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
Matthijs Berends 0138e33ce9 Update 1-bug-report.yml 2025-06-22 20:47:31 +02:00
Matthijs Berends 1013ef6086 Update _pkgdown.yml 2025-06-13 17:05:51 +02:00
Matthijs Berends 04aec39371 Update welcome_to_AMR.Rmd (#205) 2025-04-29 17:10:43 +02:00
Matthijs Berends b85890449d Update config.yml 2025-02-28 12:00:25 +01:00
Matthijs Berends 08d09d6e71 Update config.yml 2025-02-28 11:58:18 +01:00
Matthijs Berends 649dd5b35a Update config.yml 2025-02-28 11:54:36 +01:00
Matthijs Berends bb416cb254 Update 2-feature-request.yml 2025-02-28 11:52:28 +01:00
Matthijs Berends 1c551797cc Update 1-bug-report.yml 2025-02-28 11:50:26 +01:00
Matthijs Berends 21b958900c Update and rename 2.feature-request.yml to 2-feature-request.yml 2025-02-28 11:49:33 +01:00
Matthijs Berends 83bef55b1e Create 2.feature-request.yml 2025-02-28 11:48:43 +01:00
Matthijs Berends 9825109f40 Update 1-bug-report.yml 2025-02-28 11:42:09 +01:00
Matthijs Berends 8b4107d951 Update 1-bug-report.yml 2025-02-28 11:38:37 +01:00
Matthijs Berends bed29d6aff Update 1-bug-report.yml 2025-02-28 11:34:27 +01:00
Matthijs Berends 8582321f53 Update 1-bug-report.yml 2025-02-28 11:32:37 +01:00
Matthijs Berends cf7a0f99bf Update 1-bug-report.yml 2025-02-28 11:31:40 +01:00
Matthijs Berends 335a086447 Create config.yml 2025-02-28 11:30:34 +01:00
Matthijs Berends c9a610eaca Delete .github/ISSUE_TEMPLATE/feature_request.md 2025-02-28 11:27:17 +01:00
Matthijs Berends c93e0038a9 Delete .github/ISSUE_TEMPLATE/bug_report.md 2025-02-28 11:27:06 +01:00
Matthijs Berends a37d6d8276 Create 1-bug-report.yml 2025-02-28 11:26:18 +01:00
Matthijs Berends 446aa44c0b Update issue templates 2025-02-28 08:21:10 +01:00
Matthijs Berends 68efddab3d unit tests 2025-02-26 22:26:42 +01:00
Matthijs Berends 5ff9210c12 Update plot.Rd 2025-02-11 17:23:34 +01:00
Matthijs Berends 3dd3b6292a Update _pkgdown.yml 2024-10-04 16:49:55 +02:00
Matthijs Berends 88740b6f11 Update extra.js 2024-09-30 23:15:28 +02:00
Matthijs Berends 42a23e89a8 Update DESCRIPTION 2024-04-08 00:52:25 +02:00
Matthijs Berends 8b43fed94d Update _pkgdown.yml 2024-02-25 14:40:19 +01:00
Dr. Matthijs Berends f065945d7b Update clinical breakpoints and fix some as.mo() bugs (#117)
* Updates clinical breakpoints EUCAST/CLSI 2023, fixes #102, fixes #112, fixes #113, fixes #114, fixes #115
* docs
* implement ecoffs
* unit tests
2023-06-22 15:10:59 +02:00
Dr. Matthijs Berends 5f9769a4f7 Add oxygen tolerance 2023-05-12 10:37:07 +02:00
Dr. Matthijs Berends af139a3c82 unit test fix for old R versions 2023-01-21 23:53:31 +01:00
Dr. Matthijs Berends 98e62c9af2 Replace RSI with SIR 2023-01-21 23:47:20 +01:00
Dr. Matthijs Berends 6017f81e74 Update README.md 2022-11-29 19:38:17 +01:00
Dr. Matthijs Berends 496c08d851 Implement extensive support for antiviral agents support (#77) 2022-11-13 08:46:10 +01:00
Dr. Matthijs Berends d2edcf51ad Update website.yaml 2022-11-12 12:10:33 +01:00
Dr. Matthijs Berends 3102beb241 Update check-release.yaml 2022-10-21 09:59:09 +02:00
Dr. Matthijs Berends 74bcc41558 Move older test versions to Windows 2022-10-20 19:39:25 +02:00
Dr. Matthijs Berends fed3b6440f Unit test fix 2022-10-19 08:14:38 +02:00
Dr. Matthijs Berends 85ed7ea5f0 more robust install check 2022-10-14 15:45:20 +02:00
Dr. Matthijs Berends 0d8b098220 Vignette fix 2022-10-05 12:26:50 +02:00
Dr. Matthijs Berends cd2acc4a29 New mo algorithm, prepare for 2.0 2022-10-05 09:12:22 +02:00
Dr. Matthijs Berends a3b97a10a5 Update website 2022-08-30 22:17:14 +02:00
Dr. Matthijs Berends e975a3043c New tibbles, cleanup
New tibbles, cleanup
2022-08-28 21:52:45 +02:00
Dr. Matthijs Berends 0d67db4f32 Update check.yaml 2022-08-28 16:03:23 +02:00
Dr. Matthijs Berends 95f9563f58 Update check.yaml 2022-08-28 13:42:16 +02:00
Dr. Matthijs Berends 1a9bac8c64 Update check.yaml 2022-08-28 13:32:26 +02:00
Dr. Matthijs Berends 40d9658e06 Update check.yaml 2022-08-28 11:22:40 +02:00
dr. M.S. (Matthijs) Berends 7a0ecd6c3b No vignettes on old R unit tests 2021-10-03 23:49:46 +02:00
MS Berends 43ba16f8ed small change in mutate example 2018-08-22 15:20:00 +02:00
MS Berends e47e77febc Delete .zenodo.json 2018-08-20 21:05:25 +02:00
MS Berends eb4ecd9108 Update .zenodo.json 2018-08-20 20:50:56 +02:00
MS Berends e4ca66e3ee support zenodo 2018-07-04 23:42:43 +02:00
MS Berends 4bdcde9a00 allow clipboard on travis 2018-06-27 15:56:59 +02:00
MS Berends dab085d7ad Update README.md 2018-06-27 10:44:24 +02:00
MS Berends 7a6d5fb6b7 rsi/mic fix 2018-05-31 09:02:49 +02:00
MS Berends 0d80647d41 fix SI and IR 2018-05-16 11:19:45 +02:00
MS Berends eecd7a11e8 Set theme jekyll-theme-cayman 2018-05-09 11:49:50 +02:00
MS Berends c690db145e Set theme jekyll-theme-slate 2018-05-09 11:48:10 +02:00
MS Berends abcb4accbd Update .travis.yml 2018-03-29 15:17:48 +02:00
MS Berends b7f29aa748 Update first_isolates.R 2018-03-29 15:15:31 +02:00
MS Berends 2647dacc0a add clipbaord support for Linux and macOS 2018-03-29 15:07:36 +02:00
MS Berends f1dbed6fcc Update clipboard.R 2018-03-29 14:56:40 +02:00
MS Berends e2a5202b69 Update test-clipboard.R 2018-03-29 14:47:52 +02:00
MS Berends 258e080756 Update test-clipboard.R 2018-03-29 14:26:26 +02:00
MS Berends 136272cb71 Update clipboard.R 2018-03-29 14:16:42 +02:00
MS Berends 9f943708cc Update .travis.yml 2018-03-29 14:07:54 +02:00
MS Berends fd04df5f9d Update clipboard.R 2018-03-29 13:23:02 +02:00
MS Berends dbec56c68a Update .travis.yml 2018-03-29 13:16:08 +02:00
MS Berends 339b445a30 Update test-clipboard.R 2018-03-29 13:12:49 +02:00
MS Berends 2f4823f7a7 Update clipboard.R 2018-03-29 13:10:55 +02:00
MS Berends ff90188f41 Update .travis.yml 2018-03-29 12:56:03 +02:00
MS Berends c26839b08e Test on Linux and Mac 2018-03-23 14:59:50 +01:00
MS Berends 9637b43357 Remove Windows only function 2018-03-23 14:59:02 +01:00
MS Berends 39eb307968 Remove Windows only function 2018-03-23 14:58:46 +01:00
MS Berends 1b3daebc84 Remove Windows only function 2018-03-23 14:52:56 +01:00
MS Berends 2db25b3b38 Use R 3.2 to make covr work 2018-03-19 12:49:22 +01:00
MS Berends aae393f2a9 Update .Rbuildignore 2018-03-11 21:20:28 +01:00
MS Berends 692116b4dc Create .travis.yml 2018-03-11 21:00:11 +01:00
MS Berends 942c41ae9c Update README.md 2018-02-21 12:19:42 +01:00
MS Berends 3cccf9df3f Update README.md 2018-02-21 12:15:04 +01:00
MS Berends 57d0314780 Update README.md 2018-02-21 12:14:17 +01:00
MS Berends 86c9f2913d Update README.md 2018-02-21 12:11:07 +01:00