FeatureExtraction createCohortBasedCovariateSettings does not work
FeatureExtraction::createCohortBasedCovariateSettings does not work when running PLP.
When running PLP the target cohort is extracted (after sampling, restricting to specified time periods and requiring minimum prior observation) from the cohortDatabaseSchema.cohortTable into a temp table #cohort_person.
The covariate data extraction then uses this #cohort_person table. However, FeatureExtraction::createCohortBasedCovariateSettings assumes the predictor cohorts are in the same table as the target cohort (in this case, it assumes the predictor cohorts are generated in #cohort_person which is not true). This means when people use FeatureExtraction::createCohortBasedCovariateSettings as the covariateSetting and runPlp() they will not get the cohort features generated.
PatientLevelPrediction has PatientLevelPrediction::createCohortCovariateSettings() which FeatureExtraction::createCohortBasedCovariateSettings was developed based on. This function will work and let users include cohort features when running runPlp().
Here are some solutions I think we can do:
- Suggest users do not use FeatureExtraction::createCohortBasedCovariateSettings and instead use PatientLevelPrediction::createCohortCovariateSettings()
- Edit PatientLevelPrediction so that the temp #cohort_person is not used - but then it is unclear how we applying sampling and any target cohort restrictions (such as study period and min prior observation restrictions).
- Edit PatientLevelPrediction so that any cohorts in any FeatureExtraction::createCohortBasedCovariateSettings are moved into #cohort_person
- Request that FeatureExtraction enables an optional separate schema and table for the cohort features.
Any solutions I've missed? What seems the best one?
So Strategus has a solution for this:
https://github.com/OHDSI/Strategus/blob/main/R/StrategusModule.R#L324-L381
We are thinking maybe that function can be in FE and then PLP can call it in runPlp()
hi @jreps, I have added the function from Strategus in FE in this branch. Would this work for the PLP package?
Some notes from talking with @ginberg around this specific issue:
- The function that comes from Strategus in this branch should be used as part of the getDbCovariateData to override the schema and table used when building cohort-based covariate settings.
- Add additional parameters to
getDbCovariateDatacalledcovariateCohortDatabaseSchemaandcovariateCohortTablethat are NULL by default. These parameters will allow for specification of the location for cohort-based features and will be used to update the cohort-based covariate settings using the function mentioned above.
This will then allow the caller to FeatureExtraction to specify where the base and feature cohorts exist instead of assuming they are all in the same cohort table.