From b4de2d87e7e7034454ad4ca6fdc246ff6a57aff5 Mon Sep 17 00:00:00 2001 From: Marta Alcalde-Herraiz <91142894+martaalcalde@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:43:36 +0000 Subject: [PATCH 1/4] Create mockPhenotypeR --- NAMESPACE | 1 + R/addCodelistAttribute.R | 16 ++--------- R/codelistDiagnostics.R | 17 ++---------- R/cohortDiagnostics.R | 18 ++---------- R/databaseDiagnostics.R | 23 +++------------ R/matchedDiagnostics.R | 20 ++----------- R/mockPhenotypeR.R | 54 ++++++++++++++++++++++++++++++++++++ R/phenotypeDiagnostics.R | 21 ++------------ R/populationDiagnostics.R | 20 ++----------- R/shinyDiagnostics.R | 23 ++------------- man/PhenotypeR-package.Rd | 2 +- man/addCodelistAttribute.Rd | 10 +++++-- man/codelistDiagnostics.Rd | 22 ++++++--------- man/cohortDiagnostics.Rd | 23 ++++----------- man/databaseDiagnostics.Rd | 22 +++++---------- man/matchedDiagnostics.Rd | 23 ++++----------- man/mockPhenotypeR.Rd | 37 ++++++++++++++++++++++++ man/phenotypeDiagnostics.Rd | 23 ++++----------- man/populationDiagnostics.Rd | 21 ++++++++++---- man/shinyDiagnostics.Rd | 25 ++++++----------- 20 files changed, 175 insertions(+), 246 deletions(-) create mode 100644 R/mockPhenotypeR.R create mode 100644 man/mockPhenotypeR.Rd diff --git a/NAMESPACE b/NAMESPACE index 40c6ec5..0210976 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(databaseDiagnostics) export(exportSummarisedResult) export(importSummarisedResult) export(matchedDiagnostics) +export(mockPhenotypeR) export(phenotypeDiagnostics) export(populationDiagnostics) export(settings) diff --git a/R/addCodelistAttribute.R b/R/addCodelistAttribute.R index f66be54..dc66776 100644 --- a/R/addCodelistAttribute.R +++ b/R/addCodelistAttribute.R @@ -18,23 +18,11 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockCohort() +#' cdm <- mockPhenotypeR() #' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" -#' -#' cohort <- addCodelistAttribute(cohort = cdm$cohort, codelist = list("cohort_1" = 1L)) +#' cohort <- addCodelistAttribute(cohort = cdm$my_cohort, codelist = list("cohort_1" = 1L)) #' attr(cohort, "cohort_codelist") #' #' CDMConnector::cdm_disconnect(cdm) diff --git a/R/codelistDiagnostics.R b/R/codelistDiagnostics.R index 75327b0..823ab8d 100644 --- a/R/codelistDiagnostics.R +++ b/R/codelistDiagnostics.R @@ -18,29 +18,16 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(CohortConstructor) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() -#' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" +#' cdm <- mockPhenotypeR() #' #' cdm$arthropathies <- conceptCohort(cdm, #' conceptSet = list("arthropathies" = c(40475132)), #' name = "arthropathies") #' -#' result <- cdm$arthropathies |> -#' codelistDiagnostics() +#' result <- codelistDiagnostics(cdm$arthropathies) #' #' CDMConnector::cdmDisconnect(cdm = cdm) #' } diff --git a/R/cohortDiagnostics.R b/R/cohortDiagnostics.R index 59c51ea..a228d2b 100644 --- a/R/cohortDiagnostics.R +++ b/R/cohortDiagnostics.R @@ -16,25 +16,11 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockVisitOccurrence() |> -#' mockCohort(name = "my_cohort") +#' cdm <- mockPhenotypeR() #' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" -#' -#' cdm$my_cohort |> cohortDiagnostics() +#' result <- cohortDiagnostics(cdm$my_cohort) #' #' CDMConnector::cdmDisconnect(cdm = cdm) #' } diff --git a/R/databaseDiagnostics.R b/R/databaseDiagnostics.R index fa8dd72..23a8e98 100644 --- a/R/databaseDiagnostics.R +++ b/R/databaseDiagnostics.R @@ -14,27 +14,12 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockDrugExposure() |> -#' mockObservation() |> -#' mockMeasurement() |> -#' mockCohort(name = "my_cohort", numberCohorts = 2) -#' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" -#' -#' db_diag <- databaseDiagnostics(cdm) +#' cdm <- mockPhenotypeR() +#' +#' result <- databaseDiagnostics(cdm) +#' #' CDMConnector::cdmDisconnect(cdm = cdm) #' } databaseDiagnostics <- function(cdm){ diff --git a/R/matchedDiagnostics.R b/R/matchedDiagnostics.R index 1e3f8c7..7f5daf3 100644 --- a/R/matchedDiagnostics.R +++ b/R/matchedDiagnostics.R @@ -21,28 +21,12 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockDrugExposure() |> -#' mockObservation() |> -#' mockMeasurement() |> -#' mockVisitOccurrence() |> -#' mockCohort(name = "my_cohort") +#' cdm <- mockPhenotypeR() #' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" +#' result <- matchedDiagnostics(cdm$my_cohort) #' -#' result <- cdm$my_cohort |> phenotypeDiagnostics() #' CDMConnector::cdmDisconnect(cdm = cdm) #' } matchedDiagnostics <- function(cohort, diff --git a/R/mockPhenotypeR.R b/R/mockPhenotypeR.R new file mode 100644 index 0000000..70f039c --- /dev/null +++ b/R/mockPhenotypeR.R @@ -0,0 +1,54 @@ +#' Function to create a mock cdm reference for mockPhenotypeR +#' +#' @description +#' `mockPhenotypeR()` creates an example dataset that can be used to show how +#' the package works +#' +#' @param nPerson number of people in the cdm. +#' @param con A DBI connection to create the cdm mock object. +#' @param writeSchema Name of an schema on the same connection with writing +#' permissions. +#' +#' @return cdm object +#' @export +#' +#' @examples +#' \donttest{ +#' library(PhenotypeR) +#' +#' cdm <- mockPhenotypeR() +#' +#' cdm +#' } +mockPhenotypeR <- function(nPerson = 100, + con = DBI::dbConnect(duckdb::duckdb()), + writeSchema = "main", + seed = 111){ + + omopgenerics::assertNumeric(nPerson, length = 1, na = FALSE, null = FALSE) + omopgenerics::assertNumeric(seed, length = 1, na = FALSE, null = FALSE) + omopgenerics::assertCharacter(writeSchema, length = 1, na = FALSE, null = FALSE) + + cdm_local <- omock::mockCdmReference() |> + omock::mockPerson(nPerson = 100, seed = seed) |> + omock::mockObservationPeriod(seed = seed) |> + omock::mockConditionOccurrence(seed = seed) |> + omock::mockVisitOccurrence(seed = seed) |> + omock::mockDrugExposure(seed = seed) |> + omock::mockObservation(seed = seed) |> + omock::mockMeasurement(seed = seed) |> + omock::mockProcedureOccurrence(seed = seed) |> + omock::mockCohort(name = "my_cohort", numberCohorts = 2) + + cdm <- CDMConnector::copy_cdm_to(con = con, + cdm = cdm_local, + schema = writeSchema, + overwrite = TRUE) + attr(cdm, "write_schema") <- writeSchema + + return(cdm) +} + + + + diff --git a/R/phenotypeDiagnostics.R b/R/phenotypeDiagnostics.R index 7848214..7eaa408 100644 --- a/R/phenotypeDiagnostics.R +++ b/R/phenotypeDiagnostics.R @@ -25,29 +25,12 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 100) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockDrugExposure() |> -#' mockObservation() |> -#' mockMeasurement() |> -#' mockVisitOccurrence() |> -#' mockProcedureOccurrence() |> -#' mockCohort(name = "my_cohort") +#' cdm <- mockPhenotypeR() #' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" +#' result <- phenotypeDiagnostics(cdm$my_cohort) #' -#' result <- cdm$my_cohort |> phenotypeDiagnostics() #' CDMConnector::cdmDisconnect(cdm = cdm) #' } phenotypeDiagnostics <- function(cohort, diff --git a/R/populationDiagnostics.R b/R/populationDiagnostics.R index 05e177d..2271707 100644 --- a/R/populationDiagnostics.R +++ b/R/populationDiagnostics.R @@ -15,27 +15,10 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' library(dplyr) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 1000) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockDrugExposure() |> -#' mockObservation() |> -#' mockMeasurement() |> -#' mockVisitOccurrence() |> -#' mockCohort(name = "my_cohort") -#' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" +#' cdm <- mockPhenotypeR() #' #' dateStart <- cdm$my_cohort |> #' summarise(start = min(cohort_start_date, na.rm = TRUE)) |> @@ -46,6 +29,7 @@ #' #' result <- cdm$my_cohort |> #' populationDiagnostics(populationDateRange = c(dateStart, dateEnd)) +#' #' CDMConnector::cdmDisconnect(cdm = cdm) #' } populationDiagnostics <- function(cohort, diff --git a/R/shinyDiagnostics.R b/R/shinyDiagnostics.R index d3e958a..3f28ce1 100644 --- a/R/shinyDiagnostics.R +++ b/R/shinyDiagnostics.R @@ -21,30 +21,11 @@ #' #' @examples #' \donttest{ -#' library(omock) -#' library(CDMConnector) -#' library(DBI) #' library(PhenotypeR) #' -#' cdm_local <- mockCdmReference() |> -#' mockPerson(nPerson = 1000) |> -#' mockObservationPeriod() |> -#' mockConditionOccurrence() |> -#' mockDrugExposure() |> -#' mockObservation() |> -#' mockMeasurement() |> -#' mockVisitOccurrence() |> -#' mockProcedureOccurrence() |> -#' mockCohort(name = "my_cohort") +#' cdm <- mockPhenotypeR() #' -#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:") -#' cdm <- CDMConnector::copy_cdm_to(con = con, -#' cdm = cdm_local, -#' schema = "main") -#' attr(cdm, "write_schema") <- "main" -#' -#' result <- cdm$my_cohort |> -#' phenotypeDiagnostics() +#' result <- phenotypeDiagnostics(cdm$my_cohort) #' #' shinyDiagnostics(result, tempdir()) #' diff --git a/man/PhenotypeR-package.Rd b/man/PhenotypeR-package.Rd index 96d840c..5b6c3b7 100644 --- a/man/PhenotypeR-package.Rd +++ b/man/PhenotypeR-package.Rd @@ -8,7 +8,7 @@ \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} -Phenotype study cohorts in data mapped to the Observational Medical Outcomes Partnership Common Data Model. Diagnostics are run at the database, codelist, cohort, and population level to assess whether study cohorts are ready for research. +Phenotype study cohorts in data mapped to the Observational Medical Outcomes Partnership Common Data Model. Diagnostics are run at the database, code list, cohort, and population level to assess whether study cohorts are ready for research. } \seealso{ Useful links: diff --git a/man/addCodelistAttribute.Rd b/man/addCodelistAttribute.Rd index fed909b..5d47780 100644 --- a/man/addCodelistAttribute.Rd +++ b/man/addCodelistAttribute.Rd @@ -27,9 +27,13 @@ underlying assumption is that the cohort that is fed into } \examples{ \donttest{ -library(IncidencePrevalence) -cdm <- mockIncidencePrevalenceRef(sampleSize = 1000) -cohort <- addCodelistAttribute(cohort = cdm$outcome, codelist = list("cohort_1" = 1L)) +library(PhenotypeR) + +cdm <- mockPhenotypeR() + +cohort <- addCodelistAttribute(cohort = cdm$my_cohort, codelist = list("cohort_1" = 1L)) +attr(cohort, "cohort_codelist") + CDMConnector::cdm_disconnect(cdm) } } diff --git a/man/codelistDiagnostics.Rd b/man/codelistDiagnostics.Rd index 6848301..3bea89c 100644 --- a/man/codelistDiagnostics.Rd +++ b/man/codelistDiagnostics.Rd @@ -25,23 +25,17 @@ the cdm so that concept counts could be derived. } \examples{ \donttest{ - cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockCohort(name = "my_cohort") +library(CohortConstructor) +library(PhenotypeR) - db <- DBI::dbConnect(duckdb::duckdb()) +cdm <- mockPhenotypeR() - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) +cdm$arthropathies <- conceptCohort(cdm, + conceptSet = list("arthropathies" = c(40475132)), + name = "arthropathies") - result <- cdm$my_cohort |> - codelistDiagnostics() +result <- codelistDiagnostics(cdm$arthropathies) - CDMConnector::cdmDisconnect(cdm = cdm) +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/cohortDiagnostics.Rd b/man/cohortDiagnostics.Rd index 2401875..6b81d9b 100644 --- a/man/cohortDiagnostics.Rd +++ b/man/cohortDiagnostics.Rd @@ -23,23 +23,12 @@ The diganostics include: } \examples{ \donttest{ -cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockObservation() |> - omock::mockMeasurement() |> - omock::mockVisitOccurrence() |> - omock::mockProcedureOccurrence() |> - omock::mockCohort(name = "my_cohort") - db <- DBI::dbConnect(duckdb::duckdb()) - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) +library(PhenotypeR) - cdm$my_cohort |> cohortDiagnostics() - CDMConnector::cdmDisconnect(cdm = cdm) +cdm <- mockPhenotypeR() + +result <- cohortDiagnostics(cdm$my_cohort) + +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/databaseDiagnostics.Rd b/man/databaseDiagnostics.Rd index ee9a990..0238da7 100644 --- a/man/databaseDiagnostics.Rd +++ b/man/databaseDiagnostics.Rd @@ -21,20 +21,12 @@ Diagnostics include: } \examples{ \donttest{ - cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockObservation() |> - omock::mockMeasurement() |> - omock::mockCohort(name = "my_cohort", numberCohorts = 2) - db <- DBI::dbConnect(duckdb::duckdb()) - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) - db_diag <- databaseDiagnostics(cdm) - CDMConnector::cdmDisconnect(cdm = cdm) +library(PhenotypeR) + +cdm <- mockPhenotypeR() + +result <- databaseDiagnostics(cdm) + +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/matchedDiagnostics.Rd b/man/matchedDiagnostics.Rd index 4e7000f..cb90f32 100644 --- a/man/matchedDiagnostics.Rd +++ b/man/matchedDiagnostics.Rd @@ -30,23 +30,12 @@ a large scale charactersitics using the following domians of OMOP CDM: } \examples{ \donttest{ -cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockObservation() |> - omock::mockMeasurement() |> - omock::mockVisitOccurrence() |> - omock::mockProcedureOccurrence() |> - omock::mockCohort(name = "my_cohort") +library(PhenotypeR) - db <- DBI::dbConnect(duckdb::duckdb()) - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) - result <- cdm$my_cohort |> matchedDiagnostics() - CDMConnector::cdm_disconnect(cdm) +cdm <- mockPhenotypeR() + +result <- matchedDiagnostics(cdm$my_cohort) + +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/mockPhenotypeR.Rd b/man/mockPhenotypeR.Rd new file mode 100644 index 0000000..2c0e839 --- /dev/null +++ b/man/mockPhenotypeR.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mockPhenotypeR.R +\name{mockPhenotypeR} +\alias{mockPhenotypeR} +\title{Function to create a mock cdm reference for mockPhenotypeR} +\usage{ +mockPhenotypeR( + nPerson = 100, + con = DBI::dbConnect(duckdb::duckdb()), + writeSchema = "main", + seed = 111 +) +} +\arguments{ +\item{nPerson}{number of people in the cdm.} + +\item{con}{A DBI connection to create the cdm mock object.} + +\item{writeSchema}{Name of an schema on the same connection with writing +permissions.} +} +\value{ +cdm object +} +\description{ +`mockPhenotypeR()` creates an example dataset that can be used to show how +the package works +} +\examples{ +\donttest{ +library(PhenotypeR) + +cdm <- mockPhenotypeR() + +cdm +} +} diff --git a/man/phenotypeDiagnostics.Rd b/man/phenotypeDiagnostics.Rd index df2af28..3ce8f00 100644 --- a/man/phenotypeDiagnostics.Rd +++ b/man/phenotypeDiagnostics.Rd @@ -58,23 +58,12 @@ this includes: } \examples{ \donttest{ -cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockObservation() |> - omock::mockMeasurement() |> - omock::mockVisitOccurrence() |> - omock::mockProcedureOccurrence() |> - omock::mockCohort(name = "my_cohort") +library(PhenotypeR) - db <- DBI::dbConnect(duckdb::duckdb()) - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) - phenotypeDiagnostics(cdm$my_cohort) - CDMConnector::cdm_disconnect(cdm) +cdm <- mockPhenotypeR() + +result <- phenotypeDiagnostics(cdm$my_cohort) + +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/populationDiagnostics.Rd b/man/populationDiagnostics.Rd index 663afdb..3a3ca56 100644 --- a/man/populationDiagnostics.Rd +++ b/man/populationDiagnostics.Rd @@ -35,10 +35,21 @@ population. Diagnostics include: } \examples{ \donttest{ -library(IncidencePrevalence) -cdm <- mockIncidencePrevalenceRef(sampleSize = 1000) -pop_diag <- populationDiagnostics(cohort = cdm$outcome, - populationSample = 250) -CDMConnector::cdm_disconnect(cdm) +library(PhenotypeR) +library(dplyr) + +cdm <- mockPhenotypeR() + +dateStart <- cdm$my_cohort |> + summarise(start = min(cohort_start_date, na.rm = TRUE)) |> + pull("start") +dateEnd <- cdm$my_cohort |> + summarise(start = max(cohort_start_date, na.rm = TRUE)) |> + pull("start") + +result <- cdm$my_cohort |> + populationDiagnostics(populationDateRange = c(dateStart, dateEnd)) + +CDMConnector::cdmDisconnect(cdm = cdm) } } diff --git a/man/shinyDiagnostics.Rd b/man/shinyDiagnostics.Rd index 30b5e2f..b6dff61 100644 --- a/man/shinyDiagnostics.Rd +++ b/man/shinyDiagnostics.Rd @@ -29,23 +29,14 @@ includes: } \examples{ \donttest{ -cdm_local <- omock::mockCdmReference() |> - omock::mockPerson(nPerson = 100) |> - omock::mockObservationPeriod() |> - omock::mockConditionOccurrence() |> - omock::mockDrugExposure() |> - omock::mockObservation() |> - omock::mockMeasurement() |> - omock::mockVisitOccurrence() |> - omock::mockProcedureOccurrence() |> - omock::mockCohort(name = "my_cohort") +library(PhenotypeR) - db <- DBI::dbConnect(duckdb::duckdb()) - cdm <- CDMConnector::copyCdmTo(con = db, - cdm = cdm_local, - schema ="main", - overwrite = TRUE) - my_result_cohort_diag <- cdm$my_cohort |> phenotypeDiagnostics() - shinyDiagnostics(my_result_cohort_diag, tempdir()) +cdm <- mockPhenotypeR() + +result <- phenotypeDiagnostics(cdm$my_cohort) + +shinyDiagnostics(result, tempdir()) + +CDMConnector::cdmDisconnect(cdm = cdm) } } From 5bbff208126b10932519ff040e855a2dc5623295 Mon Sep 17 00:00:00 2001 From: Marta Alcalde-Herraiz <91142894+martaalcalde@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:52:22 +0000 Subject: [PATCH 2/4] add mockPhenotypeR() to pkgdown --- R/mockPhenotypeR.R | 1 + _pkgdown.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/R/mockPhenotypeR.R b/R/mockPhenotypeR.R index 70f039c..c3b427f 100644 --- a/R/mockPhenotypeR.R +++ b/R/mockPhenotypeR.R @@ -8,6 +8,7 @@ #' @param con A DBI connection to create the cdm mock object. #' @param writeSchema Name of an schema on the same connection with writing #' permissions. +#' @param seed seed to use when creating the mock data. #' #' @return cdm object #' @export diff --git a/_pkgdown.yml b/_pkgdown.yml index af35030..bfcfc22 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -19,3 +19,6 @@ reference: - subtitle: Codelist diagnostics helper - contents: - matches("addCodelistAttribute") +- subtitle: Mock data +- contents: + - matches("mockPhenotypeR") From 02c2b0105400845c364a7b1cadf46088f5764f73 Mon Sep 17 00:00:00 2001 From: Marta Alcalde-Herraiz <91142894+martaalcalde@users.noreply.github.com> Date: Fri, 13 Dec 2024 20:04:38 +0000 Subject: [PATCH 3/4] Update mockPhenotypeR.Rd --- man/mockPhenotypeR.Rd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/mockPhenotypeR.Rd b/man/mockPhenotypeR.Rd index 2c0e839..91a4e3a 100644 --- a/man/mockPhenotypeR.Rd +++ b/man/mockPhenotypeR.Rd @@ -18,6 +18,8 @@ mockPhenotypeR( \item{writeSchema}{Name of an schema on the same connection with writing permissions.} + +\item{seed}{seed to use when creating the mock data.} } \value{ cdm object From ffa89687eeeaf86ad258ccedb124b0050207f361 Mon Sep 17 00:00:00 2001 From: Marta Alcalde-Herraiz <91142894+martaalcalde@users.noreply.github.com> Date: Sat, 14 Dec 2024 11:27:50 +0000 Subject: [PATCH 4/4] Remove ggpol from description --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 14bb175..cbef9b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,7 +47,6 @@ Suggests: shinyWidgets, plotly, tidyr, - ggpol, scales Config/testthat/edition: 3 RoxygenNote: 7.3.2