To create a shiny viewer to explore CohortDiagnostic results, Characterization results, PatientLevelPrediction results and CohortMethod results:
# install dependencies
remotes::install_github('ohdsi/ResultModelManager')
remotes::install_github('ohdsi/ShinyAppBuilder')
library(dplyr)
library(ShinyAppBuilder)
# STEP 1: create a config by first creating an empty config initializeModuleConfig()
# and then adding a shiny module using addModuleConfig()
# Note: the common OHDSI analyses have default config settings (e.g., createDefaultAboutConfig() )
library(ShinyAppBuilder)
config <- initializeModuleConfig() %>%
addModuleConfig(
createDefaultAboutConfig(
resultDatabaseDetails = list(),
useKeyring = T
)
) %>%
addModuleConfig(
createDefaultCohortDiagnosticsConfig(
resultDatabaseDetails = list(
dbms = 'sqlite',
tablePrefix = 'cd_',
schema = 'main',
vocabularyDatabaseSchema = 'main'
),
useKeyring = T
)
) %>%
addModuleConfig(
createDefaultCharacterizationConfig(
resultDatabaseDetails = list(
tablePrefix = 'c_',
cohortTablePrefix = 'cg_',
databaseTablePrefix = '',
schema = 'main',
databaseTable = 'DATABASE_META_DATA',
incidenceTablePrefix = 'ci_'
),
useKeyring = T
)
) %>%
addModuleConfig(
createDefaultPredictionConfig(
resultDatabaseDetails = list(
tablePrefix = 'plp_',
cohortTablePrefix = 'cg_',
databaseTablePrefix = '',
schema = 'main',
databaseTable = 'DATABASE_META_DATA'
),
useKeyring = T
)
) %>%
addModuleConfig(
createDefaultEstimationConfig(
resultDatabaseDetails = list(
tablePrefix = 'cm_',
cohortTablePrefix = 'cg_',
databaseTablePrefix = '',
schema = 'main',
databaseTable = 'DATABASE_META_DATA'
),
useKeyring = T
)
)
# Step 2: specify the connection details to the results database
using DatabaseConnector::createConnectionDetails
connectionDetails <- DatabaseConnector::createConnectionDetails(
# add details to the result database
)
# Step 3: create a connection handler using the ResultModelManager package
connection <- ResultModelManager::ConnectionHandler$new(connectionDetails)
# Step 4: now run the shiny app based on the config file and view the results
# at the specified connection
ShinyAppBuilder::viewShiny(config = config, connection = connection)
If the connection works and there is results in the database, then an interactive shiny app will open.
If running the shiny app on a server, you create the config as in Example 1, but instead of ShinyAppBuilder::viewShiny
use:
ShinyAppBuilder::createShinyApp(config = config, connection = connection)
See the instructions here for configuring your R environment, including Java.
In R, use the following commands to download and install ShinyAppBuilder:
install.packages("remotes")
remotes::install_github("ohdsi/ShinyAppBuilder")
Documentation can be found on the package website.
PDF versions of the documentation are also available:
Read here how you can contribute to this package.