Skip to content

Commit

Permalink
checks?
Browse files Browse the repository at this point in the history
  • Loading branch information
nmercadeb committed Sep 10, 2024
1 parent 12c5ccc commit 5f723ec
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
Binary file modified R/sysdata.rda
Binary file not shown.
2 changes: 0 additions & 2 deletions data-raw/domainsData.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ domainsData <- dplyr::tribble(
"visit", "visit_occurrence", "visit_concept_id", "visit_source_concept_id", "visit_start_date", "visit_end_date",
"device", "device_exposure", "device_concept_id", "device_source_concept_id", "device_exposure_start_date", "device_exposure_end_date"
)

usethis::use_data(domainsData, internal = TRUE, overwrite = TRUE)
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ mergeData <- function(data, patterns) {
}

resultPatterns <- c("time", "comparison", "details", "omop", "index_counts", "sql_indexes")
benchmarkData <- readData(here("extras", "data")) %>% mergeData(resultPatterns)
usethis::use_data(benchmarkData, internal = TRUE, overwrite = TRUE)
benchmarkData <- readData(here::here("data-raw", "data")) %>% mergeData(resultPatterns)
3 changes: 3 additions & 0 deletions data-raw/internalData.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source(here::here("data-raw", "domainsData.R"))
source(here::here("data-raw", "getBenchmarkResults.R"))
usethis::use_data(domainsData, benchmarkData, internal = TRUE, overwrite = TRUE)
Binary file removed extras/benchmark.RData
Binary file not shown.
25 changes: 10 additions & 15 deletions vignettes/a11_benchmark.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ library(dplyr)
library(tidyr)
library(gt)
library(scales)
library(CohortConstructor)
# Functions
niceNum <- function(x, dec = 0) {
Expand Down Expand Up @@ -61,12 +62,6 @@ niceOverlapLabels <- function(labels) {
)
)
}
# Results
createRData <- FALSE
if (createRData) {
source(here::here("extras", "getBenchmarkResults.R"))
}
```

# Introduction
Expand All @@ -89,7 +84,7 @@ Current results were obtained from a 100,000-person sample of the CPRD GOLD data

The table below show how many records are in OMOP tables used in the benchmark script for each participating database.
```{r}
benchmarkData$omop |>
CohortConstructor:::benchmarkData$omop |>
filter(table_name != "death") |>
select("cdm_name", "OMOP table" = "table_name", "number_records") |>
mutate(
Expand Down Expand Up @@ -122,7 +117,7 @@ The COVID-19 cohort was used to evaluate the performance of common cohort strati
The following table displays the number of records and subjects for each cohort across the participating databases:

```{r}
benchmarkData$details |>
CohortConstructor:::benchmarkData$details |>
filterSettings(result_type == "cohort_count") |>
tidy(addSettings = FALSE) |>
select(-variable_level, - result_id) |>
Expand Down Expand Up @@ -166,7 +161,7 @@ benchmarkData$details |>
We also computed the overlap between patients in CIRCE and CohortConstructor cohorts, with results shown in the plot below:

```{r, fig.width=10, fig.height=7}
overlap <- benchmarkData$comparison |>
overlap <- CohortConstructor:::benchmarkData$comparison |>
filterSettings(result_type == "cohort_overlap")
overlap |>
Expand Down Expand Up @@ -207,7 +202,7 @@ The following plot shows the times taken to create each cohort using CIRCE and C
## TABLE with same results as the plot below.
# header_prefix <- "[header]Time by database (minutes)\n[header_level]"
# benchmarkData$time |>
# CohortConstructor:::benchmarkData$time |>
# distinct() |>
# filter(!grepl("male|set", msg)) |>
# mutate(
Expand Down Expand Up @@ -240,7 +235,7 @@ The following plot shows the times taken to create each cohort using CIRCE and C

```{r, fig.width=8, fig.height=7}
benchmarkData$time |>
CohortConstructor:::benchmarkData$time |>
distinct() |>
filter(!grepl("male|set", msg)) |>
mutate(
Expand Down Expand Up @@ -284,15 +279,15 @@ The table below depicts the total time it took to create the nine cohorts when u

```{r}
header_prefix <- "[header]Time by tool (minutes)\n[header_level]"
benchmarkData$time |>
CohortConstructor:::benchmarkData$time |>
distinct() |>
filter(grepl("atlas", msg)) |>
filter(!grepl("male", msg)) |>
group_by(cdm_name) |>
summarise(time = niceNum(sum(as.numeric(toc) - as.numeric(tic))/60, 2)) |>
mutate(Tool = "CIRCE") |>
union_all(
benchmarkData$time |>
CohortConstructor:::benchmarkData$time |>
filter(msg == "cc_set_no_strata") |>
group_by(cdm_name) |>
summarise(time = niceNum(sum(as.numeric(toc) - as.numeric(tic))/60, 2)) |>
Expand All @@ -312,7 +307,7 @@ benchmarkData$time |>
Cohorts are often stratified in studies. With Atlas cohort definitions, each stratum requires a new CIRCE JSON to be instantiated, while CohortConstructor allows stratifications to be generated from an overall cohort. The following table shows the time taken to create age and sex stratifications for the COVID-19 cohort with both CIRCE and CohortConstructor.

```{r}
benchmarkData$time |>
CohortConstructor:::benchmarkData$time |>
distinct() |>
filter(grepl("atlas_covid|set_strata", msg) | msg == "cc_covid") |>
filter(msg != "atlas_covid") |>
Expand Down Expand Up @@ -345,7 +340,7 @@ Four calls were made to `conceptCohort`, each involving a different number of OM
The plot below shows the computation time with and without SQL indexes for each scenario:

```{r, fig.width=8, fig.height=7}
benchmarkData$sql_indexes |>
CohortConstructor:::benchmarkData$sql_indexes |>
distinct() |>
group_by(cdm_name, msg) |>
summarise(time = sum(as.numeric(toc) - as.numeric(tic))/60, .groups = "drop") |>
Expand Down

0 comments on commit 5f723ec

Please sign in to comment.