Skip to content

Commit

Permalink
Merge pull request #112 from darwin-eu/mc_dev
Browse files Browse the repository at this point in the history
remove arrow dependency
  • Loading branch information
edward-burn authored Jan 16, 2024
2 parents 6ccc5f0 + 0b1009e commit 14994c9
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 77 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CodelistGenerator
Title: Generate Code Lists for the OMOP Common Data Model
Version: 2.1.1
Version: 2.1.2
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
Expand Down Expand Up @@ -30,7 +30,6 @@ Imports:
PatientProfiles (>= 0.3.0),
RJSONIO
Suggests:
arrow (>= 9.0.0),
covr,
dbplyr (>= 2.2.1),
knitr,
Expand All @@ -49,3 +48,4 @@ Config/testthat/edition: 3
VignetteBuilder: knitr
URL: https://darwin-eu.github.io/CodelistGenerator/
Language: en-US
Config/testthat/parallel: true
70 changes: 35 additions & 35 deletions R/mockVocabRef.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,39 +319,39 @@ mockVocabRef <- function(backend = "database") {
})

cdm <- CDMConnector::cdm_from_con(db)
if (backend == "database") {
return(cdm)
}

if (backend %in% c("arrow", "data_frame")) {
dOut <- tempfile()
dir.create(dOut)
CDMConnector::stow(cdm, dOut)

if (backend == "arrow") {
cdmArrow <- CDMConnector::cdm_from_files(
path = dOut,
as_data_frame = FALSE, cdm_name = "mock_vocab"
)
DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
return(cdmArrow)
}

if (backend == "data_frame") {
if(utils::packageVersion("CDMConnector")<"1.1.0"){
cdmDF <- CDMConnector::cdm_from_files(
path = dOut,
as_data_frame = TRUE
)
} else {
cdmDF <- CDMConnector::cdm_from_files(
path = dOut, cdm_name = "mock",
as_data_frame = TRUE
)
}

DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
return(cdmDF)
}
}
return(cdm)
# if (backend == "database") {
# return(cdm)
# }
#
# if (backend %in% c("arrow", "data_frame")) {
# dOut <- tempfile()
# dir.create(dOut)
# CDMConnector::stow(cdm = cdm, path = dOut, format = "csv")
#
# if (backend == "arrow") {
# cdmArrow <- CDMConnector::cdm_from_files(
# path = dOut,
# as_data_frame = FALSE, cdm_name = "mock_vocab"
# )
# DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
# return(cdmArrow)
# }
#
# if (backend == "data_frame") {
# if(utils::packageVersion("CDMConnector")<"1.1.0"){
# cdmDF <- CDMConnector::cdm_from_files(
# path = dOut,
# as_data_frame = TRUE
# )
# } else {
# cdmDF <- CDMConnector::cdm_from_files(
# path = dOut, cdm_name = "mock",
# as_data_frame = TRUE
# )
# }
# DBI::dbDisconnect(attr(cdm, "dbcon"), shutdown = TRUE)
# return(cdmDF)
# }
# }
}
72 changes: 33 additions & 39 deletions extras/precomputeVignetteData.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ devtools::load_all()

# example with postgres database connection details
db <- dbConnect(RPostgres::Postgres(),
dbname = "cdm_iqvia_pharmetrics_plus_202203",
dbname = "cdm_gold_202301",
port = Sys.getenv("DB_PORT") ,
host = "163.1.65.51",
user = Sys.getenv("DB_USER"),
Expand Down Expand Up @@ -46,9 +46,9 @@ rm(cdm)
# intro vignette ----
vocabVersion <- getVocabVersion(cdm = cdm_arrow)

saveRDS(
save(
vocabVersion,
here("vignettes", "introVocab.RData")
file = here("vignettes", "introVocab.RData")
)


Expand All @@ -70,12 +70,12 @@ saveRDS(
dementiaCodes1 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "dementia",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = FALSE,
#searchViaSynonyms = FALSE,
#fuzzyMatch = FALSE,
exclude = NULL,
includeDescendants = TRUE,
includeAncestor = FALSE,
verbose=TRUE
#verbose=TRUE
)
saveRDS(
dementiaCodes1,
Expand Down Expand Up @@ -112,15 +112,15 @@ saveRDS(
oaCodes1 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = FALSE,
#searchViaSynonyms = FALSE,
#fuzzyMatch = FALSE,
exclude = c(
"post-infection",
"post-traumatic"
),
includeDescendants = FALSE,
includeAncestor = FALSE,
verbose = TRUE
#verbose = TRUE
)
saveRDS(
oaCodes1,
Expand All @@ -131,8 +131,8 @@ saveRDS(
oaCodes2 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = FALSE,
#searchViaSynonyms = FALSE,
#fuzzyMatch = FALSE,
exclude = c(
"post-infection",
"post-traumatic"
Expand All @@ -149,9 +149,9 @@ saveRDS(
oaCodes3 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = c("Condition", "Observation"),
searchViaSynonyms = FALSE,
fuzzyMatch = FALSE,
maxDistanceCost = 0.1,
#searchViaSynonyms = FALSE,
#fuzzyMatch = FALSE,
#maxDistanceCost = 0.1,
exclude = c(
"post-infection",
"post-traumatic"
Expand All @@ -169,9 +169,9 @@ oaCodes4 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchInSynonyms = TRUE,
searchViaSynonyms = TRUE,
fuzzyMatch = FALSE,
maxDistanceCost = 0.1,
#searchViaSynonyms = TRUE,
#fuzzyMatch = FALSE,
#maxDistanceCost = 0.1,
exclude = c(
"post-infection",
"post-traumatic"
Expand Down Expand Up @@ -201,15 +201,13 @@ saveRDS(
here("vignettes", "optionsData04.RData")
)



# fuzzy search
oaCodes6 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = TRUE,
maxDistanceCost = 0.1,
#searchViaSynonyms = FALSE,
#fuzzyMatch = TRUE,
#maxDistanceCost = 0.1,
exclude = c(
"post-infection",
"post-traumatic"
Expand All @@ -226,9 +224,9 @@ saveRDS(
oaCodes7 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = TRUE,
maxDistanceCost = 0.2,
#searchViaSynonyms = FALSE,
#fuzzyMatch = TRUE,
#maxDistanceCost = 0.2,
exclude = c(
"post-infection",
"post-traumatic"
Expand All @@ -245,9 +243,9 @@ saveRDS(
oaCodes8 <- getCandidateCodes(cdm = cdm_arrow,
keywords = "osteoarthritis",
domains = "Condition",
searchViaSynonyms = FALSE,
fuzzyMatch = FALSE,
maxDistanceCost = 0.2,
#searchViaSynonyms = FALSE,
#fuzzyMatch = FALSE,
#maxDistanceCost = 0.2,
exclude = c(
"post-infection",
"post-traumatic"
Expand All @@ -265,8 +263,7 @@ ac_codes_1 <- getCandidateCodes(cdm = cdm_arrow,
keywords="acetaminophen",
domains="drug",
standardConcept="standard",
includeDescendants = TRUE,
verbose = TRUE)
includeDescendants = TRUE)
saveRDS(
ac_codes_1,
here("vignettes", "medData01.RData")
Expand All @@ -277,8 +274,7 @@ ac_codes_2a <- getCandidateCodes(cdm = cdm_arrow,
"acetaminophen intravenous"),
domains="drug",
standardConcept="standard",
includeDescendants = TRUE,
verbose = TRUE)
includeDescendants = TRUE)
saveRDS(
ac_codes_2a,
here("vignettes", "medData02a.RData")
Expand All @@ -287,10 +283,9 @@ saveRDS(
ac_codes_2b <- getCandidateCodes(cdm = cdm_arrow,
keywords="acetaminophen",
domains="drug",
doseForm = c("injection", "intravenous"),
#doseForm = c("injection", "intravenous"),
standardConcept="standard",
includeDescendants = TRUE,
verbose = TRUE )
includeDescendants = TRUE)
saveRDS(
ac_codes_2b,
here("vignettes", "medData02b.RData")
Expand All @@ -305,11 +300,10 @@ c <- compareCodelists(ac_codes_2, ac_codes_2a)
ac_codes_3 <- getCandidateCodes(cdm = cdm_arrow,
keywords="acetaminophen",
domains="drug",
conceptClassId = c("Quant Clinical Drug"),
doseForm = c("injection", "intravenous"),
#conceptClassId = c("Quant Clinical Drug"),
#doseForm = c("injection", "intravenous"),
standardConcept="standard",
includeDescendants = TRUE,
verbose = TRUE)
includeDescendants = TRUE)
saveRDS(
ac_codes_3,
here("vignettes", "medData03.RData")
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files

library(testthat)
library(CodelistGenerator)

Expand Down
2 changes: 1 addition & 1 deletion vignettes/a01_Introduction_to_CodelistGenerator.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ getVocabVersion(cdm = cdm)
```

```{r, message=FALSE, warning=FALSE,echo=FALSE}
vocabVersion <- readRDS(here("vignettes", "introVocab.RData"))
vocabVersion <- load(here("vignettes", "introVocab.RData"))
vocabVersion
```

Expand Down
Binary file modified vignettes/introData01.RData
Binary file not shown.
Binary file modified vignettes/introData02.RData
Binary file not shown.
Binary file modified vignettes/introData03.RData
Binary file not shown.
Binary file modified vignettes/introData04.RData
Binary file not shown.
Binary file modified vignettes/introData05.RData
Binary file not shown.
Binary file modified vignettes/introVocab.RData
Binary file not shown.
Binary file modified vignettes/medData01.RData
Binary file not shown.
Binary file modified vignettes/medData02a.RData
Binary file not shown.
Binary file modified vignettes/medData02b.RData
Binary file not shown.
Binary file modified vignettes/medData03.RData
Binary file not shown.
Binary file modified vignettes/medDataConceptClass.RData
Binary file not shown.
Binary file modified vignettes/medDataDoseForms.RData
Binary file not shown.
Binary file modified vignettes/optionsData01.RData
Binary file not shown.
Binary file modified vignettes/optionsData02.RData
Binary file not shown.
Binary file modified vignettes/optionsData03.RData
Binary file not shown.
Binary file modified vignettes/optionsData04.RData
Binary file not shown.
Binary file modified vignettes/optionsData05.RData
Binary file not shown.
Binary file modified vignettes/optionsData06.RData
Binary file not shown.
Binary file modified vignettes/optionsData07.RData
Binary file not shown.

0 comments on commit 14994c9

Please sign in to comment.