![](../logo.png)
Assessing drug restart and switching after treatment
drug_restart.Rmd
Introduction
Obtaining information on drug restart or switching to another drug after discontinuation of the original treatment is often of interest in drug utilisation studies. In this vignette, we show how to assess drug switching and restart with this package.
Data
Connect to mock data
For this vignette we will use mock data contained in the DrugUtilisation package.
library(DrugUtilisation)
cdm <- mockDrugUtilisation(numberIndividual = 200)
Generate study cohorts
We will examine the patterns of drug restart and switching among patients taking metformin as an example. Specifically, we will investigate whether patients restart metformin after discontinuation, switch to insulin, try both medications, or remain untreated.
For this we will need two cohorts: one of patients exposed to metformin and another of patients exposed to insulin.
# codelists
metformin <- CodelistGenerator::getDrugIngredientCodes(cdm = cdm, name = "metformin")
insulin <- CodelistGenerator::getDrugIngredientCodes(cdm = cdm, name = "insulin detemir")
cdm <- generateDrugUtilisationCohortSet(
cdm = cdm, name = "metformin", conceptSet = metformin
)
cdm$metformin |>
cohortCount()
#> # A tibble: 1 × 3
#> cohort_definition_id number_records number_subjects
#> <int> <int> <int>
#> 1 1 107 92
cdm <- generateDrugUtilisationCohortSet(
cdm = cdm, name = "insulin", conceptSet = insulin
)
cdm$insulin |>
cohortCount()
#> # A tibble: 1 × 3
#> cohort_definition_id number_records number_subjects
#> <int> <int> <int>
#> 1 1 93 85
Assess drug restart
The summariseDrugRestart()
function analyses the
outcomes within a treatment cohort following the first exposure to a
specific drug. It categorises the events into four distinct groups:
Restarting the same treatment.
Switching to a different treatment.
Restarting the same treatment while also switching to another.
Discontinuing treatment altogether (neither the original treatment nor any potential switch).
The figure below illustrates the analysis, focusing on the outcomes after the initial exposure to a particular drug (in blue), with consideration of a specific switch drug (in orange). This study examines what occurs within 100, 180, and 365 days following first treatment discontinuation in the cohort.
Now, let’s use the function to assess metformin restart and switch to insulin after the first metformin treatment.
results <- cdm$metformin |>
summariseDrugRestart(
switchCohortTable = "insulin",
switchCohortId = NULL,
strata = list(),
followUpDays = Inf,
censorDate = NULL,
restrictToFirstDiscontinuation = TRUE
)
results |>
dplyr::glimpse()
#> Rows: 8
#> Columns: 13
#> $ result_id <int> 1, 1, 1, 1, 1, 1, 1, 1
#> $ cdm_name <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ group_name <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level <chr> "6809_metformin", "6809_metformin", "6809_metformin",…
#> $ strata_name <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name <chr> "End of observation", "End of observation", "End of o…
#> $ variable_level <chr> "restart", "restart", "switch", "switch", "restart an…
#> $ estimate_name <chr> "count", "percentage", "count", "percentage", "count"…
#> $ estimate_type <chr> "integer", "percentage", "integer", "percentage", "in…
#> $ estimate_value <chr> "13", "14.1304347826087", "3", "3.26086956521739", "2…
#> $ additional_name <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…
We could be interested in getting these results in different follow-up periods since the first metformin exposure ended. For instance, next we get the results in the first 180 days, the first year, and until the end of observation.
results <- cdm$metformin |>
summariseDrugRestart(
switchCohortTable = "insulin",
switchCohortId = NULL,
strata = list(),
followUpDays = c(180, 365, Inf),
censorDate = NULL,
restrictToFirstDiscontinuation = TRUE
)
Other options that this function allows are:
- restrictToFirstDiscontinuation
By default this argument is set to TRUE, which means that we only consider the firsts exposure of the subject. If FALSE, the analysis is conducted on a record level, considering all exposures in the cohort, as the following image illustrates:
- censorEndDate
This argument allows to stop considering restart and switch events after a certain date, which must specified as a column in the cohort.
- strata
This argument must be a list pointing to columns or combinations of columns in the cohort to use as strata. It will produce stratified estimates as well as for the overall cohort.
For instance, we reproduce the last calculation but this time straifying by sex. We first use PatientProfiles to add a column indicating the sex, which later we use in strata.
results <- cdm$cohort1 |>
PatientProfiles::addSex() |>
summariseDrugRestart(
switchCohortTable = "insulin",
switchCohortId = NULL,
strata = list("sex"),
followUpDays = c(180, 365, Inf),
censorDate = NULL,
restrictToFirstDiscontinuation = TRUE
)
Visualise drug restart
The package has table and plot functions to help visualising the
results from summariseDrugRestart()
.
Table
The function tableDrugRestart()
will create a gt,
flextable or tibble table from the summarised_result object created with
summariseDrugRestart()
. This function offers multiple
customisation options to format the resulting table according to the
user preferences.
results |>
tableDrugRestart(
header = c("strata"),
splitStrata = TRUE,
cohortName = TRUE,
cdmName = FALSE,
groupColumn = c("cohort_name"),
type = "gt",
formatEstimateName = c(`N (%)` = "<count> (<percentage> %)"),
.options = list()
)
#> ! Results have not been suppressed.
Follow-up | Event | Estimate name | Sex | ||
---|---|---|---|---|---|
Overall | Female | Male | |||
Cohort 1 | |||||
180 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 3 (4.55 %) | 2 (6.90 %) | 1 (2.70 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 63 (95.45 %) | 27 (93.10 %) | 36 (97.30 %) | |
365 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 3 (4.55 %) | 2 (6.90 %) | 1 (2.70 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 63 (95.45 %) | 27 (93.10 %) | 36 (97.30 %) | |
End of observation | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 5 (7.58 %) | 4 (13.79 %) | 1 (2.70 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 61 (92.42 %) | 25 (86.21 %) | 36 (97.30 %) | |
Cohort 2 | |||||
180 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 3 (5.88 %) | 2 (7.41 %) | 1 (4.17 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 48 (94.12 %) | 25 (92.59 %) | 23 (95.83 %) | |
365 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 5 (9.80 %) | 3 (11.11 %) | 2 (8.33 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 46 (90.20 %) | 24 (88.89 %) | 22 (91.67 %) | |
End of observation | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 8 (15.69 %) | 5 (18.52 %) | 3 (12.50 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 43 (84.31 %) | 22 (81.48 %) | 21 (87.50 %) | |
Cohort 3 | |||||
180 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 4 (4.82 %) | 3 (7.69 %) | 1 (2.27 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 79 (95.18 %) | 36 (92.31 %) | 43 (97.73 %) | |
365 days | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 5 (6.02 %) | 4 (10.26 %) | 1 (2.27 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 78 (93.98 %) | 35 (89.74 %) | 43 (97.73 %) | |
End of observation | Restart | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) |
Switch | N (%) | 8 (9.64 %) | 6 (15.38 %) | 2 (4.55 %) | |
Restart and switch | N (%) | 0 (0.00 %) | 0 (0.00 %) | 0 (0.00 %) | |
Not treated | N (%) | 75 (90.36 %) | 33 (84.62 %) | 42 (95.45 %) |
Plot
The plotDrugRestart()
function creates a bar plot
depicting the percentage of drug restart events for each cohort,
stratum, and follow-up time (specified in the variable_name column of
the summarised result). This function offers customisation options for
colours, facetting, and handling of strata.
results |>
plotDrugRestart(
facetX = "variable_name",
facetY = c("cohort_name", "strata"),
colour = "variable_level",
splitStrata = TRUE
)
#> ! There are duplicated points, not included either in facetX, facetY or colour:
#> • treatment: 180 days, 365 days, End of observation.