OHDSI / Strategus

[Under development] An R packages for coordinating and executing analytics using HADES modules
https://ohdsi.github.io/Strategus/
7 stars 11 forks source link

Error seen running CohortDiagnosticModule using Broadsea #123

Closed greshje closed 2 months ago

greshje commented 7 months ago

Running Cohort Diagnostics using the attached study gives the error shown below. Full output and log file are attached.

Study specification: StrategusSpecification-CovidHomeless-2024-02-11.json

Snipped from study:


    {
      "module": "CohortDiagnosticsModule",
      "version": "0.2.0",
      "remoteRepo": "github.com",
      "remoteUsername": "ohdsi",
      "settings": {
        "runInclusionStatistics": true,
        "runIncludedSourceConcepts": true,
        "runOrphanConcepts": true,
        "runTimeSeries": false,
        "runVisitContext": true,
        "runBreakdownIndexEvents": true,
        "runIncidenceRate": true,
        "runCohortRelationship": true,
        "runTemporalCohortCharacterization": true,
        "temporalCovariateSettings": {
          "temporal": true,
          "temporalSequence": false,
          "DemographicsGender": true,
          "DemographicsAge": true,
          "DemographicsAgeGroup": true,
          "DemographicsRace": true,
          "DemographicsEthnicity": true,
          "DemographicsIndexYear": true,
          "DemographicsIndexMonth": true,
          "DemographicsPriorObservationTime": true,
          "DemographicsPostObservationTime": true,
          "DemographicsTimeInCohort": true,
          "DemographicsIndexYearMonth": true,
          "ConditionOccurrence": true,
          "ConditionEraStart": true,
          "ConditionEraOverlap": true,
          "ConditionEraGroupOverlap": true,
          "DrugEraStart": true,
          "DrugEraGroupOverlap": true,
          "ProcedureOccurrence": true,
          "DeviceExposure": true,
          "Measurement": true,
          "Observation": true,
          "CharlsonIndex": true,
          "Dcsi": true,
          "Chads2": true,
          "Chads2Vasc": true,
          "temporalStartDays": [-9999, -365, -180, -30, -365, -30, 0, 1, 31, -9999],
          "temporalEndDays": [0, 0, 0, 0, -31, -1, 0, 30, 365, 9999],
          "includedCovariateConceptIds": [],
          "addDescendantsToInclude": false,
          "excludedCovariateConceptIds": [],
          "addDescendantsToExclude": false,
          "includedCovariateIds": [],
          "attr_class": "covariateSettings",
          "attr_fun": "getDbDefaultCovariateData"
        }

Error message (full output and log file attached):

output.txt

errorReport.R.txt

errorReportR.txt


▶ dispatched target CharacterizationModule_3
● completed target CharacterizationModule_3 [8.84 seconds]
▶ dispatched target CohortDiagnosticsModule_2
MODULE READY!ule: CohortDiagnosticsModule, (0.2.0) at C:/temp/ergasia/_MODULES/CohortDiagnosticsModule_0.2.0...
- The project is out-of-sync -- use `renv::status()` for details.
Loading required package: DatabaseConnector
Loading required package: R6
Creating cohort definition set from job context
Executing cohort diagnostics
Run Cohort Diagnostics started at 2024-02-11 12:09:19
Connecting using PostgreSQL driver
Saving database metadata
Saving database metadata took 0.0423 secs
Counting cohort records and subjects
Counting cohorts took 0.0762 secs
- Censoring 0 values (0%) from cohortEntries because value below minimum
- Censoring 0 values (0%) from cohortSubjects because value below minimum
Found 0 of 3 (0.00%) submitted cohorts instantiated. Beginning cohort diagnostics for instantiated cohorts. 
Fetching inclusion statistics from files
Exporting cohort concept sets to csv
 - Unexpected fields found in table concept_sets - databaseId. These fields will be ignored.
Starting concept set diagnostics
Instantiating concept sets
  |======================================================================| 100%
Creating internal concept counts table
  |======================================================================| 100%
Executing SQL took 0.179 secs
Fetching included source concepts
  |======================================================================| 100%
Executing SQL took 0.0402 secs
Finding source codes took 0.472 secs
Breaking down index events
- Breaking down index events for cohort 'Homeless'
- Breaking down index events for cohort 'Not Homeless'
- Breaking down index events for cohort 'Vaccinated'
An error report has been created at  C:\temp\ergasia\EUNOMIA\EUNOMIA_RESULTS\strategusOutput/CohortDiagnosticsModule_2/errorReport.R
An error report has been created at  C:\temp\ergasia\EUNOMIA\EUNOMIA_RESULTS\strategusOutput\CohortDiagnosticsModule_2/errorReportR.txt
Error in makeDataExportable(x = data, tableName = "index_event_breakdown",  : 
   - Cannot find required field index_event_breakdown - conceptId, conceptCount, subjectCount, cohortId, domainField, domainTable.
Calls: execute ... eval -> runConceptSetDiagnostics -> makeDataExportable
In addition: Warning messages:
1: There were 2 warnings in `dplyr::summarise()`.
The first warning was:
ℹ In argument: `conceptCount = max(.data$conceptCount)`.
Caused by warning in `max()`:
! no non-missing arguments to max; returning -Inf
ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning. 
2: In eval(expr) :
  No primary event criteria concept sets found for cohort id: 1
3: In eval(expr) :
  No primary event criteria concept sets found for cohort id: 2
4: In eval(expr) :
  No primary event criteria concept sets found for cohort id: 3
Execution halted
✖ errored target CohortDiagnosticsModule_2
▶ completed pipeline [2.019 hours]
Error:
! Error running targets::tar_make()
Error messages: targets::tar_meta(fields = error, complete_only = TRUE)
Debugging guide: https://books.ropensci.org/targets/debugging.html
How to ask for help: https://books.ropensci.org/targets/help.html
Last error message:
    Module did not complete. To debug:
  rstudioapi::openProject('C:/temp/ergasia/_MODULES/CohortDiagnosticsModule_0.2.0', newSession = TRUE)
  file.edit('C:/temp/ergasia/EUNOMIA/EUNOMIA_RESULTS/strategusWork/CohortDiagnosticsModule_2/StrategusScript.R')
Last error traceback:
    Strategus:::runModule(analysisSpecifications, keyringSettings,      2L, ...
    stop(message)
    .handleSimpleError(function (condition)  {     state$error <- build_mess...
    h(simpleError(msg, call))

Steps to reproduce: Install and start Broadsea v3.0.0

Run attached study or clone and check out full example at https://github.com/greshje/ergasia Commit: 4bb3ddf267718eddce488a80278c4fc0e566904b

Run ./_StartHere/Bootstrap/Bootstrap.R Run ./_StartHere/01-RunStudies.R

The following versions are being used:


    StrategusRunnerLibUtil$installFromCran("remotes", "2.4.2.1")
    StrategusRunnerLibUtil$installFromCran("keyring", "1.3.1")
    StrategusRunnerLibUtil$installFromCran("usethis", "2.2.2")
    StrategusRunnerLibUtil$installFromCran("dplyr", "1.1.4")
    StrategusRunnerLibUtil$installFromCran("R6", "2.5.1")
    StrategusRunnerLibUtil$installFromCran("DatabaseConnector", "6.2.4")
    StrategusRunnerLibUtil$installFromCran("knitr", "1.45")
    # added for develop version of strategus
    StrategusRunnerLibUtil$installFromCran("aws.s3", "0.3.21")
    StrategusRunnerLibUtil$installFromCran("ellipsis", "0.3.2")
    StrategusRunnerLibUtil$installFromCran("markdown", "1.12")

    # installs from github
    StrategusRunnerLibUtil$installFromGithub("OHDSI/Strategus", "v0.2.1")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/Characterization", "v0.1.3")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/CohortDiagnostics", "v3.2.5")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/CohortGenerator", "v0.8.1")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/CohortIncidence", "v3.3.0")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/CohortMethod", "v5.2.0")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/PatientLevelPrediction", "v6.3.6")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/SelfControlledCaseSeries", "v5.1.1")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/EvidenceSynthesis", "v0.5.0")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/CirceR", "v1.3.1")
    StrategusRunnerLibUtil$installFromGithub("OHDSI/Eunomia", "v1.0.2")    
    StrategusRunnerLibUtil$installFromGithub("OHDSI/OhdsiShinyModules", "v2.0.2")    
    StrategusRunnerLibUtil$installFromGithub("OHDSI/ShinyAppBuilder", "v2.0.0")    
    StrategusRunnerLibUtil$installFromGithub("OHDSI/SqlRender", "v1.16.1")    

The following versions are being used by Strategus:


> Strategus::getModuleList()
# A tibble: 8 × 7                                                                                                                                  
  module                         version remoteRepo remoteUsername moduleType mainPackage              mainPackageTag
  <chr>                          <chr>   <chr>      <chr>          <chr>      <chr>                    <chr>         
1 CharacterizationModule         v0.5.0  github.com OHDSI          cdm        Characterization         v0.1.3        
2 CohortDiagnosticsModule        v0.2.0  github.com OHDSI          cdm        CohortDiagnostics        v3.2.5        
3 CohortGeneratorModule          v0.3.0  github.com OHDSI          cdm        CohortGenerator          v0.8.1        
4 CohortIncidenceModule          v0.4.0  github.com OHDSI          cdm        CohortIncidence          v3.3.0        
5 CohortMethodModule             v0.3.0  github.com OHDSI          cdm        CohortMethod             v5.2.0        
6 PatientLevelPredictionModule   v0.3.0  github.com OHDSI          cdm        PatientLevelPrediction   v6.3.6        
7 SelfControlledCaseSeriesModule v0.4.1  github.com OHDSI          cdm        SelfControlledCaseSeries v5.1.1        
8 EvidenceSynthesisModule        v0.6.0  github.com OHDSI          results    EvidenceSynthesis        v0.5.0        
> 
anthonysena commented 7 months ago

Hi @greshje - can you confirm that your cohorts have people in them? Just looking at the log and see the following:

Found 0 of 3 (0.00%) submitted cohorts instantiated. Beginning cohort diagnostics for instantiated cohorts.

I can see from the logs that the cohorts were created via CohortGenerator but suspect they have 0 people based on the message above which may be why diagnostics are failing.

greshje commented 7 months ago

The cohorts I'm looking at are probably empty. I'm running the study against the Eunomia database as a smoke test using a study based on my very specific data. I'll come up with a more reasonable test case for the Eunomia data.

It might be a nice-to-have to echo to the output that there are no patients in the cohort therefore cohort diagnostics is not tenable, or maybe have a simple fail case that is the zero-matching-patients diagnosis that is propigated to the reporting and completes successfully.

anthonysena commented 2 months ago

Such a message for empty cohorts would need to come from CohortDiagnostics. I'm going to close this out but if needed we can open an issue in CohortDiagnostics to add this type of messaging where needed. Thanks!