Skip to content

Commit fe7418e

Browse files
committed
speed up docs
1 parent 259c7b6 commit fe7418e

4 files changed

+16
-52
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ hip_fx_codes <- getCandidateCodes(cdm, "hip fracture")
9393
#> Search completed. Finishing up.
9494
#> ✔ 1 candidate concept identified
9595
#>
96-
#> Time taken: 0 minutes and 1 seconds
96+
#> Time taken: 0 minutes and 0 seconds
9797
forearm_fx_codes <- getCandidateCodes(cdm, "forearm fracture")
9898
#> Limiting to domains of interest
9999
#> Getting concepts to include
100100
#> Adding descendants
101101
#> Search completed. Finishing up.
102102
#> ✔ 1 candidate concept identified
103103
#>
104-
#> Time taken: 0 minutes and 1 seconds
104+
#> Time taken: 0 minutes and 0 seconds
105105

106106
fx_codes <- newCodelist(list("hip_fracture" = hip_fx_codes$concept_id,
107107
"forearm_fracture"= forearm_fx_codes$concept_id))

vignettes/a06_concatanate_cohorts.Rmd

+5-14
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ cdm <- CDMConnector::cdmFromCon(con, cdmSchema = "main",
4545
writeSchema = "main", writePrefix = "my_study_")
4646
```
4747

48-
Let's start by creating two drug cohorts, one for users of diclofenac and another for users of acetaminophen.
48+
Let's start by creating a cohort of users of acetaminophen
4949

5050
```{r}
5151
cdm$medications <- conceptCohort(cdm = cdm,
52-
conceptSet = list("diclofenac" = 1124300,
53-
"acetaminophen" = 1127433),
52+
conceptSet = list("acetaminophen" = 1127433),
5453
name = "medications")
5554
cohortCount(cdm$medications)
5655
```
@@ -59,8 +58,8 @@ We can merge cohort records using the `collapseCohorts()` function in the Cohort
5958
Let's first define a new cohort where records within 1095 days (~ 3 years) of each other will be merged.
6059

6160
```{r}
62-
cdm$medications_collapsed <- collapseCohorts(
63-
cohort = cdm$medications,
61+
cdm$medications_collapsed <- cdm$medications |>
62+
collapseCohorts(
6463
gap = 1095,
6564
name = "medications_collapsed"
6665
)
@@ -80,14 +79,6 @@ Now let's look at how the cohorts have been changed.
8079

8180
```{r}
8281
summary_attrition <- summariseCohortAttrition(cdm$medications_collapsed)
83-
plotCohortAttrition(summary_attrition, cohortId = 1)
82+
tableCohortAttrition(summary_attrition)
8483
```
8584

86-
The flow chart above illustrates the changes to cohort 1 (users of acetaminophen) when entries within 3 years of each other are merged. We see that collapsing the cohort has led to 1,390 fewer records.
87-
88-
```{r}
89-
summary_attrition <- summariseCohortAttrition(cdm$medications_collapsed)
90-
plotCohortAttrition(summary_attrition, cohortId = 2)
91-
```
92-
93-
The flow chart above illustrates the changes to cohort 2 (users of diclofenac) when entries within 3 years of each other are merged. Since this cohort only has one record per individual the function collapseCohorts() had no impact on the final number of records.

vignettes/a08_split_cohorts.Rmd

+3-23
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ cdm$medications <- conceptCohort(cdm = cdm,
4444
"acetaminophen" = 1127433),
4545
name = "medications")
4646
cohortCount(cdm$medications)
47+
settings(cdm$medications)
4748
```
4849

4950
We can stratify cohorts based on specified columns using the function `stratifyCohorts()`. In this example, let's stratify the medications cohort by age and sex.
@@ -52,30 +53,9 @@ We can stratify cohorts based on specified columns using the function `stratifyC
5253
cdm$stratified <- cdm$medications |>
5354
addAge(ageGroup = list("Child" = c(0,17), "18 to 65" = c(18,64), "65 and Over" = c(65, Inf))) |>
5455
addSex(name = "stratified") |>
55-
stratifyCohorts(strata = list("sex", "age_group", c("sex", "age_group")), name = "stratified")
56+
stratifyCohorts(strata = list("sex", "age_group"), name = "stratified")
5657
58+
cohortCount(cdm$stratified)
5759
settings(cdm$stratified)
5860
```
5961

60-
The age and sex columns are added using functions from the package `PatientProfiles`. The 'stratified' table includes 22 cohorts, representing various combinations of sex and age groups.
61-
62-
We can also split cohorts for specified years using the function `yearCohorts()`.
63-
64-
```{r, include=FALSE, warning=FALSE}
65-
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
66-
cdm <- cdmFromCon(con, cdmSchema = "main",
67-
writeSchema = c(prefix = "my_study_", schema = "main"))
68-
69-
cdm$medications <- conceptCohort(cdm = cdm,
70-
conceptSet = list("diclofenac" = 1124300,
71-
"acetaminophen" = 1127433),
72-
name = "medications")
73-
```
74-
75-
```{r}
76-
cdm$years <- cdm$medications |>
77-
yearCohorts(years = 2005:2010, name = "years")
78-
79-
settings(cdm$years)
80-
```
81-
The 'years' table includes 12 cohorts, with each cohort representing a specific drug and year.

vignettes/a09_combine_cohorts.Rmd

+6-13
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@ vignette: >
77
%\VignetteEncoding{UTF-8}
88
---
99

10-
```{r, include = FALSE}
11-
knitr::opts_chunk$set(
12-
collapse = TRUE,
13-
comment = "#>"
14-
)
15-
```
16-
17-
```{r setup}
18-
library(CohortConstructor)
19-
library(CohortCharacteristics)
20-
library(ggplot2)
21-
```
22-
2310
```{r, include = FALSE}
2411
knitr::opts_chunk$set(
2512
collapse = TRUE,
@@ -37,6 +24,12 @@ if (!dir.exists(Sys.getenv("EUNOMIA_DATA_FOLDER"))){ dir.create(Sys.getenv("EUNO
3724
}
3825
```
3926

27+
```{r setup}
28+
library(CohortConstructor)
29+
library(CohortCharacteristics)
30+
library(ggplot2)
31+
```
32+
4033
For this example we'll use the Eunomia synthetic data from the CDMConnector package.
4134

4235
```{r}

0 commit comments

Comments
 (0)