Skip to content

Commit

Permalink
Merge pull request #7 from oxford-pharmacoepi/dev_cc
Browse files Browse the repository at this point in the history
shine and code updated
  • Loading branch information
catalamarti authored Jan 13, 2025
2 parents d37d75b + ddc07ab commit 7a49f62
Show file tree
Hide file tree
Showing 23 changed files with 2,105 additions and 4,930 deletions.
27 changes: 15 additions & 12 deletions CharacterisationCode/RunCharacterisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ log_message("Start time recorded.")
tableName <- c("observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence",
"device_exposure", "measurement" , "observation", "death")
sex <- TRUE # FALSE
ageGroup <- list(c(0,19), c(20, 39),c(40, 59), c(60, 79), c(80, Inf) ) # NULL
ageGroup <- list(c(0,19), c(20, 39),c(40, 59), c(60, 79), c(80, Inf) )
ageGroup <- omopgenerics::validateAgeGroupArgument(ageGroup, ageGroupName = "")[[1]]
dateRange <- as.Date(c("2012-01-01", NA))

# Snapshot
log_message("Getting cdm snapshot")
snapshot <- OmopSketch::summariseOmopSnapshot(cdm)
Expand All @@ -30,6 +31,7 @@ result_populationCharacteristics <- CohortConstructor::demographicsCohort(cdm, "
CohortConstructor::requireInDateRange(dateRange = dateRange)|>
CohortCharacteristics::summariseCharacteristics(strata = list("sex", "age_group") )

# Summarise missing data
log_message("Summarising missing data")
result_missingData <- OmopSketch::summariseMissingData(cdm ,
omopTableName = tableName,
Expand All @@ -38,15 +40,16 @@ result_missingData <- OmopSketch::summariseMissingData(cdm ,
year = TRUE,
dateRange = dateRange)

log_message("Summarising all concept counts")
result_allConceptCount <- OmopSketch::summariseAllConceptCounts(cdm,
omopTableName = tableName,
sex = sex,
ageGroup = ageGroup,
year = TRUE,
dateRange = dateRange)
# Summarise concept counts
log_message("Summarising concept id counts")
result_conceptIdCount <- OmopSketch::summariseConceptIdCounts(cdm,
omopTableName = tableName,
sex = sex,
ageGroup = ageGroup,
year = TRUE,
dateRange = dateRange)

# Summarize clinical records
# Summarise clinical records
log_message("Summarising clinical records")
result_clinicalRecords<- OmopSketch::summariseClinicalRecords(cdm,
omopTableName = tableName,
Expand Down Expand Up @@ -77,15 +80,15 @@ result_inObservation <- OmopSketch::summariseInObservation(cdm$observation_perio



# Summarize observation period
# Summarise observation period
log_message("Summarising observation period")
result_observationPeriod <- OmopSketch::summariseObservationPeriod(cdm$observation_period,
sex = sex,
ageGroup = ageGroup,
dateRange = dateRange)

# Combine results and export
result <- omopgenerics::bind(snapshot, result_populationCharacteristics, result_missingData, result_allConceptCount, result_clinicalRecords, result_recordCounts, result_inObservation, result_observationPeriod)
result <- omopgenerics::bind(snapshot, result_populationCharacteristics, result_missingData, result_conceptIdCount, result_clinicalRecords, result_recordCounts, result_inObservation, result_observationPeriod)
omopgenerics::exportSummarisedResult(result, minCellCount = minCellCount, path = outputFolder, fileName = paste0(
"result_characterisation_", dbName, ".csv"))

Expand All @@ -96,7 +99,7 @@ dur <- abs(as.numeric(Sys.time() - start_time, units = "secs"))
log_message(paste("Study code finished. Code ran in", floor(dur / 60), "min and", dur %% 60 %/% 1, "sec"))

# Close connection
cdm_disconnect(cdm)
CDMConnector::cdmDisconnect(cdm)
log_message("Database connection closed")

# Zip the results
Expand Down
12 changes: 0 additions & 12 deletions CharacterisationCode/codeLocal.R

This file was deleted.

99 changes: 24 additions & 75 deletions CharacterisationCode/renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Packages": {
"CDMConnector": {
"Package": "CDMConnector",
"Version": "1.6.1",
"Version": "1.7.0",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
Expand All @@ -21,7 +21,6 @@
"cli",
"dbplyr",
"dplyr",
"fs",
"generics",
"glue",
"jsonlite",
Expand All @@ -35,10 +34,9 @@
"stringr",
"tidyr",
"tidyselect",
"waldo",
"withr"
],
"Hash": "1b6e550b3f742dab03099f3768595b98"
"Hash": "5233515358b0c45cd01e0d19573f0709"
},
"CohortCharacteristics": {
"Package": "CohortCharacteristics",
Expand Down Expand Up @@ -99,13 +97,9 @@
},
"OmopSketch": {
"Package": "OmopSketch",
"Version": "0.1.1",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteRepo": "OmopSketch",
"RemoteUsername": "OHDSI",
"RemoteSha": "24bcfb26100b03f55579ac973a3d8ca6a1bbe1c5",
"Version": "0.2.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"CDMConnector",
"CohortConstructor",
Expand All @@ -114,19 +108,20 @@
"cli",
"clock",
"dplyr",
"glue",
"lifecycle",
"omopgenerics",
"purrr",
"rlang",
"stringr",
"tibble",
"tidyr",
"visOmopResults"
"tidyr"
],
"Hash": "e26a42bbb901e8d9d3e972df3b9dddda"
"Hash": "0c37ddc951ee1dafd9ef3ef7998db507"
},
"PatientProfiles": {
"Package": "PatientProfiles",
"Version": "1.2.2",
"Version": "1.2.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
Expand All @@ -141,7 +136,7 @@
"stringr",
"tidyr"
],
"Hash": "87b3c5ddb1c4bc1f464115f610325c0e"
"Hash": "4f2cb7324f2d1d4f04a4aeb52fc6a200"
},
"R6": {
"Package": "R6",
Expand All @@ -165,13 +160,13 @@
},
"bit": {
"Package": "bit",
"Version": "4.5.0",
"Version": "4.5.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "5dc7b2677d65d0e874fc4aaf0e879987"
"Hash": "f89f074e0e49bf1dbe3eba0a15a91476"
},
"bit64": {
"Package": "bit64",
Expand Down Expand Up @@ -250,13 +245,13 @@
},
"cpp11": {
"Package": "cpp11",
"Version": "0.5.0",
"Version": "0.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "91570bba75d0c9d3f1040c835cee8fba"
"Hash": "9df43854f1c84685d095ed6270b52387"
},
"crayon": {
"Package": "crayon",
Expand Down Expand Up @@ -298,21 +293,6 @@
],
"Hash": "39b2e002522bfd258039ee4e889e0fd1"
},
"diffobj": {
"Package": "diffobj",
"Version": "0.3.5",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"crayon",
"methods",
"stats",
"tools",
"utils"
],
"Hash": "bcaa8b95f8d7d01a5dedfd959ce88ab8"
},
"dplyr": {
"Package": "dplyr",
"Version": "1.1.4",
Expand Down Expand Up @@ -361,17 +341,6 @@
],
"Hash": "962174cf2aeb5b9eea581522286a911f"
},
"fs": {
"Package": "fs",
"Version": "1.6.5",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"methods"
],
"Hash": "7f48af39fa27711ea5fbd183b399920d"
},
"generics": {
"Package": "generics",
"Version": "0.1.3",
Expand Down Expand Up @@ -453,13 +422,9 @@
},
"omopgenerics": {
"Package": "omopgenerics",
"Version": "0.4.0",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteRepo": "omopgenerics",
"RemoteUsername": "darwin-eu",
"RemoteSha": "3778bbd2cd5510a817dbac411b10af401fd25965",
"Version": "0.4.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
Expand All @@ -476,24 +441,23 @@
"tidyr",
"vctrs"
],
"Hash": "28e55bb219ef063055c3775a57ad60a0"
"Hash": "072f4e363174ababd20aeab7926d5797"
},
"pillar": {
"Package": "pillar",
"Version": "1.9.0",
"Version": "1.10.0",
"Source": "Repository",
"Repository": "CRAN",
"Repository": "RSPM",
"Requirements": [
"cli",
"fansi",
"glue",
"lifecycle",
"rlang",
"utf8",
"utils",
"vctrs"
],
"Hash": "15da5a8412f317beeee6175fbc76f4bb"
"Hash": "101ca350beea21261a15ba169d7a8513"
},
"pkgconfig": {
"Package": "pkgconfig",
Expand Down Expand Up @@ -778,21 +742,6 @@
],
"Hash": "390f9315bc0025be03012054103d227c"
},
"waldo": {
"Package": "waldo",
"Version": "0.6.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
"diffobj",
"glue",
"methods",
"rlang"
],
"Hash": "52f574062a7b66e56926988c3fbdb3b7"
},
"withr": {
"Package": "withr",
"Version": "3.0.2",
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,25 @@ This repository contains code for the characterisation of a database.

1. **Download the Repository**\
Download this repository:

- Either download as a ZIP file using `Code -> Download ZIP`, then unzip.
- Or, use GitHub Desktop to clone the repository.

2. **Open the R Project**

- Navigate to the `CharacterisationCode` folder and open the project file `CharacterisationCode.Rproj` in RStudio.
- You should see the project name in the top-right corner of your RStudio session.

3. **Run the Analysis Code**

- Open the `CodeToRun.R` file. This is the main script you’ll use.
- Follow the instructions within the file to add your database-specific information.
- Run the code as directed. This will generate a `Results` folder containing the outputs, including a ZIP file with the results for sharing.
4. **Visualize Results in Shiny**

4. **OPTIONAL: Visualize Results in Shiny**

- Navigate to the `shiny` folder and open the project file `shiny.Rproj` in RStudio.
- You should see the project name in the top-right corner of your RStudio session.
- Copy the generated result files (in .csv format) into the `Data` folder located within the `Shiny` folder.
- Open the `global.R` script in the `Shiny` folder.
- Open the `global.R` script in the `shiny` folder.
- Click the *Run App* button in RStudio to launch the local Shiny app for interactive exploration of the results.
1 change: 0 additions & 1 deletion Shiny/.Rprofile

This file was deleted.

18 changes: 0 additions & 18 deletions Shiny/background.md

This file was deleted.

3 changes: 0 additions & 3 deletions Shiny/data/README

This file was deleted.

17 changes: 0 additions & 17 deletions Shiny/global.R

This file was deleted.

Loading

0 comments on commit 7a49f62

Please sign in to comment.