CodelistGenerator options: examples with a with mock vocabulary"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Mock vocabulary database

library(DBI)
library(dplyr)
library(CodelistGenerator)
library(CDMConnector)

Let´s say we have a mock vocabulary database with these hypothetical concepts and relationships.

knitr::include_graphics("mock_db_fig1.png")
cdm <- mockVocabRef(backend = "data_frame")

Search for exact keyword match

knitr::include_graphics("mock_db_fig2.png")

To find "Musculoskeletal disorder" we can search for that like so

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "Musculoskeletal disorder",
  domains = "Condition",
  includeDescendants = FALSE,
)

codes %>% 
  glimpse()

Note, we would also identify it based on a partial match

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "Musculoskeletal",
  domains = "Condition",
  includeDescendants = FALSE
)

codes %>% 
  glimpse()

Add descendants

knitr::include_graphics("mock_db_fig7.png")

To include descendants of an identified code, we can set includeDescendants to TRUE

getCandidateCodes(
  cdm = cdm,
  keywords = "Musculoskeletal disorder",
  domains = "Condition",
  includeDescendants = TRUE
) %>% 
  glimpse()

Multiple search terms

We can also search for multiple keywords at the same time, and would have picked these all up with the following search

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = c(
    "Musculoskeletal disorder",
    "arthritis",
    "arthrosis"
  ),
  domains = "Condition",
  includeDescendants = FALSE
)

codes %>% 
  glimpse()

Add ancestor

knitr::include_graphics("mock_db_fig5.png")

To include the ancestors one level above the identified concepts we can set includeAncestor to TRUE

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "Osteoarthritis of knee",
  includeAncestor = TRUE,
  domains = "Condition"
)

codes %>% 
  glimpse()

Searches with multiple words

knitr::include_graphics("mock_db_fig4.png")

We can also find concepts with multiple words even if they are in a different order. For example, a search for "Knee osteoarthritis" will pick up "Osteoarthritis of knee".

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "Knee osteoarthritis",
  domains = "Condition",
  includeDescendants = TRUE
)

codes %>% 
  glimpse()

With exclusions

knitr::include_graphics("mock_db_fig5.png")

We can also exclude specific terms

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "arthritis",
  exclude = "Hip osteoarthritis",
  domains = "Condition"
)

codes %>% 
  glimpse()

Search using synonyms

knitr::include_graphics("mock_db_fig6.png")

We can also pick up codes based on their synonyms. In this case "Arthritis" has a synonym of "Osteoarthrosis" and so a search of both the primary name of a concept and any of its associated synonyms would pick up this synonym and it would be included.

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = "osteoarthrosis",
  domains = "Condition",
  searchInSynonyms = TRUE
)

codes %>% 
  glimpse()

Search via non-standard

Or we could have also picked up "Osteoarthrosis" by searching via non-standard.

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = c("arthritis", "arthropathy"),
  domains = "Condition",
  searchNonStandard = TRUE
)

codes %>% 
  glimpse()

Search for both standard and non-standard concepts

knitr::include_graphics("mock_db_fig8.png")

We can also include non-standard codes in our results like so

codes <- getCandidateCodes(
  cdm = cdm,
  keywords = c(
    "Musculoskeletal disorder",
    "arthritis",
    "arthropathy",
    "arthrosis"
  ),
  domains = "Condition",
  standardConcept = c("Standard", "Non-standard")
)

codes %>% 
  glimpse()


Try the CodelistGenerator package in your browser

Any scripts or data that you put into this service are public.

CodelistGenerator documentation built on Oct. 17, 2024, 5:09 p.m.