OHDSI / PatientLevelPrediction

An R package for performing patient level prediction in an observational database in the OMOP Common Data Model.
https://ohdsi.github.io/PatientLevelPrediction
188 stars 89 forks source link

We ran the shiny app, but it was empty #460

Open arani11 opened 5 months ago

arani11 commented 5 months ago

We ran the shiny app for our PLP prediction model, but after running it, the app was empty - it did not contain any of the data. Are you able to help with this please? Screenshot attached below. Thank you.

Contingut multimèdia (2)

egillax commented 5 months ago

The screenshot is actually missing the important bits. This is how it looks for me:

image

Can you confirm there is no row at the bottom (In a section with subheading Table like in my picture with a blue button to the right called Actions ?

arani11 commented 3 months ago

Hi, yes I can confirm that there is no row at the bottom. We have tried running it again today and had the same problem: the app was empty. Please find screenshot attached. Shiny screenshot.docx Are you able to help with this please? Many thanks @egillax @jreps

image

egillax commented 3 months ago

Hi @arani11,

This sounds like a java error we used to get when running shiny apps on ubuntu. How are you running the shiny app? I can see you are opening it in Windows, but maybe there's a server somewhere running it? Are you maybe running rstudio server? Do you get the same error if you hit the "Open in browser" button at the top below the URL ?

arani11 commented 3 months ago

Hi @egillax

Thanks for your reply.

I am running it on an Rstudio server. Yes I get the same error when I open in browser too.

Are you able to help please?

Thanks

egillax commented 3 months ago

The fix for the java error was putting the following in your .Rprofile file:

options(java.parameters = "-Xss3m")

If you don't know how to edit that file you can use usethis::edit_r_profile() to open it.

You need to restart you rsession for this to take effect. Let me know if this works. I'm not sure if this works on Rstudio server but hopefully it does.

arani11 commented 3 months ago

Thanks for your reply @egillax. I tried doing the above and this time had the following error message: Github shiny error.docx

image

image

egillax commented 3 months ago

It says an error report errorReportSql.txt was created. Could you share that file ?

arani11 commented 3 months ago

errorReportSql.txt

@egillax please find attached.

egillax commented 3 months ago

The error indicates the time-at-risk related fields are empty. These are defined in your populationSettings. (riskWindowStart, riskWindowEnd, startAnchor and endAnchor.). They all have default values so should never be empty even if you don't specify them explicitly. Either something went wrong with creating that object or possibly saving/loading it before uploading to database.

How are you defining your modelDesign or study population ?

arani11 commented 3 months ago

image

Please see screenshot - does this help to answer your question? Thanks

egillax commented 3 months ago

Yes that shows it's defined correctly. The output directory of your model development should look something like this:

plpResult/ ├── model │   ├── attributes.json │   ├── covariateImportance.csv │   ├── modelDesign.json │   ├── model.json │   ├── preprocessing.json │   └── trainDetails.json └── runPlp.rds

In the modelDesign.json the populationSettings should be stored like so:

image

Can you find the file and check it's the same for you?

arani11 commented 3 months ago

plp analysis -----

populationSettings <- createStudyPopulationSettings( firstExposureOnly = TRUE, removeSubjectsWithPriorOutcome = TRUE, priorOutcomeLookback = 99999, riskWindowStart = 1, riskWindowEnd = 1825, startAnchor = 'cohort start', endAnchor = 'cohort start', minTimeAtRisk = 1, requireTimeAtRisk = TRUE, includeAllOutcomes = TRUE )

splitSettings <- createDefaultSplitSetting( testFraction = 0.1, trainFraction = 0.9, type = 'subject', nfold = 5, splitSeed = 11061992 )

sampleSettings <- createSampleSettings(type = "none")

featureEngineeringSettings <- createFeatureEngineeringSettings()

preprocessSettings <- createPreprocessSettings( minFraction = 0.1, normalize = T, removeRedundancy = T )

if(isTRUE(run_individual_lr)){ lrModel <- setLassoLogisticRegression()

lrResults <- runPlp( plpData = plpData, outcomeId = workingOutcomeCohortid, analysisId = db_name, analysisName = workingOutputFolder, populationSettings = populationSettings, splitSettings = splitSettings, sampleSettings = sampleSettings, featureEngineeringSettings = featureEngineeringSettings, preprocessSettings = preprocessSettings, modelSettings = lrModel, logSettings = createLogSettings(), executeSettings = createExecuteSettings( runSplitData = T, runSampleData = T, runfeatureEngineering = T, runPreprocessData = T, runModelDevelopment = T, runCovariateSummary = T ), saveDirectory = here::here("results", analysis_name))

saveRDS(lrResults, "results/workingOutputFolder/lrResults.rds") }

if(isTRUE(run_individual_xgb)){

Model 2: XGBooster - setGradientBoostingMachine()

lrXGB <- setGradientBoostingMachine( ntrees = c(10, 100), nthread = 20, earlyStopRound = 25, maxDepth = c(4, 5), minChildWeight = 1, learnRate = c(0.05, 0.1, 0.3), scalePosWeight = 1, lambda = 1, alpha = 0, seed = sample(1e+07, 1) )

lrXGBResults <- runPlp( plpData = plpData, outcomeId = workingOutcomeCohortid, analysisId = db_name, analysisName = workingOutputFolder, populationSettings = populationSettings, splitSettings = splitSettings, sampleSettings = sampleSettings, featureEngineeringSettings = featureEngineeringSettings, preprocessSettings = preprocessSettings, modelSettings = lrXGB, logSettings = createLogSettings(), executeSettings = createExecuteSettings( runSplitData = T, runSampleData = T, runfeatureEngineering = T, runPreprocessData = T, runModelDevelopment = T, runCovariateSummary = T ), saveDirectory = here::here("results", analysis_name)) saveRDS(lrResults, "results/workingOutputFolder/lrResults.rds") }

arani11 commented 3 months ago

@egillax please see above - is this the correct file? thanks

egillax commented 3 months ago

Not exactly. But if you execute the following you should get the info:

lrResults <- readRDS("results/workingOutputFolder/lrResults.rds")
modelDesign <- lrResults$model$modelDesign
modelDesign$populationSettings

That should print the info.

I assume after you developed the model you call viewPlp straight on the result object like viewPlp(lrResult) ? Could you paste in the whole log after you do that, or up until the error happens. It looks like this for me:

 PatientLevelPrediction::viewPlp(lrResults)
Connecting using SQLite driver
All or some PLP result tables do not exist, tables being recreated
Deleting existing tables
Creating PLP results tables
  |======================================================================| 100%
Executing SQL took 0.0238 secs
PLP result migrration being applied
Migrating data set
Migrator using SQL files in PatientLevelPrediction
Connecting using SQLite driver
Creating migrations table
  |======================================================================| 100%
Executing SQL took 0.00358 secs
Migrations table created
Executing migration: Migration_1-store_version.sql
  |======================================================================| 100%
Executing SQL took 0.00442 secs
Saving migration: Migration_1-store_version.sql
  |======================================================================| 100%
Executing SQL took 0.00378 secs
Migration complete Migration_1-store_version.sql
Closing database connection
Updating version number
Connecting using SQLite driver
  |======================================================================| 100%
Executing SQL took 0.00427 secs
Connecting using SQLite driver
Adding TAR
  |======================================================================| 100%
Executing SQL took 0.00392 secs
tarId: 1
arani11 commented 3 months ago

Please see below @egillax

lrResults <- readRDS("results/workingOutputFolder/lrResults.rds") modelDesign <- lrResults$model$modelDesign modelDesign$populationSettings $binary [1] TRUE

$includeAllOutcomes [1] TRUE

$firstExposureOnly [1] TRUE

$washoutPeriod [1] 0

$removeSubjectsWithPriorOutcome [1] TRUE

$priorOutcomeLookback [1] 99999

$requireTimeAtRisk [1] TRUE

$minTimeAtRisk [1] 1

$riskWindowStart [1] 1

$startAnchor [1] "cohort start"

$riskWindowEnd [1] 1825

$endAnchor [1] "cohort start"

$restrictTarToCohortEnd [1] FALSE

attr(,"class") [1] "populationSettings"

arani11 commented 3 months ago
#View reults > lrResults <- readRDS("~/External_validation/results/CPRD GOLD_psoriasis_to_psa_specific_2024-06-01 17:52:36/lrResults.rds") Error in gzfile(file, "rb") : cannot open the connection In addition: Warning message: In gzfile(file, "rb") : cannot open compressed file '/home/AD_NDORMS/araniv/External_validation/results/CPRD GOLD_psoriasis_to_psa_specific_2024-06-01 17:52:36/lrResults.rds', probable reason 'No such file or directory' > viewPlp(lrResults,es,diagnosePlp = NULL) Connecting using SQLite driver All or some PLP result tables do not exist, tables being recreated Deleting existing tables Creating PLP results tables \|=======================================================================================\| 100% Executing SQL took 0.039 secs PLP result migrration being applied Migrating data set Migrator using SQL files in PatientLevelPrediction Connecting using SQLite driver Creating migrations table \|=======================================================================================\| 100% Executing SQL took 0.00526 secs Migrations table created Executing migration: Migration_1-store_version.sql \|=======================================================================================\| 100% Executing SQL took 0.00581 secs Saving migration: Migration_1-store_version.sql \|=======================================================================================\| 100% Executing SQL took 0.00473 secs Migration complete Migration_1-store_version.sql Closing database connection Updating version number Connecting using SQLite driver \|=======================================================================================\| 100% Executing SQL took 0.00582 secs Connecting using SQLite driver Adding TAR \|=======================================================================================\| 100% Executing SQL took 0.00464 secs tarId: 1 Adding cohort Cohort: 1 Inserting data took 0.0235 secs Adding cohort Cohort: 1 Inserting data took 0.0497 secs tId: 1 Adding cohort Cohort: 2 Inserting data took 0.0118 secs Adding cohort Cohort: 2 Inserting data took 0.0109 secs oId: 2 Adding new population settings Inserting data took 0.0108 secs popSetId: 1 Adding new covariate settings Inserting data took 0.0108 secs covSetId: 1 Adding new model settings Inserting data took 0.0126 secs modSetId: 1 Adding new plp data settings Inserting data took 0.0125 secs plpDataSetId: 1 Adding new feature_engineering settings Inserting data took 0.0126 secs FESetId: 1 Adding new sample settings Inserting data took 0.0123 secs sampleSetId: 1 Adding new tidy covariates settings Inserting data took 0.0123 secs tidySetId: 1 Adding new split settings Inserting data took 0.013 secs splitId: 1 \|=======================================================================================\| 100% Executing SQL took 0.00627 secs modelDesignId: 1 \|=======================================================================================\| 100% Executing SQL took 0.0052 secs \|=======================================================================================\| 100% Executing SQL took 0.00527 secs Database meta data already exists Database1 already exists \|=======================================================================================\| 100% Executing SQL took 0.00578 secs modelId: 1 inserted for modelDesignId 1and databaseId 1 TAR exists json in jsons:TRUE Cohort Cohort: 1 exists in cohort_definition with cohort id1 Cohort Cohort: 1 exists in cohorts with cohort id1 json in jsons:TRUE Cohort Cohort: 2 exists in cohort_definition with cohort id2 Cohort Cohort: 2 exists in cohorts with cohort id2 Population settings exists Split setting exists Inserting performance... \|=======================================================================================\| 100% Executing SQL took 0.00492 secs performanceId: 1 Inserting attrition for performance 1 Inserting data took 0.0127 secs Adding PredictionDistribution Inserting predictionDistribution for performance 1 Inserting data took 0.0148 secs Adding ThresholdSummary Inserting thresholdSummary for performance 1 Inserting data took 0.0192 secs Adding EvaluationStatistics Inserting evaluationSummary for performance 1 Inserting data took 0.0118 secs Adding CalibrationSummary Inserting calibrationSummary for performance 1 Inserting data took 0.0146 secs Adding DemographicSummary Inserting demographicSummary for performance 1 Inserting data took 0.0146 secs Restricting to covariates included in model Inserting covariateSummary for result 1 Inserting data took 0.0171 secs Error in insertRunPlpToSqlite(runPlp = runPlp, externalValidatePlp = validatePlp, : object 'es' not found --   > | > >
arani11 commented 3 months ago

Please see above (and also attached, in case that is easier to read for you) for the second part of your question. Thanks github shiny error 2.docx

egillax commented 3 months ago

Hi @arani11,

You seem to be getting a different error now? How are you generating the es object?

arani11 commented 3 months ago

Hi @egillax Sorry I don't understand your question. Would it be better to jump on a quick Teams call to resolve this? Thanks

egillax commented 3 months ago

Sure if you send me an invite to e.fridgeirsson@erasmusmc.nl I can hop on a quick call