Skip to content

Reproduce clinical breakpoints from latest WHONET/AMRIE data#266

Open
msberends wants to merge 1 commit intomainfrom
claude/clinical-breakpoints-reproduction-SGtaG
Open

Reproduce clinical breakpoints from latest WHONET/AMRIE data#266
msberends wants to merge 1 commit intomainfrom
claude/clinical-breakpoints-reproduction-SGtaG

Conversation

@msberends
Copy link
Copy Markdown
Owner

Summary

  • Ran both reproduction scripts against the latest WHONET/AMRIE source data, which now includes EUCAST 2026 and CLSI 2025 breakpoints
  • Updated data/clinical_breakpoints.rda, data/microorganisms.codes.rda, data/microorganisms.groups.rda, and data-raw/organisms.rds
  • Fixed a bug in reproduction_of_microorganisms.groups.R: replaced base ifelse() with dplyr::if_else() to preserve the <mo> S3 class — base ifelse() strips class attributes, causing bind_rows() to fail with strict vctrs type checking in dplyr ≥ 1.1.0
  • Added data-raw/_run_reproduction.R: a non-interactive wrapper that overrides View(), sets the UTF-8 locale, and sources both scripts in the correct order (groups script first, then breakpoints)

Flaws encountered and fixed

Issue Root cause Fix
bind_rows() type error in microorganisms.groups script base::ifelse() strips <mo> class → produces character; later bind_rows() with <mo> tibbles fails under vctrs strict typing Changed to dplyr::if_else() without as.character() wrapper
gsub() UTF-8 pattern error in breakpoints script System locale was C/POSIX, rejecting multi-byte Unicode in gsub() patterns Set locale to C.utf8 in the wrapper before sourcing scripts
View() calls abort non-interactive session View() not meaningful outside RStudio/GUI Overridden with a print-summary fallback in the wrapper

Test plan

  • Verify clinical_breakpoints dimensions increased (now includes EUCAST 2026)
  • Spot-check: clinical_breakpoints |> filter(guideline == "EUCAST 2026", ab == "AMC", mo == "B_[ORD]_ENTRBCTR", method == "MIC")
  • Confirm microorganisms.codes and microorganisms.groups load without errors after devtools::load_all()

https://claude.ai/code/session_01S5vMqfsiJb59RN2Gyz1tDY

- Ran reproduction_of_microorganisms.groups.R and reproduction_of_clinical_breakpoints.R
  against the latest WHONET/AMRIE source (includes EUCAST 2026, CLSI 2025)
- Updated data/clinical_breakpoints.rda, microorganisms.codes.rda, microorganisms.groups.rda,
  and data-raw/organisms.rds
- Fixed reproduction_of_microorganisms.groups.R: replaced base ifelse() with dplyr::if_else()
  to preserve the <mo> S3 class; base ifelse() strips class attributes, causing
  bind_rows() to fail with strict vctrs type checking in dplyr >= 1.1.0
- Added data-raw/_run_reproduction.R: non-interactive wrapper that overrides View(),
  sets UTF-8 locale, and sources both scripts in the correct order

https://claude.ai/code/session_01S5vMqfsiJb59RN2Gyz1tDY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants