Title: | Analyzes Real-World Treatment Patterns of a Study Population of Interest |
---|---|
Description: | Computes treatment patterns within a given cohort using the Observational Medical Outcomes Partnership (OMOP) common data model (CDM). As described in Markus, Verhamme, Kors, and Rijnbeek (2022) <doi:10.1016/j.cmpb.2022.107081>. |
Authors: | Aniek Markus [aut] , Maarten van Kessel [cre] |
Maintainer: | Maarten van Kessel <[email protected]> |
License: | Apache License 2.0 |
Version: | 2.6.9 |
Built: | 2024-10-31 15:20:26 UTC |
Source: | https://github.com/darwin-eu/treatmentpatterns |
Class to handle the characterization plots.
TreatmentPatterns::ShinyModule
-> CharacterizationPlots
uiMenu()
Method to include a menuItem to link to the body.
CharacterizationPlots$uiMenu( label = "Characteristics", tag = "characteristics" )
label
(character(1)
)
Label to show for the menuItem
.
tag
(character(1)
)
Tag to use internally in input
.
(menuItem
)
uiBody()
Method to include a tabItem to include the body.
CharacterizationPlots$uiBody()
(tabItem
)
server()
Method to handle the back-end.
CharacterizationPlots$server(input, output, session, inputHandler)
input
(input
)
Input from the server function.
output
(output
)
Output from the server function.
session
(session
)
Session from the server function.
inputHandler
(inputHandler
)
InputHandler class.
(NULL
)
clone()
The objects of this class are cloneable with this method.
CharacterizationPlots$clone(deep = FALSE)
deep
Whether to make a deep clone.
Compute treatment patterns according to the specified parameters within specified cohorts.
computePathways( cohorts, cohortTableName, cdm = NULL, connectionDetails = NULL, cdmSchema = NULL, resultSchema = NULL, tempEmulationSchema = NULL, includeTreatments = "startDate", periodPriorToIndex = 0, minEraDuration = 0, splitEventCohorts = NULL, splitTime = NULL, eraCollapseSize = 30, combinationWindow = 30, minPostCombinationDuration = 30, filterTreatments = "First", maxPathLength = 5 )
computePathways( cohorts, cohortTableName, cdm = NULL, connectionDetails = NULL, cdmSchema = NULL, resultSchema = NULL, tempEmulationSchema = NULL, includeTreatments = "startDate", periodPriorToIndex = 0, minEraDuration = 0, splitEventCohorts = NULL, splitTime = NULL, eraCollapseSize = 30, combinationWindow = 30, minPostCombinationDuration = 30, filterTreatments = "First", maxPathLength = 5 )
cohorts |
(
|
cohortTableName |
( |
cdm |
( |
connectionDetails |
( |
cdmSchema |
( |
resultSchema |
( |
tempEmulationSchema |
Schema used to emulate temp tables |
includeTreatments |
(
|
periodPriorToIndex |
( |
minEraDuration |
( |
splitEventCohorts |
( |
splitTime |
( |
eraCollapseSize |
( |
combinationWindow |
( |
minPostCombinationDuration |
( |
filterTreatments |
( |
maxPathLength |
( |
(Andromeda::andromeda()
)
andromeda object containing non-sharable patient level
data outcomes.
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (ableToRun) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") outputEnv <- computePathways( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm ) Andromeda::close(outputEnv) DBI::dbDisconnect(con, shutdown = TRUE) }
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (ableToRun) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") outputEnv <- computePathways( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm ) Andromeda::close(outputEnv) DBI::dbDisconnect(con, shutdown = TRUE) }
Create sankey diagram.
createSankeyDiagram( treatmentPathways, groupCombinations = FALSE, colors = NULL, ... )
createSankeyDiagram( treatmentPathways, groupCombinations = FALSE, colors = NULL, ... )
treatmentPathways |
( |
groupCombinations |
(
|
colors |
( |
... |
Paramaters for sankeyNetwork. |
(htmlwidget
)
# Dummy data, typically read from treatmentPathways.csv treatmentPathways <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSankeyDiagram(treatmentPathways)
# Dummy data, typically read from treatmentPathways.csv treatmentPathways <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSankeyDiagram(treatmentPathways)
DEPRECATED Create sankey diagram.
createSankeyDiagram2( treatmentPathways, groupCombinations = FALSE, colors = NULL, ... )
createSankeyDiagram2( treatmentPathways, groupCombinations = FALSE, colors = NULL, ... )
treatmentPathways |
( |
groupCombinations |
(
|
colors |
( |
... |
Paramaters for sankeyNetwork. |
(htmlwidget
)
# Dummy data, typically read from treatmentPathways.csv treatmentPathways <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSankeyDiagram(treatmentPathways)
# Dummy data, typically read from treatmentPathways.csv treatmentPathways <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSankeyDiagram(treatmentPathways)
New sunburstPlot function
createSunburstPlot(treatmentPathways, groupCombinations = FALSE, ...)
createSunburstPlot(treatmentPathways, groupCombinations = FALSE, ...)
treatmentPathways |
( |
groupCombinations |
(
|
... |
Paramaters for sunburst. |
(htmlwidget
)
# Dummy data, typically read from treatmentPathways.csv treatmentPatwhays <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSunburstPlot(treatmentPatwhays)
# Dummy data, typically read from treatmentPathways.csv treatmentPatwhays <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSunburstPlot(treatmentPatwhays)
DEPRECATED New sunburstPlot function
createSunburstPlot2(treatmentPathways, groupCombinations = FALSE, ...)
createSunburstPlot2(treatmentPathways, groupCombinations = FALSE, ...)
treatmentPathways |
( |
groupCombinations |
(
|
... |
Paramaters for sunburst. |
(htmlwidget
)
# Dummy data, typically read from treatmentPathways.csv treatmentPatwhays <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSunburstPlot2(treatmentPatwhays)
# Dummy data, typically read from treatmentPathways.csv treatmentPatwhays <- data.frame( path = c("Acetaminophen", "Acetaminophen-Amoxicillin+Clavulanate", "Acetaminophen-Aspirin", "Amoxicillin+Clavulanate", "Aspirin"), freq = c(206, 6, 14, 48, 221), sex = rep("all", 5), age = rep("all", 5), index_year = rep("all", 5) ) createSunburstPlot2(treatmentPatwhays)
Compute treatment patterns according to the specified parameters within specified cohorts. For more customization, or investigation of patient level outcomes, you can run computePathways and export separately.
executeTreatmentPatterns( cohorts, cohortTableName, outputPath, cdm = NULL, connectionDetails = NULL, cdmSchema = NULL, resultSchema = NULL, tempEmulationSchema = NULL, minEraDuration = 0, eraCollapseSize = 30, combinationWindow = 30, minCellCount = 5 )
executeTreatmentPatterns( cohorts, cohortTableName, outputPath, cdm = NULL, connectionDetails = NULL, cdmSchema = NULL, resultSchema = NULL, tempEmulationSchema = NULL, minEraDuration = 0, eraCollapseSize = 30, combinationWindow = 30, minCellCount = 5 )
cohorts |
(
|
cohortTableName |
( |
outputPath |
( |
cdm |
( |
connectionDetails |
( |
cdmSchema |
( |
resultSchema |
( |
tempEmulationSchema |
( |
minEraDuration |
( |
eraCollapseSize |
( |
combinationWindow |
( |
minCellCount |
( |
(invisible(NULL)
)
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (require("CirceR", character.only = TRUE, quietly = TRUE)) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") executeTreatmentPatterns( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm, outputPath = tempdir() ) DBI::dbDisconnect(con, shutdown = TRUE) }
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (require("CirceR", character.only = TRUE, quietly = TRUE)) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") executeTreatmentPatterns( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm, outputPath = tempdir() ) DBI::dbDisconnect(con, shutdown = TRUE) }
Export andromeda generated by computePathways object to sharable csv-files and/or a zip archive.
export( andromeda, outputPath, ageWindow = 10, minCellCount = 5, censorType = "minCellCount", archiveName = NULL )
export( andromeda, outputPath, ageWindow = 10, minCellCount = 5, censorType = "minCellCount", archiveName = NULL )
andromeda |
( |
outputPath |
( |
ageWindow |
( |
minCellCount |
( |
censorType |
(
|
archiveName |
( |
(invisible(NULL)
)
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (ableToRun) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") outputEnv <- computePathways( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm ) export( andromeda = outputEnv, outputPath = tempdir() ) Andromeda::close(outputEnv) DBI::dbDisconnect(con, shutdown = TRUE) }
ableToRun <- all( require("CirceR", character.only = TRUE, quietly = TRUE), require("CDMConnector", character.only = TRUE, quietly = TRUE), require("TreatmentPatterns", character.only = TRUE, quietly = TRUE), require("dplyr", character.only = TRUE, quietly = TRUE) ) if (ableToRun) { library(TreatmentPatterns) library(CDMConnector) library(dplyr) withr::local_envvar( R_USER_CACHE_DIR = tempfile(), EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile()) ) tryCatch({ if (Sys.getenv("skip_eunomia_download_test") != "TRUE") { CDMConnector::downloadEunomiaData(overwrite = TRUE) } }, error = function(e) NA) con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomia_dir()) cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main") cohortSet <- readCohortSet( path = system.file(package = "TreatmentPatterns", "exampleCohorts") ) cdm <- generateCohortSet( cdm = cdm, cohortSet = cohortSet, name = "cohort_table" ) cohorts <- cohortSet %>% # Remove 'cohort' and 'json' columns select(-"cohort", -"json") %>% mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>% rename( cohortId = "cohort_definition_id", cohortName = "cohort_name", ) %>% select("cohortId", "cohortName", "type") outputEnv <- computePathways( cohorts = cohorts, cohortTableName = "cohort_table", cdm = cdm ) export( andromeda = outputEnv, outputPath = tempdir() ) Andromeda::close(outputEnv) DBI::dbDisconnect(con, shutdown = TRUE) }
Class to handle input from the user. Supports direct paths or input fields
through setDataPath()
.
TreatmentPatterns::ShinyModule
-> InputHandler
reactiveValues
(reactiveValues
)
reactiveValues class created by reactiveValues.
uiMenu()
Method to include a menuItem to link to the body.
InputHandler$uiMenu(label = "File upload", tag = "fileUpload")
label
(character(1)
)
Label to show for the menuItem
.
tag
(character(1)
)
Tag to use internally in input
.
(menuItem
)
uiBody()
Method to include a tabItem to include the body.
InputHandler$uiBody()
(tabItem
)
server()
Method to handle the back-end.
InputHandler$server(input, output, session)
input
(input
)
Input from the server function.
output
(output
)
Output from the server function.
session
(session
)
Session from the server function.
(NULL
)
uiDatabaseSelector()
Method to include a uiOutput to select between multiple uploaded files.
InputHandler$uiDatabaseSelector()
(uiOutput
)
setDataPath()
Method to dictate where the data is coming from, either from the input
through the shiny application, or from a specified path. When one is
provided, the other is ignored.
InputHandler$setDataPath(tag = "uploadField", input = NULL, path = NULL)
tag
(character(1)
)
Tag to use internally in input
.
input
(input
)
Input from the server function of the shiny app.
path
(character(1)
)
Path to a zip-file containing TreatmentPatterns output files.
(invisible(self)
)
clone()
The objects of this class are cloneable with this method.
InputHandler$clone(deep = FALSE)
deep
Whether to make a deep clone.
Launches the ResultExplorer shinyApp.
launchResultsExplorer()
launchResultsExplorer()
(shinyApp
)
if (interactive()) { launchResultsExplorer() }
if (interactive()) { launchResultsExplorer() }
Class to handle the Sankey diagram of TreatmentPatterns.
TreatmentPatterns::ShinyModule
-> TreatmentPatterns::InteracitvePlot
-> SankeyDiagram
clone()
The objects of this class are cloneable with this method.
SankeyDiagram$clone(deep = FALSE)
deep
Whether to make a deep clone.
ShinyModule super class
namespace
Namespace of the module.
new()
Initializer method
ShinyModule$new(namespace)
namespace
(character(1)
)
(invisible(self)
)
validate()
Validator method
ShinyModule$validate()
(invisible(self)
)
uiMenu()
Method to include a menuItem to link to the body.
ShinyModule$uiMenu(label, tag)
label
(character(1)
)
Label to show for the menuItem
.
tag
(character(1)
)
Tag to use internally in input
.
(menuItem
)
uiBody()
Method to include a tabItem to include the body.
ShinyModule$uiBody()
(tabItem
)
server()
Method to handle the back-end.
ShinyModule$server(input, output, session)
input
(input
)
Input from the server function.
output
(output
)
Output from the server function.
session
(session
)
Session from the server function.
(NULL
)
clone()
The objects of this class are cloneable with this method.
ShinyModule$clone(deep = FALSE)
deep
Whether to make a deep clone.
Class to handle the Sunburst plot of TreatmentPatterns.
TreatmentPatterns::ShinyModule
-> TreatmentPatterns::InteracitvePlot
-> SunburstPlot
clone()
The objects of this class are cloneable with this method.
SunburstPlot$clone(deep = FALSE)
deep
Whether to make a deep clone.