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

Cohort Diagnostics strategus json execution fails #113

Open
ablack3 opened this issue Nov 9, 2024 · 2 comments
Open

Cohort Diagnostics strategus json execution fails #113

ablack3 opened this issue Nov 9, 2024 · 2 comments

Comments

@ablack3
Copy link
Collaborator

ablack3 commented Nov 9, 2024

I tried running cohort diagnostics using strategus and the execution failed.

Steps to reproduce the issue.

Generate the cohort diagnostics json specification with this R code

remotes::install_github("ohdsi/Strategus") # install the current release of Strategus
#> Skipping install of 'Strategus' from a github remote, the SHA1 (612859f3) has not changed since last install.
#>   Use `force = TRUE` to force installation

library(Strategus)
#> Loading required package: CohortGenerator
#> Loading required package: DatabaseConnector
#> Loading required package: R6
#> 
#> Attaching package: 'Strategus'
#> The following object is masked from 'package:CohortGenerator':
#> 
#>     uploadResults

cohortDefinitionSet <- CohortGenerator::getCohortDefinitionSet(
    settingsFileName = "testdata/Cohorts.csv",
    jsonFolder = "testdata/cohorts",
    sqlFolder = "testdata/sql",
    packageName = "Strategus"
)
#> Loading cohortDefinitionSet

ncoCohortSet <- CohortGenerator::readCsv(file = system.file("testdata/negative_controls_concept_set.csv",
                                                            package = "Strategus"
))

cgModule <- CohortGeneratorModule$new()

cohortDefinitionSharedResource <- cgModule$createCohortSharedResourceSpecifications(
    cohortDefinitionSet = cohortDefinitionSet
)


cohortGeneratorModuleSpecifications <- cgModule$createModuleSpecifications(
    generateStats = TRUE
)

cdModule <- CohortDiagnosticsModule$new()

cohortDiagnosticsModuleSpecifications <- cdModule$createModuleSpecifications(
    runInclusionStatistics = TRUE,
    runIncludedSourceConcepts = TRUE,
    runOrphanConcepts = TRUE,
    runTimeSeries = FALSE,
    runVisitContext = TRUE,
    runBreakdownIndexEvents = TRUE,
    runIncidenceRate = TRUE,
    runCohortRelationship = TRUE,
    runTemporalCohortCharacterization = TRUE
)

analysisSpecifications <- createEmptyAnalysisSpecificiations() |>
    addSharedResources(cohortDefinitionSharedResource) |>
    addModuleSpecifications(cohortGeneratorModuleSpecifications) |>
    addModuleSpecifications(cohortDiagnosticsModuleSpecifications) 

ParallelLogger::saveSettingsToJson(analysisSpecifications, "cohortDiagnosticsAnalysis.json")

Created on 2024-11-09 with reprex v2.1.1

The json this code generates is below:

{
  "sharedResources": [
    {
      "cohortDefinitions": [
        {
          "cohortId": 1,
          "cohortName": "Celecoxib",
          "cohortDefinition": "{\n\t\"cdmVersionRange\" : \">=5.0.0\",\n\t\"PrimaryCriteria\" : {\n\t\t\"CriteriaList\" : [\n\t\t\t{\n\t\t\t\t\"DrugEra\" : {\n\t\t\t\t\t\"CodesetId\" : 0\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t\"ObservationWindow\" : {\n\t\t\t\"PriorDays\" : 0,\n\t\t\t\"PostDays\" : 0\n\t\t},\n\t\t\"PrimaryCriteriaLimit\" : {\n\t\t\t\"Type\" : \"First\"\n\t\t}\n\t},\n\t\"ConceptSets\" : [\n\t\t{\n\t\t\t\"id\" : 0,\n\t\t\t\"name\" : \"Celecoxib\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"items\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"concept\" : {\n\t\t\t\t\t\t\t\"CONCEPT_ID\" : 1118084,\n\t\t\t\t\t\t\t\"CONCEPT_NAME\" : \"celecoxib\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT\" : \"S\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT_CAPTION\" : \"Standard\",\n\t\t\t\t\t\t\t\"INVALID_REASON\" : \"V\",\n\t\t\t\t\t\t\t\"INVALID_REASON_CAPTION\" : \"Valid\",\n\t\t\t\t\t\t\t\"CONCEPT_CODE\" : \"140587\",\n\t\t\t\t\t\t\t\"DOMAIN_ID\" : \"Drug\",\n\t\t\t\t\t\t\t\"VOCABULARY_ID\" : \"RxNorm\",\n\t\t\t\t\t\t\t\"CONCEPT_CLASS_ID\" : \"Ingredient\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"isExcluded\" : false,\n\t\t\t\t\t\t\"includeDescendants\" : false,\n\t\t\t\t\t\t\"includeMapped\" : false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"QualifiedLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"ExpressionLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"InclusionRules\" : [],\n\t\"EndStrategy\" : {\n\t\t\"CustomEra\" : {\n\t\t\t\"DrugCodesetId\" : 0,\n\t\t\t\"GapDays\" : 30,\n\t\t\t\"Offset\" : 0\n\t\t}\n\t},\n\t\"CensoringCriteria\" : [],\n\t\"CollapseSettings\" : {\n\t\t\"CollapseType\" : \"ERA\",\n\t\t\"EraPad\" : 0\n\t},\n\t\"CensorWindow\" : {}\n}"
        },
        {
          "cohortId": 2,
          "cohortName": "Diclofenac",
          "cohortDefinition": "{\n\t\"cdmVersionRange\" : \">=5.0.0\",\n\t\"PrimaryCriteria\" : {\n\t\t\"CriteriaList\" : [\n\t\t\t{\n\t\t\t\t\"DrugEra\" : {\n\t\t\t\t\t\"CodesetId\" : 0\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t\"ObservationWindow\" : {\n\t\t\t\"PriorDays\" : 0,\n\t\t\t\"PostDays\" : 0\n\t\t},\n\t\t\"PrimaryCriteriaLimit\" : {\n\t\t\t\"Type\" : \"First\"\n\t\t}\n\t},\n\t\"ConceptSets\" : [\n\t\t{\n\t\t\t\"id\" : 0,\n\t\t\t\"name\" : \"Diclofenac\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"items\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"concept\" : {\n\t\t\t\t\t\t\t\"CONCEPT_ID\" : 1124300,\n\t\t\t\t\t\t\t\"CONCEPT_NAME\" : \"diclofenac\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT\" : \"S\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT_CAPTION\" : \"Standard\",\n\t\t\t\t\t\t\t\"INVALID_REASON\" : \"V\",\n\t\t\t\t\t\t\t\"INVALID_REASON_CAPTION\" : \"Valid\",\n\t\t\t\t\t\t\t\"CONCEPT_CODE\" : \"3355\",\n\t\t\t\t\t\t\t\"DOMAIN_ID\" : \"Drug\",\n\t\t\t\t\t\t\t\"VOCABULARY_ID\" : \"RxNorm\",\n\t\t\t\t\t\t\t\"CONCEPT_CLASS_ID\" : \"Ingredient\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"isExcluded\" : false,\n\t\t\t\t\t\t\"includeDescendants\" : false,\n\t\t\t\t\t\t\"includeMapped\" : false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"QualifiedLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"ExpressionLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"InclusionRules\" : [],\n\t\"EndStrategy\" : {\n\t\t\"CustomEra\" : {\n\t\t\t\"DrugCodesetId\" : 0,\n\t\t\t\"GapDays\" : 30,\n\t\t\t\"Offset\" : 0\n\t\t}\n\t},\n\t\"CensoringCriteria\" : [],\n\t\"CollapseSettings\" : {\n\t\t\"CollapseType\" : \"ERA\",\n\t\t\"EraPad\" : 0\n\t},\n\t\"CensorWindow\" : {}\n}"
        },
        {
          "cohortId": 3,
          "cohortName": "GI bleed",
          "cohortDefinition": "{\n\t\"cdmVersionRange\" : \">=5.0.0\",\n\t\"PrimaryCriteria\" : {\n\t\t\"CriteriaList\" : [\n\t\t\t{\n\t\t\t\t\"ConditionOccurrence\" : {\n\t\t\t\t\t\"CodesetId\" : 0,\n\t\t\t\t\t\"ConditionTypeExclude\" : false\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t\"ObservationWindow\" : {\n\t\t\t\"PriorDays\" : 0,\n\t\t\t\"PostDays\" : 0\n\t\t},\n\t\t\"PrimaryCriteriaLimit\" : {\n\t\t\t\"Type\" : \"All\"\n\t\t}\n\t},\n\t\"ConceptSets\" : [\n\t\t{\n\t\t\t\"id\" : 0,\n\t\t\t\"name\" : \"GI bleed\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"items\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"concept\" : {\n\t\t\t\t\t\t\t\"CONCEPT_ID\" : 192671,\n\t\t\t\t\t\t\t\"CONCEPT_NAME\" : \"Gastrointestinal hemorrhage\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT\" : \"S\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT_CAPTION\" : \"Standard\",\n\t\t\t\t\t\t\t\"INVALID_REASON\" : \"V\",\n\t\t\t\t\t\t\t\"INVALID_REASON_CAPTION\" : \"Valid\",\n\t\t\t\t\t\t\t\"CONCEPT_CODE\" : \"74474003\",\n\t\t\t\t\t\t\t\"DOMAIN_ID\" : \"Condition\",\n\t\t\t\t\t\t\t\"VOCABULARY_ID\" : \"SNOMED\",\n\t\t\t\t\t\t\t\"CONCEPT_CLASS_ID\" : \"Clinical Finding\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"isExcluded\" : false,\n\t\t\t\t\t\t\"includeDescendants\" : true,\n\t\t\t\t\t\t\"includeMapped\" : false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"QualifiedLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"ExpressionLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"InclusionRules\" : [],\n\t\"EndStrategy\" : {\n\t\t\"DateOffset\" : {\n\t\t\t\"DateField\" : \"StartDate\",\n\t\t\t\"Offset\" : 0\n\t\t}\n\t},\n\t\"CensoringCriteria\" : [],\n\t\"CollapseSettings\" : {\n\t\t\"CollapseType\" : \"ERA\",\n\t\t\"EraPad\" : 0\n\t},\n\t\"CensorWindow\" : {}\n}"
        },
        {
          "cohortId": 4,
          "cohortName": "Celecoxib age 30 or older",
          "cohortDefinition": "{\n\t\"cdmVersionRange\" : \">=5.0.0\",\n\t\"PrimaryCriteria\" : {\n\t\t\"CriteriaList\" : [\n\t\t\t{\n\t\t\t\t\"DrugEra\" : {\n\t\t\t\t\t\"CodesetId\" : 0\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t\"ObservationWindow\" : {\n\t\t\t\"PriorDays\" : 0,\n\t\t\t\"PostDays\" : 0\n\t\t},\n\t\t\"PrimaryCriteriaLimit\" : {\n\t\t\t\"Type\" : \"First\"\n\t\t}\n\t},\n\t\"ConceptSets\" : [\n\t\t{\n\t\t\t\"id\" : 0,\n\t\t\t\"name\" : \"Celecoxib\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"items\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"concept\" : {\n\t\t\t\t\t\t\t\"CONCEPT_ID\" : 1118084,\n\t\t\t\t\t\t\t\"CONCEPT_NAME\" : \"celecoxib\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT\" : \"S\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT_CAPTION\" : \"Standard\",\n\t\t\t\t\t\t\t\"INVALID_REASON\" : \"V\",\n\t\t\t\t\t\t\t\"INVALID_REASON_CAPTION\" : \"Valid\",\n\t\t\t\t\t\t\t\"CONCEPT_CODE\" : \"140587\",\n\t\t\t\t\t\t\t\"DOMAIN_ID\" : \"Drug\",\n\t\t\t\t\t\t\t\"VOCABULARY_ID\" : \"RxNorm\",\n\t\t\t\t\t\t\t\"CONCEPT_CLASS_ID\" : \"Ingredient\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"isExcluded\" : false,\n\t\t\t\t\t\t\"includeDescendants\" : false,\n\t\t\t\t\t\t\"includeMapped\" : false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"QualifiedLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"ExpressionLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"InclusionRules\" : [\n\t\t{\n\t\t\t\"name\" : \"Age >= 30\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"Type\" : \"ALL\",\n\t\t\t\t\"CriteriaList\" : [],\n\t\t\t\t\"DemographicCriteriaList\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"Age\" : {\n\t\t\t\t\t\t\t\"Value\" : 30,\n\t\t\t\t\t\t\t\"Op\" : \"gte\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"Groups\" : []\n\t\t\t}\n\t\t}\n\t],\n\t\"EndStrategy\" : {\n\t\t\"CustomEra\" : {\n\t\t\t\"DrugCodesetId\" : 0,\n\t\t\t\"GapDays\" : 30,\n\t\t\t\"Offset\" : 0\n\t\t}\n\t},\n\t\"CensoringCriteria\" : [],\n\t\"CollapseSettings\" : {\n\t\t\"CollapseType\" : \"ERA\",\n\t\t\"EraPad\" : 0\n\t},\n\t\"CensorWindow\" : {}\n}"
        },
        {
          "cohortId": 5,
          "cohortName": "Diclofenac age 30 or older",
          "cohortDefinition": "{\n\t\"cdmVersionRange\" : \">=5.0.0\",\n\t\"PrimaryCriteria\" : {\n\t\t\"CriteriaList\" : [\n\t\t\t{\n\t\t\t\t\"DrugEra\" : {\n\t\t\t\t\t\"CodesetId\" : 0\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\t\"ObservationWindow\" : {\n\t\t\t\"PriorDays\" : 0,\n\t\t\t\"PostDays\" : 0\n\t\t},\n\t\t\"PrimaryCriteriaLimit\" : {\n\t\t\t\"Type\" : \"First\"\n\t\t}\n\t},\n\t\"ConceptSets\" : [\n\t\t{\n\t\t\t\"id\" : 0,\n\t\t\t\"name\" : \"Diclofenac\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"items\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"concept\" : {\n\t\t\t\t\t\t\t\"CONCEPT_ID\" : 1124300,\n\t\t\t\t\t\t\t\"CONCEPT_NAME\" : \"diclofenac\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT\" : \"S\",\n\t\t\t\t\t\t\t\"STANDARD_CONCEPT_CAPTION\" : \"Standard\",\n\t\t\t\t\t\t\t\"INVALID_REASON\" : \"V\",\n\t\t\t\t\t\t\t\"INVALID_REASON_CAPTION\" : \"Valid\",\n\t\t\t\t\t\t\t\"CONCEPT_CODE\" : \"3355\",\n\t\t\t\t\t\t\t\"DOMAIN_ID\" : \"Drug\",\n\t\t\t\t\t\t\t\"VOCABULARY_ID\" : \"RxNorm\",\n\t\t\t\t\t\t\t\"CONCEPT_CLASS_ID\" : \"Ingredient\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"isExcluded\" : false,\n\t\t\t\t\t\t\"includeDescendants\" : false,\n\t\t\t\t\t\t\"includeMapped\" : false\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t],\n\t\"QualifiedLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"ExpressionLimit\" : {\n\t\t\"Type\" : \"First\"\n\t},\n\t\"InclusionRules\" : [\n\t\t{\n\t\t\t\"name\" : \"Age >= 30\",\n\t\t\t\"expression\" : {\n\t\t\t\t\"Type\" : \"ALL\",\n\t\t\t\t\"CriteriaList\" : [],\n\t\t\t\t\"DemographicCriteriaList\" : [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"Age\" : {\n\t\t\t\t\t\t\t\"Value\" : 30,\n\t\t\t\t\t\t\t\"Op\" : \"gte\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"Groups\" : []\n\t\t\t}\n\t\t}\n\t],\n\t\"EndStrategy\" : {\n\t\t\"CustomEra\" : {\n\t\t\t\"DrugCodesetId\" : 0,\n\t\t\t\"GapDays\" : 30,\n\t\t\t\"Offset\" : 0\n\t\t}\n\t},\n\t\"CensoringCriteria\" : [],\n\t\"CollapseSettings\" : {\n\t\t\"CollapseType\" : \"ERA\",\n\t\t\"EraPad\" : 0\n\t},\n\t\"CensorWindow\" : {}\n}"
        }
      ],
      "attr_class": ["CohortDefinitionSharedResources", "SharedResources"]
    }
  ],
  "moduleSpecifications": [
    {
      "module": "CohortGeneratorModule",
      "settings": {
        "generateStats": true
      },
      "attr_class": ["ModuleSpecifications", "CohortGeneratorModuleSpecifications"]
    },
    {
      "module": "CohortDiagnosticsModule",
      "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"
        },
        "minCharacterizationMean": 0.01,
        "irWashoutPeriod": 0
      },
      "attr_class": ["ModuleSpecifications", "CohortDiagnosticsModuleSpecifications"]
    }
  ],
  "attr_class": "AnalysisSpecifications"
}

Then I uploaded this json file to https://testnodestandalone.arachnenetwork.com/
image

image

Do we need a docker image with Strategus installed?
tagging @anthonysena, @konstjar

@konstjar
Copy link
Contributor

konstjar commented Nov 9, 2024

@ablack3 Thank you for this example and details. Yes, we do not have yet ready R environment image for Strategus v1.0
We have this ticket opened #84 and targeted for November release.

@anthonysena
Copy link
Contributor

@konstjar @ablack3 I'd recommend that for the next R environment for Strategus that you look at the new repository template that is now available on https://github.com/ohdsi-studies/StrategusStudyRepoTemplate. This is using the latest HADES-wide lock file and will work best with R 4.4.1. The renv.lock file contains the dependencies, including those needed for PLP via Python.

The documentation is here: https://github.com/ohdsi-studies/StrategusStudyRepoTemplate/blob/main/template_docs/UsingThisTemplate.md. Feel free to reach out with any questions/concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants