Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CohortDiagnostics and FeatureExtraction cohortCovaraite branch #1039

Open
gowthamrao opened this issue Mar 21, 2023 · 2 comments
Open

CohortDiagnostics and FeatureExtraction cohortCovaraite branch #1039

gowthamrao opened this issue Mar 21, 2023 · 2 comments

Comments

@gowthamrao
Copy link
Member

gowthamrao commented Mar 21, 2023

I am testing the functionality using the code below

remotes::install_github("OHDSI/FeatureExtraction", ref = "cohortCovariates")
remotes::install_github("OHDSI/SkeletonCohortDiagnostics")
remotes::install_github('OHDSI/Eunomia')

connectionDetails <- Eunomia::getEunomiaConnectionDetails()
databaseId = "Eunomia"
databaseName = "Eunomia Test"
databaseDescription = "This is a test data base called Eunomia"
cdmDatabaseSchema = 'main'
vocabularyDatabaseSchema = "main"
cohortDatabaseSchema = "main"
tempEmulationSchema = getOption("sqlRenderTempEmulationSchema")

# Cohort Definitions ----
remotes::install_github('OHDSI/SkeletonCohortDiagnosticsStudy')

## get cohort definition set ----
cohortDefinitionSet <-
  CohortGenerator::getCohortDefinitionSet(
    settingsFileName = "settings/CohortsToCreate.csv",
    jsonFolder = "cohorts",
    sqlFolder = "sql/sql_server",
    packageName = "SkeletonCohortDiagnosticsStudy",
    cohortFileNameValue = "cohortId"
  ) |>  dplyr::tibble()


featureCohortIds <- c(14907)
cohortTableNames = CohortGenerator::getCohortTableNames(cohortTable = "cohortEunomia")

# output folder information ----
outputFolder <-
  file.path("D:", "temp", "outputFolder", "eunomia")

## optionally delete previous execution ----
unlink(x = outputFolder,
       recursive = TRUE,
       force = TRUE)
dir.create(path = outputFolder,
           showWarnings = FALSE,
           recursive = TRUE)

# Execution ----
## Create cohort tables on remote ----
CohortGenerator::createCohortTables(
  connectionDetails = connectionDetails,
  cohortDatabaseSchema = cohortDatabaseSchema,
  cohortTableNames = cohortTableNames,
  incremental = TRUE
)
## Generate cohort on remote ----
CohortGenerator::generateCohortSet(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = cdmDatabaseSchema,
  tempEmulationSchema = tempEmulationSchema,
  cohortTableNames = cohortTableNames,
  cohortDefinitionSet = cohortDefinitionSet,
  cohortDatabaseSchema = cohortDatabaseSchema,
  incremental = TRUE,
  incrementalFolder = file.path(outputFolder, "incremental")
)

FeatureExtractionSettingsCohortDiagnostics <-
  CohortDiagnostics::getDefaultCovariateSettings()

FeatureExtractionSettingsCohortBasedCovariateSettings <-
  FeatureExtraction::createCohortBasedTemporalCovariateSettings(
    analysisId = 150,
    covariateCohortDatabaseSchema = cohortDatabaseSchema,
    covariateCohortTable = cohortTableNames$cohortTable,
    covariateCohorts = cohortDefinitionSet |> 
      dplyr::filter(cohortId %in% c(featureCohortIds)) |>
      dplyr::select(cohortId,
                    cohortName),
    valueType = "binary",
    temporalStartDays = FeatureExtractionSettingsCohortDiagnostics$temporalStartDays,
    temporalEndDays = FeatureExtractionSettingsCohortDiagnostics$temporalEndDays
  )
FeatureExtractionCovariateSettings <- 
  list(
    FeatureExtractionSettingsCohortBasedCovariateSettings,
    FeatureExtractionSettingsCohortDiagnostics
  )

CohortDiagnostics::executeDiagnostics(
  cohortDefinitionSet = cohortDefinitionSet,
  exportFolder = outputFolder,
  databaseId = databaseId,
  databaseName = databaseName,
  databaseDescription = databaseDescription,
  cohortDatabaseSchema = cohortDatabaseSchema,
  cdmDatabaseSchema = cdmDatabaseSchema,
  tempEmulationSchema = tempEmulationSchema,
  connectionDetails = connectionDetails,
  cohortTableNames = cohortTableNames,
  runIncidenceRate = FALSE,
  runCohortRelationship = FALSE,
  vocabularyDatabaseSchema = vocabularyDatabaseSchema,
  temporalCovariateSettings = FeatureExtractionCovariateSettings,
  incremental = TRUE
)



# package results ----
CohortDiagnostics::createMergedResultsFile(dataFolder = outputFolder, overwrite = TRUE)
# Launch diagnostics explorer shiny app ----
CohortDiagnostics::launchDiagnosticsExplorer()

@gowthamrao gowthamrao changed the title CohortDiagnostics does not seem to support characterization output from FeatureExtraction cohortCovaraite branch CohortDiagnostics and FeatureExtraction cohortCovaraite branch Mar 21, 2023
@gowthamrao
Copy link
Member Author

gowthamrao commented Mar 21, 2023

Notice - two 'cohort' in the drop down

image

@gowthamrao
Copy link
Member Author

@azimov now that FeatureExtraction release has CohortCovariates, we can think of CohortRelationship/CohortOverlap also an output of FeatureExtraction. Here - all other cohorts are features - with time window -99999 to 99999.

@azimov azimov added the v3.4.0 label Oct 1, 2024
@azimov azimov added this to the Release version 3.4.0 milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants