From 6ae6773b884b2f32741728be4ecf7bfe2dfa8e8d Mon Sep 17 00:00:00 2001 From: jreps Date: Wed, 16 Aug 2023 08:35:36 -0400 Subject: [PATCH 01/21] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 73929b7e0..d8262eee5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: PatientLevelPrediction Type: Package Title: Developing patient level prediction using data in the OMOP Common Data Model -Version: 6.3.4 +Version: 6.3.4.9000 Date: 2023-08-15 Authors@R: c( person("Jenna", "Reps", email = "jreps@its.jnj.com", role = c("aut", "cre")), From 92047a87a304d8e0c911715bbe6a7d2068c4320d Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 13:36:26 +0200 Subject: [PATCH 02/21] remove python setup from action yml --- .github/workflows/R_CMD_check_Hades.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 27dcc8d23..ad343813d 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -46,20 +46,6 @@ jobs: steps: - uses: actions/checkout@v2 - - - uses: conda-incubator/setup-miniconda@v2 - with: - python-version: "3.7" - activate-environment: r-reticulate - - - name: python main dependencies - run: conda install --name r-reticulate numpy scipy scikit-learn pandas pydotplus joblib - - - name: python json dependencies - run: conda install --name r-reticulate -c conda-forge sklearn-json - - - name: python scikit-survival dependencies - run: conda install --name r-reticulate -c sebp scikit-survival - uses: r-lib/actions/setup-r@v2 with: From 05d79ac5261942c85dc7b1f8934d1a930c91e8d6 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 13:36:26 +0200 Subject: [PATCH 03/21] remove python setup from action yml --- .github/workflows/R_CMD_check_Hades.yaml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 27dcc8d23..3d9835b69 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -46,20 +46,6 @@ jobs: steps: - uses: actions/checkout@v2 - - - uses: conda-incubator/setup-miniconda@v2 - with: - python-version: "3.7" - activate-environment: r-reticulate - - - name: python main dependencies - run: conda install --name r-reticulate numpy scipy scikit-learn pandas pydotplus joblib - - - name: python json dependencies - run: conda install --name r-reticulate -c conda-forge sklearn-json - - - name: python scikit-survival dependencies - run: conda install --name r-reticulate -c sebp scikit-survival - uses: r-lib/actions/setup-r@v2 with: @@ -83,11 +69,6 @@ jobs: with: extra-packages: any::rcmdcheck needs: check - - - name: use r-reticulate environment - run: | - reticulate::use_condaenv("r-reticulate", required = TRUE) - shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 with: From 98cf353981721f09d955c38be8a24c3d9d9c172c Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 13:44:04 +0200 Subject: [PATCH 04/21] update deprecated actions --- .github/workflows/R_CMD_check_Hades.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 3d9835b69..5021748dc 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -51,9 +51,9 @@ jobs: with: r-version: ${{ matrix.config.r }} - - uses: r-lib/actions/setup-tinytex@v1 + - uses: r-lib/actions/setup-tinytex@v2 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - name: Install system requirements if: runner.os == 'Linux' From 40aff5b030401367811a419d4c24f1fb7eac74e0 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 14:45:37 +0200 Subject: [PATCH 05/21] fix decision tree node deSerialization for sklearn>=1.3 --- R/SklearnToJson.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/SklearnToJson.R b/R/SklearnToJson.R index 9c1dba1ae..2a2771338 100644 --- a/R/SklearnToJson.R +++ b/R/SklearnToJson.R @@ -89,7 +89,11 @@ deSerializeTree <- function(tree_dict, nFeatures, nClasses, nOutputs) { reticulate::tuple(reticulate::py_to_r(tree_dict["nodes"][i]))) } - names = list("left_child", "right_child", "feature", "threshold", "impurity", "n_node_samples", "weighted_n_node_samples") + names <- list("left_child", "right_child", "feature", "threshold", "impurity", "n_node_samples", "weighted_n_node_samples") + if (length(tree_dict["nodes"][0])==8) { + # model used sklearn>=1.3 which added a parameter + names[[8]] <- "missing_go_to_left" + } sklearn <- reticulate::import("sklearn") np <- reticulate::import("numpy", convert = FALSE) From 790f31798be3740b979130324984ee96f7b400e0 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 14:45:57 +0200 Subject: [PATCH 06/21] tell windows where miniconda is --- .github/workflows/R_CMD_check_Hades.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 5021748dc..e63a80757 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -64,6 +64,8 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + if: runner.os == 'Windows' + run: Add-Content $env:PATH "C:\Miniconda" - uses: r-lib/actions/setup-r-dependencies@v2 with: From 93bc937598ef7e32235e458f289603644c5c7bc8 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 14:47:27 +0200 Subject: [PATCH 07/21] separate workflow item for windows miniconda --- .github/workflows/R_CMD_check_Hades.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index e63a80757..55bdd25a5 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -64,6 +64,8 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Tell windows about miniconda if: runner.os == 'Windows' run: Add-Content $env:PATH "C:\Miniconda" From 89505933d95896060dd1647ea66906bfd74a6ade Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Fri, 25 Aug 2023 15:00:37 +0200 Subject: [PATCH 08/21] use bash to add windows path --- .github/workflows/R_CMD_check_Hades.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 55bdd25a5..515d110a1 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -66,8 +66,9 @@ jobs: done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - name: Tell windows about miniconda - if: runner.os == 'Windows' - run: Add-Content $env:PATH "C:\Miniconda" + shell: bash + run: | + echo "C:\Miniconda" >> $GITHUB_PATH - uses: r-lib/actions/setup-r-dependencies@v2 with: From 23bd6bbc01505ab9563d87e03935d8f801be7fa3 Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Fri, 25 Aug 2023 15:51:32 +0200 Subject: [PATCH 09/21] Update R_CMD_check_Hades.yaml --- .github/workflows/R_CMD_check_Hades.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 515d110a1..e3dc98159 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -68,7 +68,7 @@ jobs: - name: Tell windows about miniconda shell: bash run: | - echo "C:\Miniconda" >> $GITHUB_PATH + echo "C:\Miniconda\bin" >> $GITHUB_PATH - uses: r-lib/actions/setup-r-dependencies@v2 with: From 84602e7a767a4519a4eb22b50f1373299830aa76 Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Fri, 25 Aug 2023 16:11:24 +0200 Subject: [PATCH 10/21] Update R_CMD_check_Hades.yaml --- .github/workflows/R_CMD_check_Hades.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index e3dc98159..8e27ec827 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -65,10 +65,10 @@ jobs: eval sudo $cmd done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - name: Tell windows about miniconda - shell: bash - run: | - echo "C:\Miniconda\bin" >> $GITHUB_PATH + - name: Setup conda + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: "r-reticulate" - uses: r-lib/actions/setup-r-dependencies@v2 with: From d9a609c7382d13d33f85a5d1691565ca2e0ea42a Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Fri, 25 Aug 2023 17:10:10 +0200 Subject: [PATCH 11/21] Update R_CMD_check_Hades.yaml --- .github/workflows/R_CMD_check_Hades.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index 8e27ec827..b85c0c946 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -22,7 +22,7 @@ jobs: config: - {os: windows-latest, r: 'release'} # Does not appear to have Java 32-bit, hence the --no-multiarch - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"} env: GITHUB_PAT: ${{ secrets.GH_TOKEN }} @@ -63,7 +63,7 @@ jobs: while read -r cmd do eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "22.04"))') - name: Setup conda uses: conda-incubator/setup-miniconda@v2 From 0d32abd6bca82079b462523a4672aa4e35c2bafb Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 18:03:35 +0200 Subject: [PATCH 12/21] prepare release --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 73929b7e0..a16e3f37e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: PatientLevelPrediction Type: Package Title: Developing patient level prediction using data in the OMOP Common Data Model -Version: 6.3.4 +Version: 6.3.5 Date: 2023-08-15 Authors@R: c( person("Jenna", "Reps", email = "jreps@its.jnj.com", role = c("aut", "cre")), diff --git a/NEWS.md b/NEWS.md index 33ce2fe7d..be5c6e18f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +PatientLevelPrediction 6.3.5 +====================== +- Fix sklearnToJson to be compatible with scikit-learn>=1.3 +- Fix github actions so it's not hardcoded to use python 3.7 + + PatientLevelPrediction 6.3.4 ====================== - added spline feature engineering From 2653c39c8524f7563eb23150146cc5054a2b3f71 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 25 Aug 2023 18:17:51 +0200 Subject: [PATCH 13/21] update python version mentioned in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52a2ac8bc..838a82cff 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ System Requirements Requires R (version 4.0 or higher). Installation on Windows requires [RTools](http://cran.r-project.org/bin/windows/Rtools/). Libraries used in PatientLevelPrediction require Java and Python. The python installation is required for some of the machine learning algorithms. We advise to -install Python 3.7 using Anaconda (https://www.continuum.io/downloads). +install Python 3.8 or higher using Anaconda (https://www.continuum.io/downloads). Getting Started =============== From 5a08d8a52328fb7838e2d1ccdd1ade80f1a560b6 Mon Sep 17 00:00:00 2001 From: jreps Date: Thu, 7 Sep 2023 18:12:56 -0400 Subject: [PATCH 14/21] adding pages to website - adding benchmark tasks and constrained predictors to website --- _pkgdown.yml | 8 + vignettes/BenchmarkTasks.Rmd | 306 ++++++++++++++++++++++++++++ vignettes/BestPractices.rmd | 18 +- vignettes/ConstrainedPredictors.Rmd | 86 ++++++++ 4 files changed, 415 insertions(+), 3 deletions(-) create mode 100644 vignettes/BenchmarkTasks.Rmd create mode 100644 vignettes/ConstrainedPredictors.Rmd diff --git a/_pkgdown.yml b/_pkgdown.yml index 2ad97fef6..d3f9ef550 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -20,6 +20,8 @@ navbar: - reference - articles - tutorial + - benchmarks + - predictors - bestpractice - news right: [hades, github] @@ -39,6 +41,12 @@ navbar: bestpractice: text: Best Practices href: articles/BestPractices.html + benchmarks: + text: Benchmarks + href: articles/BenchmarkTasks.html + predictors: + text: Predictors + href: articles/ConstrainedPredictors.html news: text: Changelog href: news/index.html diff --git a/vignettes/BenchmarkTasks.Rmd b/vignettes/BenchmarkTasks.Rmd new file mode 100644 index 000000000..13eb511ab --- /dev/null +++ b/vignettes/BenchmarkTasks.Rmd @@ -0,0 +1,306 @@ +--- +title: "Benchmark Tasks" +author: "Jenna Reps, Ross Williams, Peter R. Rijnbeek" +date: '`r Sys.Date()`' +header-includes: + - \usepackage{fancyhdr} + - \pagestyle{fancy} + - \fancyhead{} + - \fancyhead[CO,CE]{Installation Guide} + - \fancyfoot[CO,CE]{PatientLevelPrediction Package Version `r utils::packageVersion("PatientLevelPrediction")`} + - \fancyfoot[LE,RO]{\thepage} + - \renewcommand{\headrulewidth}{0.4pt} + - \renewcommand{\footrulewidth}{0.4pt} +output: + pdf_document: + includes: + in_header: preamble.tex + number_sections: yes + toc: yes + word_document: + toc: yes + html_document: + number_sections: yes + toc: yes +--- + + +## Benchmark Tasks For Large-Scale Empirical Analyses + +Here we provide a set of diverse prediction tasks that can be used when evaluating the impact of the model design choice when developing models using observational data. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Target Cohort (index) + +Outcome + +Time-at-risk + +Link +
+Patients with an outpatient visit in 2017 with no prior cancer (first visit in 2017) + +Lung cancer + +1 day - 3 years after index + +
+Patients newly diagnosed with major depressive disorder (date of first record) + +Bipolar + +1 day - 365 day after index + +
+Patients with an outpatient visit in 2019 + +Dementia + +1 day - 3 years after index + +
+Patients with an outpatient visit and a positive COVID test + +Hospitalization with pneumonia + +1 day - 30 days after index + +
+Patients with an outpatient visit and a positive COVID test + +Hospitalization with pneumonia that required intensive services (ventilation, intubation, tracheotomy, or extracorporeal membrane oxygenation) or death + +1 day - 30 days after index + +
+Patients with an outpatient visit and a positive COVID test + +Death + +1 day - 30 days after index + +
+Patients with T2DM who were treated with metformin and who became new adult users of one of sulfonylureas, thiazolidinediones, dipeptidyl peptidase-4 inhibitors, glucagon-like peptide-1 receptor agonists, or sodium-glucose co-transporter-2 inhibitors (date of secondary drug). Patients with HF or patients treated with insulin on or prior to the index date were excluded from the analysis. Patients were required to have been enrolled for at least 365 days before cohort entry. + +Heart Failure + +1 to 365 days + +
+Patients newly diagnosed with atrial fibrilation (date of initial afib record) + +Ischemic stroke + +1 to 365 days + +
+Patients undergoing elective major non-cardiac surgery (date of surgery). Patients were required to have been enrolled for at least 365 days before cohort entry. + +Earliest of AMI cardiac arrest or death (MACE) + +O to 30 days + +
+Patients starting intravitreal Anti-VEGF (date of administration) + +Kidney Failure + +1 to 365 days + +
+Pregnancy women (start of pregnancy) + +Preeclampsia + +During pregnancy + +
+Pregnancy women (start of pregnancy) + +Still birth + +During pregnancy + +
+Patients with COPD (first record) + +Cardiovascular event and death + +1-30 days and 1-90 days + +
+Patients starting menopause (first record) + +Depression + +1 day - 3-years + +
+Patients with anemia (date of first anemia record) + +Colorectal cancer + +1 day - 1-year + +
+Patients with quadriplegia (date of first quadriplegia record) + +Death + +1 day - 1-year + +
+Patient undergoing + + + + + +
+ + + + + + +
+ \ No newline at end of file diff --git a/vignettes/BestPractices.rmd b/vignettes/BestPractices.rmd index 9c27f3f7c..b59ba6c5e 100644 --- a/vignettes/BestPractices.rmd +++ b/vignettes/BestPractices.rmd @@ -101,7 +101,7 @@ Data Creation Impact of over/under-sampling -Study being developed +Paper under review @@ -125,7 +125,7 @@ Model development How much data do we need for prediction - Learning curves at scale -Preprint link +International Journal of Medical Informatics @@ -165,6 +165,18 @@ Study needs to be done + + +Model development + + +Can we use ensembles to combine different algorithm models within a database to improve models transportability? + + +Study Complete + + + Model development @@ -173,7 +185,7 @@ Model development Can we use ensembles to combine models developed using different databases to improve models transportability? - Paper under review at BMC + BMC Medical Informatics and Decision Making diff --git a/vignettes/ConstrainedPredictors.Rmd b/vignettes/ConstrainedPredictors.Rmd new file mode 100644 index 000000000..506830952 --- /dev/null +++ b/vignettes/ConstrainedPredictors.Rmd @@ -0,0 +1,86 @@ +--- +title: "Constrained predictors" +author: "Jenna Reps" +date: '`r Sys.Date()`' +header-includes: + - \usepackage{fancyhdr} + - \pagestyle{fancy} + - \fancyhead{} + - \fancyhead[CO,CE]{Installation Guide} + - \fancyfoot[CO,CE]{PatientLevelPrediction Package Version `r utils::packageVersion("PatientLevelPrediction")`} + - \fancyfoot[LE,RO]{\thepage} + - \renewcommand{\headrulewidth}{0.4pt} + - \renewcommand{\footrulewidth}{0.4pt} +output: + pdf_document: + includes: + in_header: preamble.tex + number_sections: yes + toc: yes + word_document: + toc: yes + html_document: + number_sections: yes + toc: yes +--- + + +## Constrained Predictors + +Here we provide a set of phenotypes that can be used as predictors in prediction models or best practice research. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Phenotype Name + +Category + +ATLAS link +
+Acetaminophen prescirption + +Medication + +ATLAS link +
+Alcoholism + +Lifestyle + +ATLAS link +
+Anemia + + + +ATLAS link +
+ \ No newline at end of file From 820e05e62b1d970c924c0d0d0effabe4ffb33bff Mon Sep 17 00:00:00 2001 From: jreps Date: Thu, 21 Sep 2023 09:43:46 -0400 Subject: [PATCH 15/21] Update uploadToDatabase.R - fixing result upload issue when there is a ' in a cohort's name --- R/uploadToDatabase.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/uploadToDatabase.R b/R/uploadToDatabase.R index eef4f2021..a00c61e5c 100644 --- a/R/uploadToDatabase.R +++ b/R/uploadToDatabase.R @@ -1145,7 +1145,7 @@ addCohort <- function( targetDialect = targetDialect, tableName = 'cohort_definition', columnNames = c('cohort_name'), - values = c(paste0("'",cohortDefinition$cohortName,"'")), + values = c(paste0("'",gsub('\'', '', cohortDefinition$cohortName),"'")), tempEmulationSchema = tempEmulationSchema ) @@ -1157,12 +1157,12 @@ addCohort <- function( if(addNew){ cohortDefinitionId <- result$cohortDefinitionId[result$json %in% json] - ParallelLogger::logInfo(paste0('Cohort ',cohortDefinition$cohortName,' exists in cohort_definition with cohort id', result$cohortDefinitionId[result$json %in% json])) + ParallelLogger::logInfo(paste0('Cohort ',gsub('\'', '', cohortDefinition$cohortName),' exists in cohort_definition with cohort id', result$cohortDefinitionId[result$json %in% json])) } else{ - ParallelLogger::logInfo(paste0('Adding cohort ',cohortDefinition$cohortName)) + ParallelLogger::logInfo(paste0('Adding cohort ',gsub('\'', '', cohortDefinition$cohortName))) data <- data.frame( - cohortName = cohortDefinition$cohortName, + cohortName = gsub('\'', '', cohortDefinition$cohortName), cohortDefinitionId = cohortDefinition$cohortId, json = json ) @@ -1187,7 +1187,7 @@ addCohort <- function( targetDialect = targetDialect, tableName = 'cohort_definition', columnNames = c('cohort_name', 'cohort_definition_id'), - values = c(paste0("'",cohortDefinition$cohortName,"'"), cohortDefinition$cohortId), + values = c(paste0("'",gsub('\'', '', cohortDefinition$cohortName),"'"), cohortDefinition$cohortId), tempEmulationSchema = tempEmulationSchema ) @@ -1202,18 +1202,18 @@ addCohort <- function( targetDialect = targetDialect, tableName = 'cohorts', columnNames = c('cohort_definition_id','cohort_name'), - values = c(cohortDefinitionId, paste0("'",cohortDefinition$cohortName,"'")), + values = c(cohortDefinitionId, paste0("'",gsub('\'', '', cohortDefinition$cohortName),"'")), tempEmulationSchema = tempEmulationSchema ) if(nrow(result)>0){ - ParallelLogger::logInfo(paste0('Cohort ',cohortDefinition$cohortName,' exists in cohorts with cohort id', result$cohortId)) + ParallelLogger::logInfo(paste0('Cohort ',gsub('\'', '', cohortDefinition$cohortName),' exists in cohorts with cohort id', result$cohortId)) } else{ - ParallelLogger::logInfo(paste0('Adding cohort ',cohortDefinition$cohortName)) + ParallelLogger::logInfo(paste0('Adding cohort ',gsub('\'', '', cohortDefinition$cohortName))) data <- data.frame( cohortDefinitionId = cohortDefinitionId, - cohortName = cohortDefinition$cohortName + cohortName = gsub('\'', '', cohortDefinition$cohortName) ) DatabaseConnector::insertTable( connection = conn, @@ -1235,7 +1235,7 @@ addCohort <- function( targetDialect = targetDialect, tableName = 'cohorts', columnNames = c('cohort_definition_id','cohort_name'), - values = c(cohortDefinitionId, paste0("'",cohortDefinition$cohortName,"'")), + values = c(cohortDefinitionId, paste0("'",gsub('\'', '', cohortDefinition$cohortName),"'")), tempEmulationSchema = tempEmulationSchema ) } From 8fe88459381a237363d0e93024c7a0d7f4d67179 Mon Sep 17 00:00:00 2001 From: jreps Date: Mon, 9 Oct 2023 17:13:16 -0400 Subject: [PATCH 16/21] Update ConstrainedPredictors.Rmd adding more details about constrained predictors --- vignettes/ConstrainedPredictors.Rmd | 815 +++++++++++++++++++++++++++- 1 file changed, 806 insertions(+), 9 deletions(-) diff --git a/vignettes/ConstrainedPredictors.Rmd b/vignettes/ConstrainedPredictors.Rmd index 506830952..18623112c 100644 --- a/vignettes/ConstrainedPredictors.Rmd +++ b/vignettes/ConstrainedPredictors.Rmd @@ -30,8 +30,31 @@ output: ## Constrained Predictors + +### How to use the PhenotypeLibrary R package Here we provide a set of phenotypes that can be used as predictors in prediction models or best practice research. +These phenotypes can be extracted from the PhenotypeLibrary R package. To install the R package run: + +```{r echo = FALSE} +remotes::install_github('ohdsi/PhenotypeLibrary') +``` + + +To extract the cohort definition for Alcoholism with an id of 1165, just run: + +```{r echo = FALSE} +PhenotypeLibrary::getPlCohortDefinitionSet(1165) +``` + +in general you can extract all the cohorts by running: + +```{r echo = FALSE} +phenotypeDefinitions <- PhenotypeLibrary::getPlCohortDefinitionSet(1152:1215) +``` + +### The full set of predictor phenotypes + @@ -39,34 +62,34 @@ Here we provide a set of phenotypes that can be used as predictors in prediction Phenotype Name @@ -75,10 +98,784 @@ ATLAS link Anemia + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 559c7efb78b46a9038b47964ff60689f2e7914ca Mon Sep 17 00:00:00 2001 From: jreps Date: Mon, 9 Oct 2023 17:43:19 -0400 Subject: [PATCH 17/21] Update ConstrainedPredictors.Rmd --- vignettes/ConstrainedPredictors.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vignettes/ConstrainedPredictors.Rmd b/vignettes/ConstrainedPredictors.Rmd index 18623112c..2776122cb 100644 --- a/vignettes/ConstrainedPredictors.Rmd +++ b/vignettes/ConstrainedPredictors.Rmd @@ -36,20 +36,20 @@ Here we provide a set of phenotypes that can be used as predictors in prediction These phenotypes can be extracted from the PhenotypeLibrary R package. To install the R package run: -```{r echo = FALSE} +```{r echo = T} remotes::install_github('ohdsi/PhenotypeLibrary') ``` To extract the cohort definition for Alcoholism with an id of 1165, just run: -```{r echo = FALSE} +```{r echo = T} PhenotypeLibrary::getPlCohortDefinitionSet(1165) ``` in general you can extract all the cohorts by running: -```{r echo = FALSE} +```{r echo = T} phenotypeDefinitions <- PhenotypeLibrary::getPlCohortDefinitionSet(1152:1215) ``` From 069958f14aca163d3d991dac893b38ed308b1409 Mon Sep 17 00:00:00 2001 From: egillax Date: Tue, 10 Oct 2023 12:01:22 +0200 Subject: [PATCH 18/21] use python 3.11 when creating conda envs --- R/HelperFunctions.R | 5 +++-- man/configurePython.Rd | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/R/HelperFunctions.R b/R/HelperFunctions.R index e3b939ff6..bf5f71b1b 100644 --- a/R/HelperFunctions.R +++ b/R/HelperFunctions.R @@ -94,9 +94,10 @@ listAppend <- function(a, b){ #' #' @param envname A string for the name of the virtual environment (default is 'PLP') #' @param envtype An option for specifying the environment as'conda' or 'python'. If NULL then the default is 'conda' for windows users and 'python' for non-windows users +#' @param condaPythonVersion String, Python version to use when creating a conda environment #' #' @export -configurePython <- function(envname='PLP', envtype=NULL){ +configurePython <- function(envname='PLP', envtype=NULL, condaPythonVersion="3.11"){ if(is.null(envtype)){ if(getOs()=='windows'){ @@ -113,7 +114,7 @@ configurePython <- function(envname='PLP', envtype=NULL){ warning(paste0('Conda environment ', envname,' exists. You can use reticulate::conda_remove() to remove if you want to fresh config')) } else { ParallelLogger::logInfo(paste0('Creating virtual conda environment called ', envname)) - location <- reticulate::conda_create(envname=envname, packages = "python", conda = "auto") + location <- reticulate::conda_create(envname=envname, packages = paste0("python==", condaPythonVersion), conda = "auto") } packages <- c('numpy','scipy','scikit-learn', 'pandas','pydotplus','joblib') ParallelLogger::logInfo(paste0('Adding python dependancies to ', envname)) diff --git a/man/configurePython.Rd b/man/configurePython.Rd index 9d014fa94..99e8d79aa 100644 --- a/man/configurePython.Rd +++ b/man/configurePython.Rd @@ -4,12 +4,14 @@ \alias{configurePython} \title{Sets up a virtual environment to use for PLP (can be conda or python)} \usage{ -configurePython(envname = "PLP", envtype = NULL) +configurePython(envname = "PLP", envtype = NULL, condaPythonVersion = "3.11") } \arguments{ \item{envname}{A string for the name of the virtual environment (default is 'PLP')} \item{envtype}{An option for specifying the environment as'conda' or 'python'. If NULL then the default is 'conda' for windows users and 'python' for non-windows users} + +\item{condaPythonVersion}{String, Python version to use when creating a conda environment} } \description{ Sets up a virtual environment to use for PLP (can be conda or python) From 6ab80dd850d48a50170660809c8bab79ff24bc9d Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Tue, 10 Oct 2023 12:34:47 +0200 Subject: [PATCH 19/21] Update R_CMD_check_Hades.yaml --- .github/workflows/R_CMD_check_Hades.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index b85c0c946..f7c4ea17e 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -67,8 +67,6 @@ jobs: - name: Setup conda uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: "r-reticulate" - uses: r-lib/actions/setup-r-dependencies@v2 with: From e6a6c937239e7fdf211b86c3a6987aa5396e4bc8 Mon Sep 17 00:00:00 2001 From: jreps Date: Wed, 11 Oct 2023 15:23:23 -0400 Subject: [PATCH 20/21] fixing issue 415 bug fix in ohdsi shiny modules version check --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ R/ViewShinyPlp.R | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b1b0dcc2..dde325a53 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: PatientLevelPrediction Type: Package Title: Developing patient level prediction using data in the OMOP Common Data Model -Version: 6.3.5.9000 -Date: 2023-08-15 +Version: 6.3.6 +Date: 2023-10-09 Authors@R: c( person("Jenna", "Reps", email = "jreps@its.jnj.com", role = c("aut", "cre")), person("Martijn", "Schuemie", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index be5c6e18f..ea37b5ad1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +PatientLevelPrediction 6.3.6 +====================== +- fix bug with ohdsi shiny modules version check (issue 415) + PatientLevelPrediction 6.3.5 ====================== - Fix sklearnToJson to be compatible with scikit-learn>=1.3 diff --git a/R/ViewShinyPlp.R b/R/ViewShinyPlp.R index eb4f5c2cf..65d60b8b0 100644 --- a/R/ViewShinyPlp.R +++ b/R/ViewShinyPlp.R @@ -154,7 +154,7 @@ viewPlps <- function(databaseSettings){ ) } else{ ohdsiModulesVersion <- strsplit(x = as.character(utils::packageVersion('OhdsiShinyModules')), split = '\\.')[[1]] - if(ohdsiModulesVersion[1]>=1 & ohdsiModulesVersion[2]>= 2){ + if(paste0(ohdsiModulesVersion[1], ".", ohdsiModulesVersion[2])>= 1.2){ config <- ParallelLogger::loadSettingsFromJson( fileName = system.file( 'shinyConfigUpdate.json', From ecf0fa249525eb73eb57db76ea138402891ea479 Mon Sep 17 00:00:00 2001 From: Egill Axfjord Fridgeirsson Date: Thu, 12 Oct 2023 12:08:38 +0200 Subject: [PATCH 21/21] Update R_CMD_check_Hades.yaml remove r-reticulate activation from actions since it messes up python version --- .github/workflows/R_CMD_check_Hades.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/R_CMD_check_Hades.yaml b/.github/workflows/R_CMD_check_Hades.yaml index b85c0c946..f7c4ea17e 100644 --- a/.github/workflows/R_CMD_check_Hades.yaml +++ b/.github/workflows/R_CMD_check_Hades.yaml @@ -67,8 +67,6 @@ jobs: - name: Setup conda uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: "r-reticulate" - uses: r-lib/actions/setup-r-dependencies@v2 with:
-Category +Disorder classification -ATLAS link +OHDSI Phenotype library ID
-Acetaminophen prescirption +Alcoholism -Medication +Behavioral -ATLAS link +1165
-Alcoholism +Smoking -Lifestyle +Behavioral -ATLAS link +1166
+Blood + +1188 +
+Osteoarthritis + +Bone + +1184 +
+Osteoporosis + +Bone + +1185 +
+Cancer + +Cancer + +1215 +
+Atrial fibrillation + +Cardiovascular + +1160 +
+Congestive heart failure + +Cardiovascular + +1154 +
+Coronary artery disease + +Cardiovascular + +1162 +
+Heart valve disorder + +Cardiovascular + +1172 +
+Hyperlipidemia + +Cardiovascular + +1170 +
+Hypertension + +Cardiovascular + +1198 +
+Angina + +Cardiovascular + +1159 +
+Skin Ulcer + +Debility + +1168 +
+Diabetes type 1 + +Endocrine + +1193 +
+Diabetes type 2 + +Endocrine + +1194 +
+Hypothyroidism + +Endocrine + +1171 +
+Obesity + +Endocrine + +1179 +
+Gastroesophageal reflux disease (GERD) + +GI + +1178 +
+Gastrointestinal (GI) bleed + +GI + +1197 +
+Inflammatory bowel disorder (IBD) + +GI/Rheumatology + +1180 +
+Hormonal contraceptives + +Gynecologic + +1190 +
+Antibiotics Aminoglycosides + +Infection + +1201 +
+Antibiotics Carbapenems + +Infection + +1202 +
+Antibiotics Cephalosporins + +Infection + +1203 +
+Antibiotics Fluoroquinolones + +Infection + +1204 +
+Antibiotics Glycopeptides and lipoglycopeptides + +Infection + +1205 +
+Antibiotics Macrolides + +Infection + +1206 +
+Antibiotics Monobactams + +Infection + +1207 +
+Antibiotics Oxazolidinones + +Infection + +1208 +
+Antibiotics Penicillins + +Infection + +1209 +
+Antibiotics Polypeptides + +Infection + +1210 +
+Antibiotics Rifamycins + +Infection + +1211 +
+Antibiotics Sulfonamides + +Infection + +1212 +
+Antibiotics Streptogramins + +Infection + +1213 +
+Antibiotics Tetracyclines + +Infection + +1214 +
+Pneumonia + +Infection/Respiratory + +1199 +
+Sepsis + +Infection + +1176 +
+Urinary tract infection (UTI) + +Infection + +1186 +
+Hepatitis + +Liver + +1169 +
+Anxiety + +Mood + +1189 +
+Depression (MDD) + +Mood + +1161 +
+Psychotic disorder + +Mood + +1175 +
+Antiepileptics (pain) + +Neurology/Pain + +1183 +
+Seizure + +Neurology + +1153 +
+Hemorrhagic stroke + +Neurology/Vascular + +1156 +
+Non-hemorrhagic stroke + +Neurology/Vascular + +1155 +
+Acetaminophen prescription + +Pain/Infection + +1187 +
+Low back pain + +Pain + +1173 +
+Neuropathy + +Pain/Neurology + +1174 +
+Opioids + +Pain + +1182 +
+Acute kidney injury + +Kidney + +1163 +
+Chronic kidney disease + +Kidney + +1191 +
+Asthma + +Respiratory + +1164 +
+Chronic obstructive pulmonary disorder (COPD) + +Respiratory + +1192 +
+Dyspnea + +Respiratory + +1195 +
+Respiratory failure + +Respiratory + +1177 +
+Sleep apnea + +Respiratory + +1167 +
+Rheumatoid arthritis + +Rheumatology + +1200 +
+Steroids + +Rheumatology/Pain/Pulmonary + +1181 +
+Peripheral vascular disease + +Vascular + +1157 +
+Aspirin + +Vascular + +1158 +
+Deep vein thrombosis (DVT) + +Vascular + +1152 +
+Edema + +Vascular + +1196 +
+Inpatient visit + +NA -ATLAS link +NA