Add join_smq() to expand SMQ lists into per-LLT dictionary rows#15
Open
billdenney wants to merge 1 commit into
Open
Add join_smq() to expand SMQ lists into per-LLT dictionary rows#15billdenney wants to merge 1 commit into
billdenney wants to merge 1 commit into
Conversation
Fixes #14. Adds an exported join_smq() that turns the SMQ definitions parsed by read_meddra() into the flat per-LLT term list needed to merge against coded adverse events and to build SMQ*/CQ* variables. join_smq() returns one row per (SMQ x LLT x SOC path) with the full SOC -> HLGT -> HLT -> PT -> LLT hierarchy plus SMQ identity and member attributes (term_scope, term_category, term_weight, term_status). It: * recursively resolves sub-SMQ references (term_level 0, cycle-safe); * expands PT members (term_level 4) down to all of the PT's LLTs, with scope inherited; and * attaches LLT members (term_level 5) directly. It reuses join_meddra() for the hierarchy and uses inner_join so orphan terms with no hierarchy match are dropped rather than emitting all-NA rows. Column names match join_meddra() (snake_case); the vignette adds a recipe for renaming to the SAS/ADaM short names. Also: regenerated NAMESPACE + man/join_smq.Rd, extended the vignette SMQ section, updated NEWS.md, CLAUDE.md, and inst/WORDLIST. Tests cover PT, LLT, sub-SMQ, cycle-safety, missing-file, and empty-input paths (100% coverage of R/join_smq.R); R CMD check passes with no new NOTEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14. Adds an exported join_smq() that turns the SMQ definitions parsed by read_meddra() into the flat per-LLT term list needed to merge against coded adverse events and to build SMQ*/CQ* variables.
Summary
Fixes #14. Adds an exported
join_smq()that turns the SMQ definitionsparsed by
read_meddra()(smq_list.asc+smq_content.asc) into the flatper-LLT term list needed to merge against coded adverse events and to build
SMQ*/CQ* variables.
join_smq(data)returns one row per (SMQ × LLT × SOC path) with the fullSOC → HLGT → HLT → PT → LLThierarchy plus SMQ identity and memberattributes (
term_scope,term_category,term_weight,term_status).How it works
term_level == 0rows reference a child SMQ and areflattened recursively via a cycle-safe worklist.
term_level == 4PT members expand to all LLTs ofthe PT, with scope/category inherited.
term_level == 5attach to the single LLT.It reuses
join_meddra()for the hierarchy and usesinner_join, so orphanterms with no hierarchy match are dropped rather than emitting all-NA rows
(the one intentional departure from
join_meddra()'s tolerantleft_joins).Output columns use the same snake_case names as
join_meddra(). Per theagreed design, the vignette documents a recipe to rename to the SAS/ADaM short
names from the issue (
soccd,lltcd,ptcd, …).Changes
R/join_smq.R(join_smq()+ internalflatten_smq_content()/flatten_smq_one()),tests/testthat/test-join_smq.R,man/join_smq.Rd.NAMESPACE(export),NEWS.md,vignettes/meddra-read.Rmd(new "Expanding an SMQ into dictionary terms" section + rename table),
inst/WORDLIST,CLAUDE.md.Testing
devtools::test()— all pass (7 new tests: PT, LLT, sub-SMQ, cycle-safety,missing-file, empty-content, empty-list paths).
R/join_smq.R(covr).devtools::check()— 0 errors, 0 warnings; only environmental NOTEs(
.gitpresent; clock check).join_smq() returns one row per (SMQ x LLT x SOC path) with the full SOC -> HLGT -> HLT -> PT -> LLT hierarchy plus SMQ identity and member attributes (term_scope, term_category, term_weight, term_status). It:
It reuses join_meddra() for the hierarchy and uses inner_join so orphan terms with no hierarchy match are dropped rather than emitting all-NA rows. Column names match join_meddra() (snake_case); the vignette adds a recipe for renaming to the SAS/ADaM short names.
Also: regenerated NAMESPACE + man/join_smq.Rd, extended the vignette SMQ section, updated NEWS.md, CLAUDE.md, and inst/WORDLIST. Tests cover PT, LLT, sub-SMQ, cycle-safety, missing-file, and empty-input paths (100% coverage of R/join_smq.R); R CMD check passes with no new NOTEs.