The settings belowallow the user to influence how the events of interest should be processed to form treatment pathways. For the example in this vignette we used the default settings
| param | values | description |
|---|---|---|
| periodPriorToIndex | 0 | Number of days prior to the index date of the target cohort |
| minEraDuration | 0 | Minimum time an event era should last to be included in analysis |
| splitEventCohorts | Specify event cohort to split in acute (< X days) and therapy (>= X days) | |
| splitTime | 30 | Specify number of days (X) at which each of the split event cohorts should be split in acute and therapy |
| eraCollapseSize | 30 | Window of time between which two eras of the same event cohort are collapsed into one era |
| combinationWindow | 30 | Window of time two event cohorts need to overlap to be considered a combination treatment |
| minPostCombinationDuration | 30 | Minimum time an event era before or after a generated combination treatment should last to be included in analysis |
| filterTreatments | First | Select first occurrence of (‘First’); changes between (‘Changes’); or all event cohorts (‘All’). |
| maxPathLength | 5 | Maximum number of steps included in treatment pathway |
| minFreq | 5 | Minimum frequency required per pathway. Censors data below
x as <x. This minimum value will carry over
to the sankey diagram and sunburst plot. |
| addNoPaths | FALSE | Select to include untreated persons without treatment pathway in the sunburst plot |
library(dplyr)
# Select Viral Sinusitis Cohort
targetCohorts <- cohortsGenerated %>%
filter(cohortName == "ViralSinusitis") %>%
select(cohortId, cohortName)
# Select everything BUT Viral Sinusitis cohorts
eventCohorts <- cohortsGenerated %>%
filter(cohortName != "ViralSinusitis" & cohortName != "Death") %>%
select(cohortId, cohortName)
exitCohorts <- cohortsGenerated %>%
filter(cohortName == "Death") %>%
select(cohortId, cohortName)
cohorts <- dplyr::bind_rows(
targetCohorts %>% mutate(type = "target"),
eventCohorts %>% mutate(type = "event"),
exitCohorts %>% mutate(type = "exit")
)
tempDir <- tempdir()
allDir <- file.path(tempDir, "all_in_one")
TreatmentPatterns::executeTreatmentPatterns(
cohorts = cohorts,
cohortTableName = "CohortTable",
outputPath = allDir,
connectionDetails = connectionDetails,
cdmSchema = "main",
resultSchema = "main",
# Optional settings
includeTreatments = "startDate",
periodPriorToIndex = 0,
minEraDuration = 0,
splitEventCohorts = "",
splitTime = 30,
eraCollapseSize = 30,
combinationWindow = 30,
minPostCombinationDuration = 30,
filterTreatments = "First",
maxPathLength = 5,
minFreq = 5,
addNoPaths = TRUE
)
The segmented approach allows you to investigate the patient-level intermediate files by querying the andromeda environment.
andromeda <- TreatmentPatterns::computePathways(
cohorts = cohorts,
cohortTableName = "CohortTable",
connectionDetails = connectionDetails,
cdmSchema = "main",
resultSchema = "main"
)
names(andromeda)
andromeda$treatmentHistory
The files inside the andromeda environment can be exported using the export function.
segDir <- file.path(tempDir, "segmented")
TreatmentPatterns::export(andromeda, outputPath = segDir)
cdmDir <- file.path(tempDir, "CDMCon")
con <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
cdm <- CDMConnector::cdm_from_con(
con = con,
cdm_schema = "main",
write_schema = "main"
)
TreatmentPatterns::executeTreatmentPatterns(
cohorts = cohorts,
cohortTableName = "CohortTable",
outputPath = cdmDir,
cdm = cdm
)