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

Characterization is not supporting temporal covariate settings object #13

Open
gowthamrao opened this issue Feb 27, 2023 · 2 comments
Open
Assignees

Comments

@gowthamrao
Copy link
Member

Reproducible code. the code below gives the error
Error: Columns time_id not found

While uploading covariates

This is because timeId is absent in these tables

CREATE TABLE @my_schema.@table_prefixcovariates (
run_id int NOT NULL,
database_id varchar(100) NOT NULL,
cohort_definition_id int NOT NULL,
covariate_id int NOT NULL,
sum_value int NOT NULL,
average_value float NOT NULL
);
CREATE TABLE @my_schema.@table_prefixcovariates_continuous (
run_id int NOT NULL,
database_id varchar(100) NOT NULL,
cohort_definition_id int NOT NULL,
covariate_id int NOT NULL,
count_value int NOT NULL,
min_value float,
max_value float,
average_value float,
standard_deviation float,
median_value float,
p_10_value float,
p_25_value float,
p_75_value float,
p_90_value float
);

# Set up
remotes::install_github("OHDSI/DatabaseConnector")
remotes::install_github("OHDSI/FeatureExtraction")

outputLocation <- file.path("D:", "test")

# cohort definition set
targetCohortIds <- 40 # diabetes mellitus
outcomeCohortIds <- 23 # inpatient
cohortDefinitionSet <-
  PhenotypeLibrary::getPlCohortDefinitionSet(cohortIds = c(targetCohortIds, outcomeCohortIds))

database <- "eunomia"
resultsLocation <- file.path(outputLocation, database)
cohortDatabaseSchema <- "main"
cdmDatabaseSchema <- "main"
databaseId <- database
cohortTableNames <-
  CohortGenerator::getCohortTableNames(cohortTable = "cohort")
targetCohortDatabaseSchema <- cdmDatabaseSchema
targetCohortTable <- cohortTableNames$cohortTable
outcomeCohortDatabaseSchema <- cdmDatabaseSchema
outcomeCohortTable <- cohortTableNames$cohortTable
connectionDetails <- Eunomia::getEunomiaConnectionDetails()
CohortGenerator::createCohortTables(
  connectionDetails = connectionDetails,
  cohortDatabaseSchema = cohortDatabaseSchema,
  cohortTableNames = cohortTableNames
)
CohortGenerator::generateCohortSet(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = cdmDatabaseSchema,
  cohortDatabaseSchema = cohortDatabaseSchema,
  cohortTableNames = cohortTableNames,
  cohortDefinitionSet = cohortDefinitionSet
)

# feature extraction specification from CohortDiagnostics as it has temporalCovariateSettings
cohortDiagnosticsCovariateSettings <-
  CohortDiagnostics::getDefaultCovariateSettings()


# Setting for characterization package
aggregateCovariateSettings1 <-
  Characterization::createAggregateCovariateSettings(
    targetIds = targetCohortIds,
    outcomeIds = outcomeCohortIds,
    riskWindowStart = 0,
    startAnchor = 'cohort start',
    riskWindowEnd = 0,
    endAnchor = 'cohort end',
    covariateSettings = cohortDiagnosticsCovariateSettings
  )

timeToEventSettings1 <- Characterization::createTimeToEventSettings(targetIds = targetCohortIds,
                                                                    outcomeIds = outcomeCohortIds)
dechallengeRechallengeSettings <-
  Characterization::createDechallengeRechallengeSettings(
    targetIds = targetCohortIds,
    outcomeIds = outcomeCohortIds,
    dechallengeStopInterval = 30,
    dechallengeEvaluationWindow = 31
  )


characterizationSettings <-
  Characterization::createCharacterizationSettings(
    timeToEventSettings = list(timeToEventSettings1),
    dechallengeRechallengeSettings = list(dechallengeRechallengeSettings),
    aggregateCovariateSettings = list(aggregateCovariateSettings1)
  )

Characterization::runCharacterizationAnalyses(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = cdmDatabaseSchema,
  targetDatabaseSchema = targetCohortDatabaseSchema,
  targetTable = targetCohortTable,
  outcomeDatabaseSchema = outcomeCohortDatabaseSchema,
  outcomeTable = outcomeCohortTable,
  characterizationSettings = characterizationSettings,
  saveDirectory = resultsLocation,
  tablePrefix = 'c_',
  databaseId = databaseId
)


@jreps
Copy link
Collaborator

jreps commented Apr 26, 2024

This edit will require adding migration SQL scrips to add in the time reference. I'll look into adding those.

@jreps jreps self-assigned this Apr 26, 2024
@jreps
Copy link
Collaborator

jreps commented Apr 26, 2024

Actually - enabling temporal features would make things difficult, especially for the shiny viewer (you would have to check for timeId and do a different view). I think the best solution would be to add a new function that does temporal description where the user specifies cohortIds and a temporal features setting. I'll add that in the future.

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

2 participants