Introduction
After creating a study cohort, for example of some specific condition of interest, we may be interested in describing the treatments received by the individuals within it. Here we show how such a summary can be obtained.
Create mock table
We will use mock data contained in the package throughout the
vignette. Let’s modify cohort tables cohort1
and
cohort2
in our mock dataset, so the first table includes 3
cohorts of health conditions (our study cohorts), while the second
contains three are of treatments they could receive.
library(DrugUtilisation)
#> Error in get(paste0(generic, ".", class), envir = get_method_env()) :
#> object 'type_sum.accel' not found
cdm <- mockDrugUtilisation(numberIndividual = 200)
new_cohort_set <- settings(cdm$cohort1) |>
dplyr::arrange(cohort_definition_id) |>
dplyr::mutate(cohort_name = c("asthma", "bronchitis", "pneumonia"))
cdm$cohort1 <- cdm$cohort1 |>
omopgenerics::newCohortTable(cohortSetRef = new_cohort_set)
new_cohort_set <- settings(cdm$cohort2) |>
dplyr::arrange(cohort_definition_id) |>
dplyr::mutate(cohort_name = c("albuterol", "fluticasone", "montelukast"))
cdm$cohort2 <- cdm$cohort2 |>
omopgenerics::newCohortTable(cohortSetRef = new_cohort_set)
Notice that cohort1
is a cohort table with three cohorts
representing three different conditions:
settings(cdm$cohort1)
#> # A tibble: 3 × 2
#> cohort_definition_id cohort_name
#> <int> <chr>
#> 1 1 asthma
#> 2 2 bronchitis
#> 3 3 pneumonia
And cohort2
is a cohort table with three different
treatment cohorts:
settings(cdm$cohort2)
#> # A tibble: 3 × 2
#> cohort_definition_id cohort_name
#> <int> <chr>
#> 1 1 albuterol
#> 2 2 fluticasone
#> 3 3 montelukast
Summarise treatment
The summariseTreatment()
function produces a summary of
the treatment received by our study cohorts. There are three mandatory
arguments:
-
cohort
: cohort from the cdm object. -
treatmentCohortName
: name of the treatment cohort’s table. -
window
: list of the windows where to summarise the treatments.
See an example of its usage below, where we use
summariseTreatment()
to summarise treatments defined in
cohort2
in the cohorts defined in cohort1
.
summariseTreatment(
cohort = cdm$cohort1,
treatmentCohortName = c("cohort2"),
window = list(c(0, 0), c(1, 30))
)
strata parameter
We can also stratify our cohort and calculate the estimates within
each strata group by using the strata
parameter.
cdm[["cohort1"]] <- cdm[["cohort1"]] |>
PatientProfiles::addSex() |>
PatientProfiles::addAge(ageGroup = list("<40" = c(0, 39), ">=40" = c(40, 150)))
results <- summariseTreatment(
cohort = cdm$cohort1,
treatmentCohortName = c("cohort2"),
window = list(c(0, 0)),
treatmentCohortId = 1,
strata = list("sex", "age_group")
)
Notice that we have also used the treatmentCohortId
parameter to specify that we only want to explore albuterol
across the cohorts defined in cohort1
.
Visualise results
The package includes table
and plot
functions to help visualise the results from
summariseTreatment()
.
Tables
The tableTreatment()
function generates a table in gt,
flextable, or tibble format from the summarised_result produced by
summariseTreatment()
. This function has customisation
options to format the table according to user preferences.
tableTreatment(result = results)
cdm_name
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|
DUS MOCK
|
||||||||||
censor_date | cohort_table_name | index_date | treatment_cohort_name | sex | age_group | Treatment | estimate_name |
cohort_name
|
||
asthma | bronchitis | pneumonia | ||||||||
Medication on index date | ||||||||||
NA | temp | cohort_start_date | cohort2 | overall | overall | albuterol | N (%) | 5 (7.6 %) | 6 (11.8 %) | 7 (8.4 %) |
NA | temp | cohort_start_date | cohort2 | overall | overall | untreated | N (%) | 61 (92.4 %) | 45 (88.2 %) | 76 (91.6 %) |
NA | temp | cohort_start_date | cohort2 | overall | overall | not in observation | N (%) | 0 (0.0 %) | 0 (0.0 %) | 0 (0.0 %) |
NA | temp | cohort_start_date | cohort2 | Female | overall | albuterol | N (%) | 2 (6.9 %) | 3 (11.1 %) | 2 (5.1 %) |
NA | temp | cohort_start_date | cohort2 | Female | overall | untreated | N (%) | 27 (93.1 %) | 24 (88.9 %) | 37 (94.9 %) |
NA | temp | cohort_start_date | cohort2 | Female | overall | not in observation | N (%) | 0 (0.0 %) | 0 (0.0 %) | 0 (0.0 %) |
NA | temp | cohort_start_date | cohort2 | Male | overall | albuterol | N (%) | 3 (8.1 %) | 3 (12.5 %) | 5 (11.4 %) |
NA | temp | cohort_start_date | cohort2 | Male | overall | untreated | N (%) | 34 (91.9 %) | 21 (87.5 %) | 39 (88.6 %) |
NA | temp | cohort_start_date | cohort2 | Male | overall | not in observation | N (%) | 0 (0.0 %) | 0 (0.0 %) | 0 (0.0 %) |
NA | temp | cohort_start_date | cohort2 | overall | <40 | albuterol | N (%) | 5 (9.8 %) | 6 (13.6 %) | 4 (6.7 %) |
NA | temp | cohort_start_date | cohort2 | overall | <40 | untreated | N (%) | 46 (90.2 %) | 38 (86.4 %) | 56 (93.3 %) |
NA | temp | cohort_start_date | cohort2 | overall | <40 | not in observation | N (%) | 0 (0.0 %) | 0 (0.0 %) | 0 (0.0 %) |
NA | temp | cohort_start_date | cohort2 | overall | >=40 | albuterol | N (%) | 0 (0.0 %) | 0 (0.0 %) | 3 (13.0 %) |
NA | temp | cohort_start_date | cohort2 | overall | >=40 | untreated | N (%) | 15 (100.0 %) | 7 (100.0 %) | 20 (87.0 %) |
NA | temp | cohort_start_date | cohort2 | overall | >=40 | not in observation | N (%) | 0 (0.0 %) | 0 (0.0 %) | 0 (0.0 %) |
Plots
The plotTreatment()
function creates a bar plot showing
the percentage of treated and untreated in each cohort, stratum, and
time-window. This function offers customization options for colors,
faceting, and handling of strata.
plotTreatment(
result = results,
facet = sex + age_group ~ window_name + cohort_name,
colour = "variable_level"
)