| Title: | Implement Descriptive Studies Using the Common Data Model |
|---|---|
| Description: | An end-to-end framework that enables users to implement various descriptive studies for a given set of target and outcome cohorts for data mapped to the Observational Medical Outcomes Partnership Common Data Model. |
| Authors: | Jenna Reps [aut, cre], Patrick Ryan [aut], Chris Knoll [aut] |
| Maintainer: | Jenna Reps <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 3.0.1 |
| Built: | 2026-05-15 21:00:31 UTC |
| Source: | https://github.com/ohdsi/characterization |
Removes csv files from folders that have not been marked as completed and removes the record of the execution file
cleanIncremental(executionFolder, ignoreWhenEmpty = FALSE)cleanIncremental(executionFolder, ignoreWhenEmpty = FALSE)
executionFolder |
The folder that has the execution files |
ignoreWhenEmpty |
When TRUE, if there are no incremental logs then nothing is run |
A list with the settings
Other Incremental:
cleanNonIncremental()
cleanIncremental( file.path(tempdir(), 'incremental'), ignoreWhenEmpty = TRUE )cleanIncremental( file.path(tempdir(), 'incremental'), ignoreWhenEmpty = TRUE )
Removes csv files from the execution folder as there should be no csv files when running in non-incremental model
cleanNonIncremental(executionFolder)cleanNonIncremental(executionFolder)
executionFolder |
The folder that has the execution files |
A list with the settings
Other Incremental:
cleanIncremental()
# example code cleanNonIncremental(file.path(tempdir(), 'incremental'))# example code cleanNonIncremental(file.path(tempdir(), 'incremental'))
Compute dechallenge rechallenge study
computeDechallengeRechallengeAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), settings, databaseId = "database 1", outputFolder, minCellCount = 0, progressBar = interactive(), ... )computeDechallengeRechallengeAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), settings, databaseId = "database 1", outputFolder, minCellCount = 0, progressBar = interactive(), ... )
connectionDetails |
An object of type 'connectionDetails' as created using the [DatabaseConnector::createConnectionDetails()] function. |
targetDatabaseSchema |
Schema name where your target cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
targetTable |
Name of the target cohort table. |
outcomeDatabaseSchema |
Schema name where your outcome cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
outcomeTable |
Name of the outcome cohort table. |
tempEmulationSchema |
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp tables, provide a schema with write privileges where temp tables can be created |
settings |
The settings for the timeToEvent study |
databaseId |
An identifier for the database (string) |
outputFolder |
A directory to save the results as csv files |
minCellCount |
The minimum cell value to display, values less than this will be replaced by -1 |
progressBar |
Whether to display a progress bar while the analysis is running |
... |
extra inputs |
An Andromeda::andromeda() object containing the dechallenge rechallenge results
Other DechallengeRechallenge:
computeRechallengeFailCaseSeriesAnalyses(),
createDechallengeRechallengeSettings()
conDet <- exampleOmopConnectionDetails() drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) computeDechallengeRechallengeAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', settings = drSet, outputFolder = tempdir() )conDet <- exampleOmopConnectionDetails() drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) computeDechallengeRechallengeAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', settings = drSet, outputFolder = tempdir() )
Compute fine the subjects that fail the dechallenge rechallenge study
computeRechallengeFailCaseSeriesAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), settings, databaseId = "database 1", showSubjectId = FALSE, outputFolder, minCellCount = 0, progressBar = interactive(), executionId, ... )computeRechallengeFailCaseSeriesAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), settings, databaseId = "database 1", showSubjectId = FALSE, outputFolder, minCellCount = 0, progressBar = interactive(), executionId, ... )
connectionDetails |
An object of type 'connectionDetails' as created using the [DatabaseConnector::createConnectionDetails()] function. |
targetDatabaseSchema |
Schema name where your target cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
targetTable |
Name of the target cohort table. |
outcomeDatabaseSchema |
Schema name where your outcome cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
outcomeTable |
Name of the outcome cohort table. |
tempEmulationSchema |
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp tables, provide a schema with write privileges where temp tables can be created |
settings |
The settings for the timeToEvent study |
databaseId |
An identifier for the database (string) |
showSubjectId |
if F then subject_ids are hidden (recommended if sharing results) |
outputFolder |
A directory to save the results as csv files |
minCellCount |
The minimum cell value to display, values less than this will be replaced by -1 |
progressBar |
Whether to display a progress bar while the analysis is running |
executionId |
a unique id for the run |
... |
extra inputs |
An Andromeda::andromeda() object with the case series details of the failed rechallenge
Other DechallengeRechallenge:
computeDechallengeRechallengeAnalyses(),
createDechallengeRechallengeSettings()
conDet <- exampleOmopConnectionDetails() drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) computeRechallengeFailCaseSeriesAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', settings = drSet, outputFolder = tempdir() )conDet <- exampleOmopConnectionDetails() drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) computeRechallengeFailCaseSeriesAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', settings = drSet, outputFolder = tempdir() )
Compute time to event study
computeTimeToEventAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cdmDatabaseSchema, settings, databaseId = "database 1", outputFolder, minCellCount = 0, progressBar = interactive(), executionId, ... )computeTimeToEventAnalyses( connectionDetails = NULL, targetDatabaseSchema, targetTable, outcomeDatabaseSchema = targetDatabaseSchema, outcomeTable = targetTable, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cdmDatabaseSchema, settings, databaseId = "database 1", outputFolder, minCellCount = 0, progressBar = interactive(), executionId, ... )
connectionDetails |
An object of type 'connectionDetails' as created using the [DatabaseConnector::createConnectionDetails()] function. |
targetDatabaseSchema |
Schema name where your target cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
targetTable |
Name of the target cohort table. |
outcomeDatabaseSchema |
Schema name where your outcome cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
outcomeTable |
Name of the outcome cohort table. |
tempEmulationSchema |
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp tables, provide a schema with write privileges where temp tables can be created |
cdmDatabaseSchema |
The database schema containing the OMOP CDM data |
settings |
The settings for the timeToEvent study |
databaseId |
An identifier for the database (string) |
outputFolder |
A directory to save the results as csv files |
minCellCount |
The minimum cell value to display, values less than this will be replaced by -1 |
progressBar |
Whether to display a progress bar while the analysis is running |
executionId |
a unique id for the run |
... |
extra inputs |
An Andromeda::andromeda() object containing the time to event results.
Other TimeToEvent:
createTimeToEventSettings()
# example code conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) result <- computeTimeToEventAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', cdmDatabaseSchema = 'main', settings = tteSet, outputFolder = file.path(tempdir(), 'tte') )# example code conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) result <- computeTimeToEventAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', cdmDatabaseSchema = 'main', settings = tteSet, outputFolder = file.path(tempdir(), 'tte') )
Create aggregate covariate study settings
createCaseSeriesSettings( targetIds, outcomeIds, limitToFirstInNDays = 99999, minPriorObservation = 0, outcomeWashoutDays = 0, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", caseCovariateSettings = createDuringCovariateSettings(useConditionGroupEraDuring = TRUE, useDrugGroupEraDuring = TRUE, useProcedureOccurrenceDuring = TRUE, useDeviceExposureDuring = TRUE, useMeasurementDuring = TRUE, useObservationDuring = TRUE, useVisitConceptCountDuring = TRUE), casePreTargetDuration = 365, casePostOutcomeDuration = 365 )createCaseSeriesSettings( targetIds, outcomeIds, limitToFirstInNDays = 99999, minPriorObservation = 0, outcomeWashoutDays = 0, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", caseCovariateSettings = createDuringCovariateSettings(useConditionGroupEraDuring = TRUE, useDrugGroupEraDuring = TRUE, useProcedureOccurrenceDuring = TRUE, useDeviceExposureDuring = TRUE, useMeasurementDuring = TRUE, useObservationDuring = TRUE, useVisitConceptCountDuring = TRUE), casePreTargetDuration = 365, casePostOutcomeDuration = 365 )
targetIds |
A list of cohortIds for the target cohorts |
outcomeIds |
A list of cohortIds for the outcome cohorts |
limitToFirstInNDays |
whether to limit each target cohort to the first entry into the cohort per N days per subject |
minPriorObservation |
The minimum time (in days) in the database a patient in the target cohorts must be observed prior to index |
outcomeWashoutDays |
Patients with the outcome within outcomeWashout days prior to index are excluded from the risk factor analysis |
riskWindowStart |
The start of the risk window (in days) relative to the 'startAnchor'. |
startAnchor |
The anchor point for the start of the risk window. Can be '"cohort start"' or '"cohort end"'. |
riskWindowEnd |
The end of the risk window (in days) relative to the 'endAnchor'. |
endAnchor |
The anchor point for the end of the risk window. Can be '"cohort start"' or '"cohort end"'. |
caseCovariateSettings |
An object created using |
casePreTargetDuration |
The number of days prior to case index we use for FeatureExtraction |
casePostOutcomeDuration |
The number of days prior to case index we use for FeatureExtraction |
A list with the settings
Other Aggregate:
createRiskFactorSettings(),
createTargetBaselineSettings()
caseSeriesSetting <- createCaseSeriesSettings( targetIds = c(1,2), outcomeIds = c(3), limitToFirstInNDays = 365, minPriorObservation = 365, outcomeWashoutDays = 90, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", casePreTargetDuration = 365, casePostOutcomeDuration = 365 )caseSeriesSetting <- createCaseSeriesSettings( targetIds = c(1,2), outcomeIds = c(3), limitToFirstInNDays = 365, minPriorObservation = 365, outcomeWashoutDays = 90, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", casePreTargetDuration = 365, casePostOutcomeDuration = 365 )
This function creates a list of settings for different characterization studies
createCharacterizationSettings( timeToEventSettings = NULL, dechallengeRechallengeSettings = NULL, targetBaselineSettings = NULL, riskFactorSettings = NULL, caseSeriesSettings = NULL )createCharacterizationSettings( timeToEventSettings = NULL, dechallengeRechallengeSettings = NULL, targetBaselineSettings = NULL, riskFactorSettings = NULL, caseSeriesSettings = NULL )
timeToEventSettings |
A list of timeToEvent settings |
dechallengeRechallengeSettings |
A list of dechallengeRechallenge settings |
targetBaselineSettings |
A list of targetBaselineSettings settings |
riskFactorSettings |
A list of riskFactorSettings settings |
caseSeriesSettings |
A list of caseSeriesSettings settings |
Specify one or more timeToEvent, dechallengeRechallenge and aggregateCovariate settings
Returns the connection to the sqlite database
Other LargeScale:
loadCharacterizationSettings(),
runCharacterizationAnalyses(),
saveCharacterizationSettings()
# example code drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet )# example code drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet )
This function executes a large set of SQL statements to create tables that can store results
createCharacterizationTables( connectionDetails, resultSchema, targetDialect = "postgresql", deleteExistingTables = TRUE, createTables = TRUE, tablePrefix = "c_", tempEmulationSchema = getOption("sqlRenderTempEmulationSchema") )createCharacterizationTables( connectionDetails, resultSchema, targetDialect = "postgresql", deleteExistingTables = TRUE, createTables = TRUE, tablePrefix = "c_", tempEmulationSchema = getOption("sqlRenderTempEmulationSchema") )
connectionDetails |
The connectionDetails to a database created by using the
function |
resultSchema |
The name of the database schema that the result tables will be created. |
targetDialect |
The database management system being used |
deleteExistingTables |
If true any existing tables matching the Characterization result tables names will be deleted |
createTables |
If true the Characterization result tables will be created |
tablePrefix |
A string appended to the Characterization result tables |
tempEmulationSchema |
The temp schema used when the database management system is oracle |
This function can be used to create (or delete) Characterization result tables
Returns NULL but creates the required tables into the specified database schema.
Other Database:
createSqliteDatabase(),
insertResultsToDatabase()
# create sqlite database charResultDbCD <- createSqliteDatabase() # create database results tables createCharacterizationTables( connectionDetails = charResultDbCD, resultSchema = 'main' )# create sqlite database charResultDbCD <- createSqliteDatabase() # create database results tables createCharacterizationTables( connectionDetails = charResultDbCD, resultSchema = 'main' )
Create dechallenge rechallenge study settings
createDechallengeRechallengeSettings( targetIds, outcomeIds, dechallengeStopInterval = 30, dechallengeEvaluationWindow = 30 )createDechallengeRechallengeSettings( targetIds, outcomeIds, dechallengeStopInterval = 30, dechallengeEvaluationWindow = 30 )
targetIds |
A list of cohortIds for the target cohorts |
outcomeIds |
A list of cohortIds for the outcome cohorts |
dechallengeStopInterval |
An integer specifying the how much time to add to the cohort_end when determining whether the event starts during cohort and ends after |
dechallengeEvaluationWindow |
An integer specifying the period of time after the cohort_end when you cannot see an outcome for a dechallenge success |
A list with the settings
Other DechallengeRechallenge:
computeDechallengeRechallengeAnalyses(),
computeRechallengeFailCaseSeriesAnalyses()
drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 )drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 )
Create during covariate settings
createDuringCovariateSettings( useConditionOccurrenceDuring = FALSE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE, useDrugExposureDuring = FALSE, useDrugEraDuring = FALSE, useDrugGroupEraDuring = FALSE, useProcedureOccurrenceDuring = FALSE, useDeviceExposureDuring = FALSE, useMeasurementDuring = FALSE, useObservationDuring = FALSE, useVisitCountDuring = FALSE, useVisitConceptCountDuring = FALSE, includedCovariateConceptIds = c(), addDescendantsToInclude = FALSE, excludedCovariateConceptIds = c(), addDescendantsToExclude = FALSE, includedCovariateIds = c() )createDuringCovariateSettings( useConditionOccurrenceDuring = FALSE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE, useDrugExposureDuring = FALSE, useDrugEraDuring = FALSE, useDrugGroupEraDuring = FALSE, useProcedureOccurrenceDuring = FALSE, useDeviceExposureDuring = FALSE, useMeasurementDuring = FALSE, useObservationDuring = FALSE, useVisitCountDuring = FALSE, useVisitConceptCountDuring = FALSE, includedCovariateConceptIds = c(), addDescendantsToInclude = FALSE, excludedCovariateConceptIds = c(), addDescendantsToExclude = FALSE, includedCovariateIds = c() )
useConditionOccurrenceDuring |
One covariate per condition in the condition_occurrence table starting between cohort start and cohort end. (analysis ID 109) |
useConditionOccurrencePrimaryInpatientDuring |
One covariate per condition observed as a primary diagnosis in an inpatient setting in the condition_occurrence table starting between cohort start and cohort end. (analysis ID 110) |
useConditionEraDuring |
One covariate per condition in the condition_era table starting between cohort start and cohort end. (analysis ID 217) |
useConditionGroupEraDuring |
One covariate per condition era rolled up to groups in the condition_era table starting between cohort start and cohort end. (analysis ID 218) |
useDrugExposureDuring |
One covariate per drug in the drug_exposure table between cohort start and end. (analysisId 305) |
useDrugEraDuring |
One covariate per drug in the drug_era table between cohort start and end. (analysis ID 417) |
useDrugGroupEraDuring |
One covariate per drug rolled up to ATC groups in the drug_era table between cohort start and end. (analysis ID 418) |
useProcedureOccurrenceDuring |
One covariate per procedure in the procedure_occurrence table between cohort start and end. (analysis ID 505) |
useDeviceExposureDuring |
One covariate per device in the device exposure table starting between cohort start and end. (analysis ID 605) |
useMeasurementDuring |
One covariate per measurement in the measurement table between cohort start and end. (analysis ID 713) |
useObservationDuring |
One covariate per observation in the observation table between cohort start and end. (analysis ID 805) |
useVisitCountDuring |
The number of visits observed between cohort start and end. (analysis ID 926) |
useVisitConceptCountDuring |
The number of visits observed between cohort start and end, stratified by visit concept ID. (analysis ID 927) |
includedCovariateConceptIds |
A list of concept IDs that should be used to construct covariates. |
addDescendantsToInclude |
Should descendant concept IDs be added to the list of concepts to include? |
excludedCovariateConceptIds |
A list of concept IDs that should NOT be used to construct covariates. |
addDescendantsToExclude |
Should descendant concept IDs be added to the list of concepts to exclude? |
includedCovariateIds |
A list of covariate IDs that should be restricted to. |
creates an object specifying how during covariates should be constructed from data in the CDM model.
An object of type covariateSettings, to be used in other functions.
Other CovariateSetting:
getDbDuringCovariateData()
settings <- createDuringCovariateSettings( useConditionOccurrenceDuring = TRUE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE )settings <- createDuringCovariateSettings( useConditionOccurrenceDuring = TRUE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE )
Create risk factor study settings
createRiskFactorSettings( targetIds, outcomeIds, limitToFirstInNDays = 99999, minPriorObservation = 0, outcomeWashoutDays = 0, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", covariateSettings = FeatureExtraction::createCovariateSettings(useDemographicsGender = TRUE, useDemographicsAge = TRUE, useDemographicsAgeGroup = TRUE, useDemographicsRace = TRUE, useDemographicsEthnicity = TRUE, useDemographicsIndexYear = TRUE, useDemographicsIndexMonth = TRUE, useDemographicsTimeInCohort = TRUE, useDemographicsPriorObservationTime = TRUE, useDemographicsPostObservationTime = TRUE, useConditionGroupEraLongTerm = TRUE, useDrugGroupEraOverlapping = TRUE, useDrugGroupEraLongTerm = TRUE, useProcedureOccurrenceLongTerm = TRUE, useMeasurementLongTerm = TRUE, useObservationLongTerm = TRUE, useDeviceExposureLongTerm = TRUE, useVisitConceptCountLongTerm = TRUE, useConditionGroupEraShortTerm = TRUE, useDrugGroupEraShortTerm = TRUE, useProcedureOccurrenceShortTerm = TRUE, useMeasurementShortTerm = TRUE, useObservationShortTerm = TRUE, useDeviceExposureShortTerm = TRUE, useVisitConceptCountShortTerm = TRUE, endDays = 0, longTermStartDays = -365, shortTermStartDays = -30), minTargetSize = 0, minTwithOSize = 0 )createRiskFactorSettings( targetIds, outcomeIds, limitToFirstInNDays = 99999, minPriorObservation = 0, outcomeWashoutDays = 0, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start", covariateSettings = FeatureExtraction::createCovariateSettings(useDemographicsGender = TRUE, useDemographicsAge = TRUE, useDemographicsAgeGroup = TRUE, useDemographicsRace = TRUE, useDemographicsEthnicity = TRUE, useDemographicsIndexYear = TRUE, useDemographicsIndexMonth = TRUE, useDemographicsTimeInCohort = TRUE, useDemographicsPriorObservationTime = TRUE, useDemographicsPostObservationTime = TRUE, useConditionGroupEraLongTerm = TRUE, useDrugGroupEraOverlapping = TRUE, useDrugGroupEraLongTerm = TRUE, useProcedureOccurrenceLongTerm = TRUE, useMeasurementLongTerm = TRUE, useObservationLongTerm = TRUE, useDeviceExposureLongTerm = TRUE, useVisitConceptCountLongTerm = TRUE, useConditionGroupEraShortTerm = TRUE, useDrugGroupEraShortTerm = TRUE, useProcedureOccurrenceShortTerm = TRUE, useMeasurementShortTerm = TRUE, useObservationShortTerm = TRUE, useDeviceExposureShortTerm = TRUE, useVisitConceptCountShortTerm = TRUE, endDays = 0, longTermStartDays = -365, shortTermStartDays = -30), minTargetSize = 0, minTwithOSize = 0 )
targetIds |
A list of cohortIds for the target cohorts |
outcomeIds |
A list of cohortIds for the outcome cohorts |
limitToFirstInNDays |
whether to limit each target cohort to the first entry into the cohort per N days per subject |
minPriorObservation |
The minimum time (in days) in the database a patient in the target cohorts must be observed prior to index |
outcomeWashoutDays |
Patients with the outcome within outcomeWashout days prior to index are excluded from the risk factor analysis |
riskWindowStart |
The start of the risk window (in days) relative to the 'startAnchor'. |
startAnchor |
The anchor point for the start of the risk window. Can be '"cohort start"' or '"cohort end"'. |
riskWindowEnd |
The end of the risk window (in days) relative to the 'endAnchor'. |
endAnchor |
The anchor point for the end of the risk window. Can be '"cohort start"' or '"cohort end"'. |
covariateSettings |
An object created using |
minTargetSize |
The minimum size of the target cohorts for them to have aggregate covariates calculated |
minTwithOSize |
The minimum size of the cohorts corresponding to patients in the target with the outcome during time-at-risk for them to have aggregate covariates calculated |
A list with the settings
Other Aggregate:
createCaseSeriesSettings(),
createTargetBaselineSettings()
riskFactorSetting <- createRiskFactorSettings( targetIds = c(1,2), outcomeIds = c(3), minPriorObservation = 365, outcomeWashoutDays = 90, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start" )riskFactorSetting <- createRiskFactorSettings( targetIds = c(1,2), outcomeIds = c(3), minPriorObservation = 365, outcomeWashoutDays = 90, riskWindowStart = 1, startAnchor = "cohort start", riskWindowEnd = 365, endAnchor = "cohort start" )
This function creates a connection to an sqlite database
createSqliteDatabase(sqliteLocation = tempdir())createSqliteDatabase(sqliteLocation = tempdir())
sqliteLocation |
The location of the sqlite database |
This function creates a sqlite database and connection
Returns the connection detail object to the sqlite database
Other Database:
createCharacterizationTables(),
insertResultsToDatabase()
charResultDbCD <- createSqliteDatabase()charResultDbCD <- createSqliteDatabase()
Create target baseline aggregate covariate study settings
createTargetBaselineSettings( targetIds, limitToFirstInNDays = 99999, minPriorObservation = 0, covariateSettings = FeatureExtraction::createCovariateSettings(useDemographicsGender = TRUE, useDemographicsAge = TRUE, useDemographicsAgeGroup = TRUE, useDemographicsRace = TRUE, useDemographicsEthnicity = TRUE, useDemographicsIndexYear = TRUE, useDemographicsIndexMonth = TRUE, useDemographicsTimeInCohort = TRUE, useDemographicsPriorObservationTime = TRUE, useDemographicsPostObservationTime = TRUE, useConditionGroupEraLongTerm = TRUE, useDrugGroupEraOverlapping = TRUE, useDrugGroupEraLongTerm = TRUE, useProcedureOccurrenceLongTerm = TRUE, useMeasurementLongTerm = TRUE, useObservationLongTerm = TRUE, useDeviceExposureLongTerm = TRUE, useVisitConceptCountLongTerm = TRUE, useConditionGroupEraShortTerm = TRUE, useDrugGroupEraShortTerm = TRUE, useProcedureOccurrenceShortTerm = TRUE, useMeasurementShortTerm = TRUE, useObservationShortTerm = TRUE, useDeviceExposureShortTerm = TRUE, useVisitConceptCountShortTerm = TRUE, useCharlsonIndex = TRUE, endDays = 0, longTermStartDays = -365, shortTermStartDays = -30) )createTargetBaselineSettings( targetIds, limitToFirstInNDays = 99999, minPriorObservation = 0, covariateSettings = FeatureExtraction::createCovariateSettings(useDemographicsGender = TRUE, useDemographicsAge = TRUE, useDemographicsAgeGroup = TRUE, useDemographicsRace = TRUE, useDemographicsEthnicity = TRUE, useDemographicsIndexYear = TRUE, useDemographicsIndexMonth = TRUE, useDemographicsTimeInCohort = TRUE, useDemographicsPriorObservationTime = TRUE, useDemographicsPostObservationTime = TRUE, useConditionGroupEraLongTerm = TRUE, useDrugGroupEraOverlapping = TRUE, useDrugGroupEraLongTerm = TRUE, useProcedureOccurrenceLongTerm = TRUE, useMeasurementLongTerm = TRUE, useObservationLongTerm = TRUE, useDeviceExposureLongTerm = TRUE, useVisitConceptCountLongTerm = TRUE, useConditionGroupEraShortTerm = TRUE, useDrugGroupEraShortTerm = TRUE, useProcedureOccurrenceShortTerm = TRUE, useMeasurementShortTerm = TRUE, useObservationShortTerm = TRUE, useDeviceExposureShortTerm = TRUE, useVisitConceptCountShortTerm = TRUE, useCharlsonIndex = TRUE, endDays = 0, longTermStartDays = -365, shortTermStartDays = -30) )
targetIds |
A list of cohortIds for the target cohorts |
limitToFirstInNDays |
Whether to remove target cohort entries that occur within limitToFirstInNDays of a prior entry. limitToFirstInNDays = 99999 means limit to first entry. |
minPriorObservation |
The minimum time (in days) in the database a patient in the target cohorts must be observed prior to index |
covariateSettings |
An object created using |
A list with the settings
Other Aggregate:
createCaseSeriesSettings(),
createRiskFactorSettings()
aggregateSetting <- createTargetBaselineSettings( targetIds = c(1,2), limitToFirstInNDays = 99999, minPriorObservation = 365 )aggregateSetting <- createTargetBaselineSettings( targetIds = c(1,2), limitToFirstInNDays = 99999, minPriorObservation = 365 )
Create time to event study settings
createTimeToEventSettings(targetIds, outcomeIds)createTimeToEventSettings(targetIds, outcomeIds)
targetIds |
A list of cohortIds for the target cohorts |
outcomeIds |
A list of cohortIds for the outcome cohorts |
An list with the time to event settings
Other TimeToEvent:
computeTimeToEventAnalyses()
# example code tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 )# example code tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 )
This returns an object of class 'ConnectionDetails' that lets you connect via 'DatabaseConnector::connect()' to the example database.
exampleOmopConnectionDetails(exdir = tempdir())exampleOmopConnectionDetails(exdir = tempdir())
exdir |
a directory to unzip the example OMOP database into. Default is tempdir(). |
Finds the location of the example database in the package and calls 'DatabaseConnector::createConnectionDetails' to create a 'ConnectionDetails' object for connecting to the database.
An object of class 'ConnectionDetails' with the details to connect to the example OHDSI OMOP CDM database
conDet <- exampleOmopConnectionDetails() connectionHandler <- ResultModelManager::ConnectionHandler$new(conDet)conDet <- exampleOmopConnectionDetails() connectionHandler <- ResultModelManager::ConnectionHandler$new(conDet)
Extracts covariates that occur during a cohort
getDbDuringCovariateData( connection, oracleTempSchema = NULL, cdmDatabaseSchema, cdmVersion = "5", cohortTable = "#cohort_person", rowIdField = "subject_id", aggregated = TRUE, cohortIds = c(-1), covariateSettings, minCharacterizationMean = 0, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), targetDatabaseSchema = NULL, targetCovariateTable = NULL, targetCovariateContinuousTable = NULL, targetCovariateRefTable = NULL, targetAnalysisRefTable = NULL, targetTimeRefTable = NULL, ... )getDbDuringCovariateData( connection, oracleTempSchema = NULL, cdmDatabaseSchema, cdmVersion = "5", cohortTable = "#cohort_person", rowIdField = "subject_id", aggregated = TRUE, cohortIds = c(-1), covariateSettings, minCharacterizationMean = 0, tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), targetDatabaseSchema = NULL, targetCovariateTable = NULL, targetCovariateContinuousTable = NULL, targetCovariateRefTable = NULL, targetAnalysisRefTable = NULL, targetTimeRefTable = NULL, ... )
connection |
The database connection |
oracleTempSchema |
The temp schema if using oracle |
cdmDatabaseSchema |
The schema of the OMOP CDM data |
cdmVersion |
version of the OMOP CDM data |
cohortTable |
the table name that contains the target population cohort |
rowIdField |
string representing the unique identifier in the target population cohort |
aggregated |
whether the covariate should be aggregated |
cohortIds |
cohort id for the target cohort |
covariateSettings |
settings for the covariate cohorts and time periods |
minCharacterizationMean |
The minimum mean value for binary characterization output. Values below this will be cut off from output. This will help reduce the file size of the characterization output, but will remove information on covariates that have very low values. The default is 0. |
tempEmulationSchema |
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp tables, provide a schema with write privileges where temp tables can be created |
targetDatabaseSchema |
(Optional) The schema to save the tables targetCovariateTable/targetCovariateContinuousTable/targetCovariateRefTable/targetCovariateRefTable/targetAnalysisRefTable when they are not temp tables and the output is being exported to database tables. |
targetCovariateTable |
(Optional) The name of the table where the resulting binary covariates will
be stored. If not provided, results will be fetched to R. The table can be
a permanent table in the |
targetCovariateContinuousTable |
(Optional) The name of the table where the resulting continuous covariates will
be stored. If not provided, results will be fetched to R. The table can be
a permanent table in the |
targetCovariateRefTable |
(Optional) The name of the table where the covariate reference will be stored. |
targetAnalysisRefTable |
(Optional) The name of the table where the analysis reference will be stored. |
targetTimeRefTable |
(Optional) The name of the table for the time reference |
... |
additional arguments from FeatureExtraction |
The user specifies a what during covariates they want and this executes them using FE
A 'FeatureExtraction' covariateData object containing the during covariates based on user settings
Other CovariateSetting:
createDuringCovariateSettings()
conDet <- exampleOmopConnectionDetails() connection <- DatabaseConnector::connect(conDet) settings <- createDuringCovariateSettings( useConditionOccurrenceDuring = TRUE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE ) duringData <- getDbDuringCovariateData( connection <- connection, cdmDatabaseSchema = 'main', cohortIds = 1, covariateSettings = settings, cohortTable = 'cohort' ) DatabaseConnector::disconnect(connection)conDet <- exampleOmopConnectionDetails() connection <- DatabaseConnector::connect(conDet) settings <- createDuringCovariateSettings( useConditionOccurrenceDuring = TRUE, useConditionOccurrencePrimaryInpatientDuring = FALSE, useConditionEraDuring = FALSE, useConditionGroupEraDuring = FALSE ) duringData <- getDbDuringCovariateData( connection <- connection, cdmDatabaseSchema = 'main', cohortIds = 1, covariateSettings = settings, cohortTable = 'cohort' ) DatabaseConnector::disconnect(connection)
This function uploads results in csv format into a result database
insertResultsToDatabase( connectionDetails, schema, resultsFolder, tablePrefix = "", csvTablePrefix = "c_", includedFiles = NULL )insertResultsToDatabase( connectionDetails, schema, resultsFolder, tablePrefix = "", csvTablePrefix = "c_", includedFiles = NULL )
connectionDetails |
The connection details to the result database |
schema |
The schema for the result database |
resultsFolder |
The folder containing the csv results |
tablePrefix |
A prefix to append to the result tables for the characterization results |
csvTablePrefix |
The prefix added to the csv results - default is 'c_' |
includedFiles |
Specify the csv files to upload or NULL to upload all in directory |
Calls ResultModelManager uploadResults function to upload the csv files
Returns the connection to the sqlite database
Other Database:
createCharacterizationTables(),
createSqliteDatabase()
## generate results into resultsFolder #conDet <- exampleOmopConnectionDetails() #tteSet <- createTimeToEventSettings( #targetIds = c(1,2), # outcomeIds = 3 # ) #cSet <- createCharacterizationSettings( # timeToEventSettings = tteSet #) #runCharacterizationAnalyses( # connectionDetails = conDet, # targetDatabaseSchema = 'main', # targetTable = 'cohort', # outcomeDatabaseSchema = 'main', # outcomeTable = 'cohort', # cdmDatabaseSchema = 'main', # characterizationSettings = cSet, # outputDirectory = file.path(tempdir(),'database') #) ## create sqlite database #charResultDbCD <- createSqliteDatabase() ## create database results tables #createCharacterizationTables( # connectionDetails = charResultDbCD, # resultSchema = 'main' # ) ## insert results #insertResultsToDatabase( # connectionDetails = charResultDbCD, # schema = 'main', # resultsFolder = file.path(tempdir(),'database'), # includedFiles = c('time_to_event') #)## generate results into resultsFolder #conDet <- exampleOmopConnectionDetails() #tteSet <- createTimeToEventSettings( #targetIds = c(1,2), # outcomeIds = 3 # ) #cSet <- createCharacterizationSettings( # timeToEventSettings = tteSet #) #runCharacterizationAnalyses( # connectionDetails = conDet, # targetDatabaseSchema = 'main', # targetTable = 'cohort', # outcomeDatabaseSchema = 'main', # outcomeTable = 'cohort', # cdmDatabaseSchema = 'main', # characterizationSettings = cSet, # outputDirectory = file.path(tempdir(),'database') #) ## create sqlite database #charResultDbCD <- createSqliteDatabase() ## create database results tables #createCharacterizationTables( # connectionDetails = charResultDbCD, # resultSchema = 'main' # ) ## insert results #insertResultsToDatabase( # connectionDetails = charResultDbCD, # schema = 'main', # resultsFolder = file.path(tempdir(),'database'), # includedFiles = c('time_to_event') #)
This function converts the json file back into an R object
loadCharacterizationSettings(fileName)loadCharacterizationSettings(fileName)
fileName |
The location of the the json settings |
Input the directory containing the 'characterizationSettings.json' file and load the settings into R
Returns the json settings as an R object
Other LargeScale:
createCharacterizationSettings(),
runCharacterizationAnalyses(),
saveCharacterizationSettings()
# example code setPath <- file.path(tempdir(), 'charSet.json') drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet ) saveCharacterizationSettings( settings = cSet, fileName = setPath ) setting <- loadCharacterizationSettings(setPath)# example code setPath <- file.path(tempdir(), 'charSet.json') drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet ) saveCharacterizationSettings( settings = cSet, fileName = setPath ) setting <- loadCharacterizationSettings(setPath)
Specify the database connection containing the CDM data, the cohort database schemas/tables, the characterization settings and the directory to save the results to
runCharacterizationAnalyses( connectionDetails, targetDatabaseSchema, targetTable, outcomeDatabaseSchema, outcomeTable, outputDatabaseSchema = targetDatabaseSchema, outputTable = "characterization_cohort", tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cdmDatabaseSchema, characterizationSettings, outputDirectory, executionPath = file.path(outputDirectory, "execution"), csvFilePrefix = "c_", databaseId = "1", showSubjectId = FALSE, minCellCount = 0, incremental = TRUE, threads = 1, cohortGenerationThreads = NULL, nTargetJobs = 1, minCharacterizationMean = 0.001, minCovariateCount = 0, mode = "CohortIncidence", minSMD = 0 )runCharacterizationAnalyses( connectionDetails, targetDatabaseSchema, targetTable, outcomeDatabaseSchema, outcomeTable, outputDatabaseSchema = targetDatabaseSchema, outputTable = "characterization_cohort", tempEmulationSchema = getOption("sqlRenderTempEmulationSchema"), cdmDatabaseSchema, characterizationSettings, outputDirectory, executionPath = file.path(outputDirectory, "execution"), csvFilePrefix = "c_", databaseId = "1", showSubjectId = FALSE, minCellCount = 0, incremental = TRUE, threads = 1, cohortGenerationThreads = NULL, nTargetJobs = 1, minCharacterizationMean = 0.001, minCovariateCount = 0, mode = "CohortIncidence", minSMD = 0 )
connectionDetails |
The connection details to the database containing the OMOP CDM data |
targetDatabaseSchema |
Schema name where your target cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
targetTable |
Name of the target cohort table. |
outcomeDatabaseSchema |
Schema name where your outcome cohort table resides. Note that for SQL Server, this should include both the database and schema name, for example 'scratch.dbo'. |
outcomeTable |
Name of the outcome cohort table. |
outputDatabaseSchema |
The schema where the characterization cohort table will be saved into |
outputTable |
The table name where the characterization cohort table will be saved into |
tempEmulationSchema |
Some database platforms like Oracle and Impala do not truly support temp tables. To emulate temp tables, provide a schema with write privileges where temp tables can be created |
cdmDatabaseSchema |
The schema with the OMOP CDM data |
characterizationSettings |
The study settings created using |
outputDirectory |
The location to save the final csv files to |
executionPath |
The location where intermediate results are saved to |
csvFilePrefix |
A string to append the csv files in the outputDirectory |
databaseId |
The unique identifier for the cdm database |
showSubjectId |
Whether to include subjectId of failed rechallenge case series or hide |
minCellCount |
The minimum count value that is calculated |
incremental |
If TRUE then skip previously executed analyses that completed |
threads |
The number of threads to use when running analyses jobs in parallel |
cohortGenerationThreads |
(optional) The number of threads to use when generating the cohorts in parallel (Note: some database management systems do not allow insert parallelization) |
nTargetJobs |
Partition the targets into this number of groups (e.g., if there are 20 targets and njobs is 5 then there will be 4 targets per job and 5 jobs) |
minCharacterizationMean |
The minimum mean threshold to extract when running aggregate covariates |
minCovariateCount |
The minimum number of patients who must have the covariate when running aggregate covariates |
mode |
Select from Efficient (no exclusions to target based on washout)/CohortIncidence (excludes targets with outcome in washout if they have no time at risk)/PatientLevelPrediction (excludes targets with outcome during washout prior to index) |
minSMD |
The minimum standardized mean difference for the risk factor analysis |
The results of the characterization will be saved into an sqlite database inside the specified saveDirectory
Multiple csv files in the outputDirectory.
Other LargeScale:
createCharacterizationSettings(),
loadCharacterizationSettings(),
saveCharacterizationSettings()
conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( timeToEventSettings = tteSet ) runCharacterizationAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', outcomeDatabaseSchema = 'main', outcomeTable = 'cohort', cdmDatabaseSchema = 'main', characterizationSettings = cSet, outputDirectory = file.path(tempdir(),'runChar') )conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( timeToEventSettings = tteSet ) runCharacterizationAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', outcomeDatabaseSchema = 'main', outcomeTable = 'cohort', cdmDatabaseSchema = 'main', characterizationSettings = cSet, outputDirectory = file.path(tempdir(),'runChar') )
This function converts the settings into a json object and saves it
saveCharacterizationSettings(settings, fileName)saveCharacterizationSettings(settings, fileName)
settings |
An object of class characterizationSettings created using |
fileName |
The location to save the json settings |
Input the characterization settings and output a json file to a file named 'characterizationSettings.json' inside the saveDirectory
Returns the location of the directory containing the json settings
Other LargeScale:
createCharacterizationSettings(),
loadCharacterizationSettings(),
runCharacterizationAnalyses()
drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet ) saveCharacterizationSettings( settings = cSet, fileName = file.path(tempdir(), 'cSet.json') )drSet <- createDechallengeRechallengeSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( dechallengeRechallengeSettings = drSet ) saveCharacterizationSettings( settings = cSet, fileName = file.path(tempdir(), 'cSet.json') )
This is a shiny app for viewing interactive plots and tables
viewCharacterization(resultFolder, cohortDefinitionSet = NULL)viewCharacterization(resultFolder, cohortDefinitionSet = NULL)
resultFolder |
The location of the csv results |
cohortDefinitionSet |
The cohortDefinitionSet extracted using webAPI |
Input is the output of ...
Opens a shiny app for interactively viewing the results
conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( timeToEventSettings = tteSet ) runCharacterizationAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', outcomeDatabaseSchema = 'main', outcomeTable = 'cohort', cdmDatabaseSchema = 'main', characterizationSettings = cSet, outputDirectory = file.path(tempdir(),'view') ) # interactive shiny app ## Not run: viewCharacterization( resultFolder = file.path(tempdir(),'view') ) ## End(Not run)conDet <- exampleOmopConnectionDetails() tteSet <- createTimeToEventSettings( targetIds = c(1,2), outcomeIds = 3 ) cSet <- createCharacterizationSettings( timeToEventSettings = tteSet ) runCharacterizationAnalyses( connectionDetails = conDet, targetDatabaseSchema = 'main', targetTable = 'cohort', outcomeDatabaseSchema = 'main', outcomeTable = 'cohort', cdmDatabaseSchema = 'main', characterizationSettings = cSet, outputDirectory = file.path(tempdir(),'view') ) # interactive shiny app ## Not run: viewCharacterization( resultFolder = file.path(tempdir(),'view') ) ## End(Not run)