-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.Rmd
138 lines (116 loc) · 4.51 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
message=FALSE,
warning=FALSE
)
```
# CodelistGenerator <img src="man/figures/logo.png" align="right" height="200"/>
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/CodelistGenerator)](https://CRAN.R-project.org/package=CodelistGenerator)
[![codecov.io](https://codecov.io/github/darwin-eu/CodelistGenerator/coverage.svg?branch=main)](https://app.codecov.io/github/darwin-eu/CodelistGenerator?branch=main)
[![R-CMD-check](https://github.com/darwin-eu/CodelistGenerator/workflows/R-CMD-check/badge.svg)](https://github.com/darwin-eu/CodelistGenerator/actions)
[![Lifecycle:Stable](https://img.shields.io/badge/Lifecycle-Stable-97ca00)](https://lifecycle.r-lib.org/articles/stages.html)
[![R-CMD-check](https://github.com/darwin-eu/CodelistGenerator/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/darwin-eu/CodelistGenerator/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
## Installation
You can install CodelistGenerator from CRAN
``` r
install.packages("CodelistGenerator")
```
Or you can also install the development version of CodelistGenerator
``` r
install.packages("remotes")
remotes::install_github("darwin-eu/CodelistGenerator")
```
## Example usage
```{r}
library(dplyr)
library(CDMConnector)
library(CodelistGenerator)
```
For this example we'll use the Eunomia dataset (which only contains a subset of the OMOP CDM vocabularies)
```{r}
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir())
cdm <- cdm_from_con(db, cdm_schema = "main", write_schema = c(prefix = "cg_", schema = "main"))
```
## Exploring the OMOP CDM Vocabulary tables
OMOP CDM vocabularies are frequently updated, and we can identify the version of the vocabulary of our Eunomia data
```{r}
getVocabVersion(cdm = cdm)
```
CodelistGenerator provides various other functions to explore the vocabulary tables. For example, we can see the the different concept classes of standard concepts used for drugs
```{r}
getConceptClassId(cdm,
standardConcept = "Standard",
domain = "Drug")
```
## Vocabulary based codelists using CodelistGenerator
CodelistGenerator provides functions to extract code lists based on vocabulary hierarchies. One example is `getDrugIngredientCodes, which we can use, for example, to get all the concept IDs used to represent aspirin.
```{r}
getDrugIngredientCodes(cdm = cdm, name = "aspirin")
```
If we also want the details of these concept IDs we can get these like so.
```{r}
getDrugIngredientCodes(cdm = cdm, name = "aspirin", withConceptDetails = TRUE)
```
And if we want codelists for all drug ingredients we can simply omit the name argument and all ingredients will be returned.
```{r}
ing <- getDrugIngredientCodes(cdm = cdm)
ing$aspirin
ing$diclofenac
ing$celecoxib
```
## Systematic search using CodelistGenerator
CodelistGenerator can also support systematic searches of the vocabulary tables to support codelist development. A little like the process for a systematic review, the idea is that for a specified search strategy, CodelistGenerator will identify a set of concepts that may be relevant, with these then being screened to remove any irrelevant codes by clinical experts.
We can do a simple search for asthma
```{r}
asthma_codes1 <- getCandidateCodes(
cdm = cdm,
keywords = "asthma",
domains = "Condition"
)
asthma_codes1 %>%
glimpse()
```
But perhaps we want to exclude certain concepts as part of the search strategy, in this case we can add these like so
```{r}
asthma_codes2 <- getCandidateCodes(
cdm = cdm,
keywords = "asthma",
exclude = "childhood",
domains = "Condition"
)
asthma_codes2 %>%
glimpse()
```
We can compare these two code lists like so
```{r}
compareCodelists(asthma_codes1, asthma_codes2)
```
We can then also see non-standard codes these are mapped from, for example here we can see the non-standard ICD10 code that maps to a standard snowmed code for gastrointestinal hemorrhage returned by our search
```{r}
Gastrointestinal_hemorrhage <- getCandidateCodes(
cdm = cdm,
keywords = "Gastrointestinal hemorrhage",
domains = "Condition"
)
Gastrointestinal_hemorrhage %>%
glimpse()
```
## Summarising code use
```{r}
summariseCodeUse(list("asthma" = asthma_codes1$concept_id),
cdm = cdm) %>%
glimpse()
```
```{r, echo=FALSE}
DBI::dbDisconnect(db)
```