OHDSI / CohortDiagnostics

An R package for performing various cohort diagnostics.
https://ohdsi.github.io/CohortDiagnostics
40 stars 45 forks source link

$ operator is invalid for atomic vectors #1118

Open ablack3 opened 3 weeks ago

ablack3 commented 3 weeks ago

I'm running cohort diagnostics (current OHDSI main branch) and getting the following error.

Thread: Main Message: $ operator is invalid for atomic vectors Level: FATAL Time: 2024-06-06 12:36:18

Stack trace: 4: RunDiagnostics.R#807: executeCohortRelationshipDiagnostics(connection = connection, databaseId = databaseId, exportFolder = exportFolder, cohortDatabaseSchema = cohortDatabaseSchema, cdmDatabase 3: Private.R#326: eval(expr) 2: RunDiagnostics.R#801: timeExecution(exportFolder, "executeCohortRelationshipDiagnostics", cohortIds, parent = "executeDiagnostics", expr = { executeCohortRelationshipDiagnostics(connection = 1: CohortDiagnostics::executeDiagnostics(cohortDefinitionSet = cohortDefinitionSet, connectionDetails = connectionDetails, cdmDatabaseSchema = cdmSchema, cohortDatabaseSchema = writeSchema, databas

R version: R version 4.4.0 (2024-04-24)

Platform: x86_64-pc-linux-gnu

Attached base packages:

image

Some cohorts have zero counts in my database.

ablack3 commented 3 weeks ago

https://github.com/OHDSI/CohortDiagnostics/blob/03c40ab06832a329f2c904fbd686a0596ea9af6f/R/RunDiagnostics.R#L816

temporalCovariateSettings is a covariateSettings object but when executeCohortRelationshipDiagnostics is called only the first element of the list is passed in. So inside executeCohortRelationshipDiagnostics the temporalCovariateSettings is a length one logical vector.

Then inside executeCohortRelationshipDiagnostics it seems as if temporalCovariateSettings is expected to be a covariate settings object.

https://github.com/OHDSI/CohortDiagnostics/blob/03c40ab06832a329f2c904fbd686a0596ea9af6f/R/CohortRelationship.R#L266

So I think https://github.com/OHDSI/CohortDiagnostics/blob/03c40ab06832a329f2c904fbd686a0596ea9af6f/R/RunDiagnostics.R#L816 should not include the subsetting.

temporalCovariateSettings = temporalCovariateSettings, Has anyone else experienced this issue?

azimov commented 1 week ago

I think this issue is caused by a check occuring only when running temporal characterization is false:

https://github.com/OHDSI/CohortDiagnostics/blob/03c40ab06832a329f2c904fbd686a0596ea9af6f/R/RunDiagnostics.R#L357

I should be able to resolve this in the develop branch today