From aba2fcee3ee7e3972ff063da4f4136ec9d364b4e Mon Sep 17 00:00:00 2001 From: Gowtham Rao Date: Sun, 24 Sep 2023 08:32:24 -0400 Subject: [PATCH] Release Version: 3.22.1 - getPhenotypeLog() now returns the original user submitted cohort name, instead of the name forced by atlas-phenotype. - This is in line with the original requirement. It allows for long names, names with special characters. - Deprecated listPhenotypes(). This was an older function that did the same as getPhenotypeLog() but returned only two fields. - Added requirement on R (4.10) because tidyverse seems to cause problems with older versions of R. --- DESCRIPTION | 6 +- NAMESPACE | 1 - NEWS.md | 10 ++ R/PhenotypeLibrary.R | 1 - R/Phenotypes.R | 94 +++++++++++++++--- docs/404.html | 2 +- ...ohortDefinitionSubmissionRequirements.html | 4 +- ...ortDefinitionsInOhdsiPhenotypeLibrary.html | 8 +- ...icalDescriptionForConditionPhenotypes.html | 4 +- .../GuidanceOnCohortDefinitionSetRObject.html | 4 +- docs/articles/GuidanceOnLiteratureReview.html | 4 +- .../GuidanceOnPerformingPeerReview.html | 4 +- .../GuidanceOnWritingAnEvaluationReport.html | 4 +- ...itingCohortDefinitionLogicDescription.html | 4 +- .../HowToUsePhenotypeLibraryRPackage.html | 52 +++++----- ...dWordsWithSpecialMeaningToPhenotypers.html | 4 +- docs/articles/SubmittedCohortDefinitions.html | 4 +- .../ValidityChecksForCohortDefinitions.html | 4 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 9 +- docs/pkgdown.yml | 2 +- docs/reference/PhenotypeLibrary-package.html | 2 +- docs/reference/getPhenotypeLog.html | 26 ++--- docs/reference/getPlCohortDefinitionSet.html | 14 +-- docs/reference/getPlConceptDefinitionSet.html | 26 ++--- docs/reference/index.html | 4 +- docs/reference/listPhenotypes.html | 50 +++++----- extras/PhenotypeLibrary.pdf | Bin 85054 -> 85774 bytes ...CohortDefinitionSubmissionRequirements.pdf | Bin 156645 -> 156767 bytes ...hortDefinitionsInOhdsiPhenotypeLibrary.pdf | Bin 115942 -> 116055 bytes ...nicalDescriptionForConditionPhenotypes.pdf | Bin 144875 -> 144988 bytes .../GuidanceOnCohortDefinitionSetRObject.pdf | Bin 204530 -> 204644 bytes inst/doc/GuidanceOnLiteratureReview.pdf | Bin 114483 -> 114592 bytes inst/doc/GuidanceOnPerformingPeerReview.pdf | Bin 157134 -> 157242 bytes .../GuidanceOnWritingAnEvaluationReport.pdf | Bin 117843 -> 117956 bytes inst/doc/HowToUsePhenotypeLibraryRPackage.pdf | Bin 196921 -> 196968 bytes ...edWordsWithSpecialMeaningToPhenotypers.pdf | Bin 148701 -> 148812 bytes inst/doc/SubmittedCohortDefinitions.pdf | Bin 150609 -> 150727 bytes .../ValidityChecksForCohortDefinitions.pdf | Bin 127495 -> 127619 bytes man/getPhenotypeLog.Rd | 2 +- man/getPlCohortDefinitionSet.Rd | 2 +- man/getPlConceptDefinitionSet.Rd | 2 +- man/listPhenotypes.Rd | 5 +- tests/testthat/test-PhenotypeLibrary.R | 12 +++ ...hortDefinitionsInOhdsiPhenotypeLibrary.Rmd | 22 +--- .../HowToUsePhenotypeLibraryRPackage.Rmd | 2 +- 48 files changed, 239 insertions(+), 161 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b21ba21f..0c838226 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,13 @@ Package: PhenotypeLibrary Type: Package Title: The OHDSI Phenotype Library -Version: 3.22.0 -Date: 2023-09-23 +Version: 3.22.1 +Date: 2023-09-24 Author: Gowtham Rao [aut, cre] Maintainer: Gowtham Rao Description: A repository to store the content of the OHDSI Phenotype library. +Depends: + R (>= 4.1.0) Imports: checkmate, readr, diff --git a/NAMESPACE b/NAMESPACE index e1172515..ad0f0bf9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,5 +4,4 @@ export(getPhenotypeLog) export(getPlCohortDefinitionSet) export(getPlConceptDefinitionSet) export(listPhenotypes) -import(dplyr) importFrom(rlang,.data) diff --git a/NEWS.md b/NEWS.md index 5fd2e896..408bb097 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +PhenotypeLibrary 3.22.1 +====================== + +- getPhenotypeLog() now returns the original user submitted cohort name, instead of the name forced by atlas-phenotype. +- This is in line with the original requirement. It allows for long names, names with special characters. + +- Deprecated listPhenotypes(). This was an older function that did the same as getPhenotypeLog() but returned only two fields. + +- Added requirement on R (4.10) because tidyverse seems to cause problems with older versions of R. + PhenotypeLibrary 3.22.0 ====================== Accepted Cohorts: No cohorts were accepted in this release. diff --git a/R/PhenotypeLibrary.R b/R/PhenotypeLibrary.R index 5fccca46..99df1f5f 100644 --- a/R/PhenotypeLibrary.R +++ b/R/PhenotypeLibrary.R @@ -17,6 +17,5 @@ #' @keywords internal "_PACKAGE" -#' @import dplyr #' @importFrom rlang .data NULL diff --git a/R/Phenotypes.R b/R/Phenotypes.R index f8f8f152..144f389a 100644 --- a/R/Phenotypes.R +++ b/R/Phenotypes.R @@ -14,18 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -#' List all phenotypes in the library +#' Deprecated. List all phenotypes in the library. #' #' @return #' A tibble with the cohort ID and name. +#' Deprecated. Please use getPhenotypeLog #' #' @examples #' listPhenotypes() #' #' @export listPhenotypes <- function() { - cohorts <- readr::read_csv(system.file("Cohorts.csv", package = "PhenotypeLibrary"), col_types = readr::cols()) - return(cohorts) + .Deprecated( + new = "getPhenotypeLog", + msg = "listPhenotypes is deprecated. use getPhenotypeLog" + ) + getPhenotypeLog() } #' Get a cohort definition set @@ -37,7 +41,7 @@ listPhenotypes <- function() { #' `CohortGenerator` package. #' #' @examples -#' cohorts <- listPhenotypes() +#' cohorts <- getPhenotypeLog() #' subsetIds <- cohorts$cohortId[1:3] #' getPlCohortDefinitionSet(subsetIds) #' @@ -47,8 +51,8 @@ getPlCohortDefinitionSet <- function(cohortIds) { checkmate::assertIntegerish(cohortIds, min.len = 1, add = errorMessages) checkmate::reportAssertions(collection = errorMessages) - cohorts <- listPhenotypes() |> - filter(.data$cohortId %in% cohortIds) |> + cohorts <- getPhenotypeLog() |> + dplyr::filter(.data$cohortId %in% cohortIds) |> dplyr::select( "cohortId", "cohortName" @@ -68,7 +72,7 @@ getPlCohortDefinitionSet <- function(cohortIds) { sql <- readFile(file.path(sqlFolder, paste0(cohorts$cohortId[i], ".sql"))) output <- cohorts[i, ] |> - mutate( + dplyr::mutate( json = !!json, sql = !!sql ) @@ -76,7 +80,7 @@ getPlCohortDefinitionSet <- function(cohortIds) { } result <- lapply(seq_len(nrow(cohorts)), getJsonAndSql) |> - bind_rows() + dplyr::bind_rows() return(result) } @@ -98,19 +102,48 @@ getPlCohortDefinitionSet <- function(cohortIds) { #' getPhenotypeLog(cohortIds = c(1, 2)) #' #' @export -getPhenotypeLog <- function(cohortIds = listPhenotypes()$cohortId) { - log <- - readr::read_csv( - system.file("Cohorts.csv", package = "PhenotypeLibrary"), +getPhenotypeLog <- function(cohortIds = NULL) { + checkmate::assertIntegerish(cohortIds, + min.len = 0, + null.ok = TRUE + ) + + cohorts <- + readr::read_csv(system.file("Cohorts.csv", package = "PhenotypeLibrary"), col_types = readr::cols() ) |> - dplyr::filter(.data$cohortId %in% c(cohortIds)) |> + dplyr::mutate( + newCohortName = dplyr::case_when( + !is.na(.data$cohortNameLong) & + cohortNameLong != "" ~ .data$cohortNameLong, !is.na(.data$cohortNameFormatted) & + cohortNameFormatted != "" ~ .data$cohortNameFormatted, + TRUE ~ .data$cohortName + ) + ) |> + dplyr::rename( + cohortNameAtlas = .data$cohortName, + cohortName = .data$newCohortName + ) |> + dplyr::relocate( + .data$cohortId, + .data$cohortName + ) |> + dplyr::arrange(.data$cohortId) + + cohorts <- transformColumns(cohorts) + + cohorts <- cohorts |> dplyr::mutate( addedDate = as.Date(.data$createdDate), updatedDate = as.Date(.data$modifiedDate) ) |> dplyr::arrange(.data$cohortId) - return(log) + + if (!is.null(cohortIds)) { + cohorts <- cohorts |> + dplyr::filter(.data$cohortId %in% c(cohortIds)) + } + return(cohorts) } @@ -130,9 +163,40 @@ getPhenotypeLog <- function(cohortIds = listPhenotypes()$cohortId) { #' #' @export getPlConceptDefinitionSet <- - function(cohortIds = listPhenotypes()$cohortId) { + function(cohortIds = getPhenotypeLog()$cohortId) { conceptSets <- system.file("ConceptSetsInCohortDefinition.RDS", package = "PhenotypeLibrary") |> readRDS() + + if (!is.null(cohortIds)) { + conceptSets <- conceptSets |> + dplyr::filter(.data$cohortId %in% c(cohortIds)) + } + + conceptSets <- transformColumns(df = conceptSets) + return(conceptSets) } + + +# Function to transform columns based on conditions +transformColumns <- function(df) { + # Iterate through each column + for (col_name in names(df)) { + col_data <- df[[col_name]] + + # If column contains alphabets + if (any(grepl("[a-zA-Z]", col_data, ignore.case = TRUE))) { + # Replace NA with empty string + df[[col_name]][is.na(df[[col_name]])] <- "" + } + + # If column contains only 0, 1, and NA + else if (all(col_data %in% c(0, 1, NA))) { + # Replace NA with 0 + df[[col_name]][is.na(df[[col_name]])] <- 0 + } + } + return(df |> + dplyr::tibble()) +} diff --git a/docs/404.html b/docs/404.html index 52dff506..8e1d69bf 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 diff --git a/docs/articles/CohortDefinitionSubmissionRequirements.html b/docs/articles/CohortDefinitionSubmissionRequirements.html index 6184cccf..e1149d77 100644 --- a/docs/articles/CohortDefinitionSubmissionRequirements.html +++ b/docs/articles/CohortDefinitionSubmissionRequirements.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

Cohort Definition Submission Requirements

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/CohortDefinitionSubmissionRequirements.Rmd diff --git a/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html b/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html index e16f5029..8227929b 100644 --- a/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html +++ b/docs/articles/CohortDefinitionsInOhdsiPhenotypeLibrary.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -120,7 +120,7 @@

Cohort Definitions in OHDSI Phenotype

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/CohortDefinitionsInOhdsiPhenotypeLibrary.Rmd @@ -129,8 +129,8 @@

2023-09-23

-
- +
+ @@ -119,7 +119,7 @@

Guidance on writing clinical description for

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnClinicalDescriptionForConditionPhenotypes.Rmd diff --git a/docs/articles/GuidanceOnCohortDefinitionSetRObject.html b/docs/articles/GuidanceOnCohortDefinitionSetRObject.html index e27465ae..c07691f7 100644 --- a/docs/articles/GuidanceOnCohortDefinitionSetRObject.html +++ b/docs/articles/GuidanceOnCohortDefinitionSetRObject.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

Guidance on Cohort Definition Set R Object

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnCohortDefinitionSetRObject.Rmd diff --git a/docs/articles/GuidanceOnLiteratureReview.html b/docs/articles/GuidanceOnLiteratureReview.html index 99caca96..551e2deb 100644 --- a/docs/articles/GuidanceOnLiteratureReview.html +++ b/docs/articles/GuidanceOnLiteratureReview.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

Guidance on literature review

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnLiteratureReview.Rmd diff --git a/docs/articles/GuidanceOnPerformingPeerReview.html b/docs/articles/GuidanceOnPerformingPeerReview.html index 198a752a..ebc60c3b 100644 --- a/docs/articles/GuidanceOnPerformingPeerReview.html +++ b/docs/articles/GuidanceOnPerformingPeerReview.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

Guidance on performing peer review

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnPerformingPeerReview.Rmd diff --git a/docs/articles/GuidanceOnWritingAnEvaluationReport.html b/docs/articles/GuidanceOnWritingAnEvaluationReport.html index fa0c1b85..b13a1a2e 100644 --- a/docs/articles/GuidanceOnWritingAnEvaluationReport.html +++ b/docs/articles/GuidanceOnWritingAnEvaluationReport.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

Guidance on writing an evaluation report

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnWritingAnEvaluationReport.Rmd diff --git a/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html b/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html index 4d5257cf..de30553b 100644 --- a/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html +++ b/docs/articles/GuidanceOnWritingCohortDefinitionLogicDescription.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -119,7 +119,7 @@

Guidance on writing Cohort Definition Logic

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/GuidanceOnWritingCohortDefinitionLogicDescription.Rmd diff --git a/docs/articles/HowToUsePhenotypeLibraryRPackage.html b/docs/articles/HowToUsePhenotypeLibraryRPackage.html index 1fc5a86e..56ccb7f0 100644 --- a/docs/articles/HowToUsePhenotypeLibraryRPackage.html +++ b/docs/articles/HowToUsePhenotypeLibraryRPackage.html @@ -33,7 +33,7 @@ PhenotypeLibrary - 3.22.0 + 3.22.1 @@ -118,7 +118,7 @@

How to Use PhenotypeLibrary R Package

Gowtham A. Rao

-

2023-09-23

+

2023-09-24

Source: vignettes/HowToUsePhenotypeLibraryRPackage.Rmd @@ -147,27 +147,27 @@

Retrieval
-PhenotypeLibrary::listPhenotypes()
-
#> # A tibble: 869 x 72
-#>    cohortId cohortName       cohortNameFormatted cohortNameLong librarian status
-#>       <dbl> <chr>            <chr>               <chr>          <chr>     <chr> 
-#>  1        2 [W] COVID-19 di~ COVID-19 diagnosis~ COVID-19 diag~ rao@ohds~ Withd~
-#>  2        3 [P] Cough or Sp~ Cough or Sputum     Cough or Sput~ rao@ohds~ Pendi~
-#>  3        4 [P] Diarrhea     Diarrhea            Diarrhea       rao@ohds~ Pendi~
-#>  4        5 [P] Dyspnea      Dyspnea             Dyspnea        rao@ohds~ Pendi~
-#>  5        6 [P] Fever        Fever               Fever          rao@ohds~ Pendi~
-#>  6        7 [P] Headache or~ Headache or Headac~ Headache or H~ rao@ohds~ Pendi~
-#>  7        8 [P] Altered sme~ Altered smell or t~ Altered smell~ rao@ohds~ Pendi~
-#>  8        9 [P] Sore throat  Sore throat         Sore throat    rao@ohds~ Pendi~
-#>  9       10 [P] Nausea or V~ Nausea or Vomiting  Nausea or Vom~ rao@ohds~ Pendi~
-#> 10       11 [P] Malaise and~ Malaise and or fat~ Malaise and o~ rao@ohds~ Pendi~
+PhenotypeLibrary::getPhenotypeLog()
+
#> # A tibble: 869 x 75
+#>    cohortId cohortName        cohortNameAtlas cohortNameFormatted cohortNameLong
+#>       <dbl> <chr>             <chr>           <chr>               <chr>         
+#>  1        2 COVID-19 diagnos~ [W] COVID-19 d~ COVID-19 diagnosis~ COVID-19 diag~
+#>  2        3 Cough or Sputum   [P] Cough or S~ Cough or Sputum     Cough or Sput~
+#>  3        4 Diarrhea          [P] Diarrhea    Diarrhea            Diarrhea      
+#>  4        5 Dyspnea           [P] Dyspnea     Dyspnea             Dyspnea       
+#>  5        6 Fever             [P] Fever       Fever               Fever         
+#>  6        7 Headache or Head~ [P] Headache o~ Headache or Headac~ Headache or H~
+#>  7        8 Altered smell or~ [P] Altered sm~ Altered smell or t~ Altered smell~
+#>  8        9 Sore throat       [P] Sore throat Sore throat         Sore throat   
+#>  9       10 Nausea or Vomiti~ [P] Nausea or ~ Nausea or Vomiting  Nausea or Vom~
+#> 10       11 Malaise and or f~ [P] Malaise an~ Malaise and or fat~ Malaise and o~
 #> # i 859 more rows
-#> # i 66 more variables: addedVersion <chr>, logicDescription <chr>,
-#> #   hashTag <chr>, isCirceJson <dbl>, contributors <chr>,
-#> #   contributorOrcIds <chr>, contributorOrganizations <chr>,
-#> #   peerReviewers <chr>, peerReviewerOrcIds <lgl>,
-#> #   recommendedReferentConceptIds <chr>, ohdsiForumPost <chr>,
-#> #   createdDate <date>, modifiedDate <date>, lastModifiedBy <lgl>, ...
+#> # i 70 more variables: librarian <chr>, status <chr>, addedVersion <chr>, +#> # logicDescription <chr>, hashTag <chr>, isCirceJson <dbl>, +#> # contributors <chr>, contributorOrcIds <chr>, +#> # contributorOrganizations <chr>, peerReviewers <chr>, +#> # peerReviewerOrcIds <dbl>, recommendedReferentConceptIds <chr>, +#> # ohdsiForumPost <chr>, createdDate <date>, modifiedDate <date>, ...