The DrugUtilisation package incorporates a function to summarise the
dose table over multiple cohorts: summariseTreatment(). In
this vignette, we will explore the functionalities and usages of this
function.
library(DrugUtilisation)
library(CodelistGenerator)
library(CDMConnector)
library(dplyr)
library(PatientProfiles)
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 |>
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 |>
newCohortTable(cohortSetRef = new_cohort_set)For the following examples, we will use the cohort
cohort1 and cohort2 already created in the
mock table.
Notice that cohort1 is a cohort with three subcohorts
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 pneumoniaAnd cohort2 is a cohort with three different
treatments:
settings(cdm$cohort2)
#> # A tibble: 3 × 2
#> cohort_definition_id cohort_name
#> <int> <chr>
#> 1 1 albuterol
#> 2 2 fluticasone
#> 3 3 montelukastsummariseTreatmentFromCohort() function creates a
standarised tibble summarising the treatment information (already
specified in an existing cohort) over multiple 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
summariseTreatmentFromCohort() to summarise treatments
defined in cohort2 in the cohorts defined in
cohort1.
summariseTreatmentFromCohort(cohort = cdm$cohort1,
treatmentCohortName = c("cohort2"),
window = list(c(0,0), c(1,30)))
#> # A tibble: 48 × 15
#> cdm_name result_type package_name package_version group_name group_level
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 2 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 3 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 4 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 5 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 6 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 7 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 8 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 9 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 10 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> # ℹ 38 more rows
#> # ℹ 9 more variables: strata_name <chr>, strata_level <chr>,
#> # variable_name <chr>, variable_level <chr>, estimate_name <chr>,
#> # estimate_type <chr>, estimate_value <chr>, additional_name <chr>,
#> # additional_level <chr>We can also stratify our cohort and calculate the estimates within
each strata group by using the strata parameter.
cdm[["cohort1"]] <- cdm[["cohort1"]] %>%
addSex(cdm) %>%
addAge(ageGroup = list("<40" = c(0, 39), ">40" = c(40, 150)))
summariseTreatmentFromCohort(cohort = cdm$cohort1,
treatmentCohortName = c("cohort2"),
window = list(c(0,0)),
treatmentCohortId = 1,
strata = list("sex" = "sex", "age" = "age_group")
)
#> # A tibble: 60 × 15
#> cdm_name result_type package_name package_version group_name group_level
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 2 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 3 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 4 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 5 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 6 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 7 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 8 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 9 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> 10 DUS MOCK summarised_trea… DrugUtilisa… 0.5.1 cohort_na… asthma
#> # ℹ 50 more rows
#> # ℹ 9 more variables: strata_name <chr>, strata_level <chr>,
#> # variable_name <chr>, variable_level <chr>, estimate_name <chr>,
#> # estimate_type <chr>, estimate_value <chr>, additional_name <chr>,
#> # additional_level <chr>Notice that we have also used the treatmentCohortId
parameter to specify that we only want to explore albuterol
across the cohorts defined in cohort1.
Soon, you will be able to include combinations of different
treatments by using the combination argument.
Unfortunately, it has not been implemented yet, stay tuned for the next
release! 😄
minCellCount parameterSpecify the minimum number of individuals that a strata group must have in order to appear in the table. Default is set to 5.
summariseTreatmentFromConceptSet() functionsummariseTreatmentFromCohort() can be used when we have
already created our treatment cohort. However, if that is not the case,
we can use summariseTreatmentFromConceptSet() to avoid
creating a new cohort before using this function. The following
arguments have to be provided:
cohort: cohort from the cdm object.treatmentConceptSet: list with the treatments’ concepts
sets.window: list of the windows where to summarise the
treatments.Unfortunately, is not implemented yet. Stay in the loop for the next release!😉