Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Initial data spec #39

Merged
merged 29 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a47d52
update renv
aclark02-arcus May 21, 2024
57cf626
sync with dev
aclark02-arcus May 30, 2024
47664dc
add a new vignette to outline the data specification
aclark02-arcus May 30, 2024
91645d8
update data_spec
aclark02-arcus Jun 12, 2024
35e90ff
Merge branch 'dev' into ac-initial
aclark02-arcus Jun 13, 2024
8e32b82
commit stuff
aclark02-arcus Jun 26, 2024
85d45b1
added 'under construction' note to vignette
aclark02-arcus Jun 27, 2024
bfac0e2
update Rd files
aclark02-arcus Jun 27, 2024
072b8fd
Merge branch 'dev' into ac-21-data-spec
aclark02-arcus Jun 27, 2024
797bb43
updating run_app.rd
aclark02-arcus Jun 27, 2024
12752a3
Merge branch 'ac-21-data-spec' of https://github.com/openpharma/clins…
aclark02-arcus Jun 27, 2024
1de747d
remove unneeded changes
aclark02-arcus Jun 27, 2024
402fa51
update run_app.Rd
aclark02-arcus Jun 27, 2024
1aa41b2
Increment version number to 0.0.0.9003
aclark02-arcus Jun 27, 2024
3b9f32c
update run_app() documentation now that arguments have been shifted t…
aclark02-arcus Jun 27, 2024
9a15f5f
fix typo issues
aclark02-arcus Jun 27, 2024
9fab16e
update run_app.Rd to include 'meta_data' info
aclark02-arcus Jun 28, 2024
96864ab
update golem-config pkg version
aclark02-arcus Jun 28, 2024
a8c3691
move data config information over to vignette instead of run_app docs
aclark02-arcus Jul 1, 2024
dad8b58
update data spec to include section for raw data
aclark02-arcus Jul 1, 2024
802fb2c
get all the right peices into the vignette before testing them out
aclark02-arcus Jul 9, 2024
617749f
making more progress
aclark02-arcus Jul 9, 2024
cc3c0dc
Merge branch 'dev' into ac-21-data-spec
aclark02-arcus Jul 10, 2024
44bfe61
Merge branch 'ac-21-data-spec' of https://github.com/openpharma/clins…
aclark02-arcus Jul 12, 2024
d0fb860
Fix vignette
LDSamson Jul 12, 2024
9e74540
Update clinsightful_data description
LDSamson Jul 12, 2024
8b45810
Provide updated yaml
LDSamson Jul 12, 2024
1b9a240
Add a few clarifications
LDSamson Jul 12, 2024
5e77543
Update version
LDSamson Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.0.0.9004
Version: 0.0.0.9005
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut")),
person("GCP-Service International Ltd.& Co. KG", role = "fnd")
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
- Created two renv profiles, one for development and one for production. Goal is
to minimize the package dependencies of the production version.
- Removed development package dependencies (for example devtools) that were not needed to run the application.
- Improved data anonimization.
- Improved data anonymization.
- Changed license.

- Updated Description file.
- Improved reading of data files within clinsight::run_app()
- Improved creating test result report.
- Added data specification to `run_app()` documentation

## Bug fixes

Expand Down
14 changes: 12 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@
#'
"col_palette"


#' Clinical Trial test data
#'
#' A data frame containing randomly created clinical trial data. Used for
#' testing purposes.
#' A data.frame containing randomly created clinical trial data. Used for
#' testing purposes. It will also be used to run the app with example data when
#' executing `run_app()` with the default configuration settings, or when
#' running `golem::run_dev()`.
#'
#' @format a data.frame with 6,483 rows and 24 variables.
#'
#' @source Created with `data-raw/create_random_data.R`
"clinsightful_data"




4 changes: 3 additions & 1 deletion R/run_app.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' Run the Shiny Application
#'
#'
#' @param data_folder Character string. The folder in which all data resides is
#' usually set in the config.yml file. However, this can be overwritten if a
#' path is set in this argument. Useful for testing purposes.
Expand All @@ -8,6 +8,8 @@
#' @param ... arguments to pass to golem_opts. See `?golem::get_golem_options`
#' for more details.
#' @inheritParams shiny::shinyApp
#'
#'
#'
#' @export
#'
Expand Down
77 changes: 77 additions & 0 deletions dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,82 @@
#### CURRENT FILE: DEV SCRIPT #####
###################################

# Exploring for insights on data spec
unique(clinsightful_data[,c("site_code","region")]) |> arrange(site_code)
unique(clinsightful_data[,c("event_id","event_name")])
unique(clinsightful_data[,c("form_id","form_repeat")])
unique(clinsightful_data[,c("event_repeat","event_id","event_name")])
unique(clinsightful_data[,c("event_repeat","event_id","event_name","form_id","form_repeat")])
unique(clinsightful_data[,c("event_repeat","event_id","event_name", "day")])
unique(clinsightful_data[,c("event_repeat","event_id","event_name", "event_label")])

# form exploration
unique(clinsightful_data[,c("form_id")])
unique(clinsightful_data[,c("form_id","item_group", "item_type")])

# other
unique(clinsightful_data[,c("item_group","item_type")])
other <- clinsightful_data |>
filter(item_type == "other")
unique(other[,c("item_group","item_type","item_name")]) |>
print(n=40)

# bds
unique(clinsightful_data[,c("item_group","item_type")])
bds <- clinsightful_data |>
filter(item_type != "other")
unique(bds[,c("item_group","item_type","item_name")]) |>
print(n=40)


unique(clinsightful_data[,c("item_group","item_type")])
other <- clinsightful_data |>
filter(item_group == "Vital signs")
unique(other[,c("item_group","item_type","item_name")]) |>
print(n=40)

# dirty?
library(clinsight)
data("clinsightful_data")
dirty <- clinsightful_data |>
filter(item_value %in% c("µg/h","µg/ml"))

str(clinsightful_data$item_value)

# day
class(clinsightful_data$day)

# exploring events
data("clinsightful_data")
d_1pat <- clinsightful_data |>
filter(subject_id == "BEL_04_772") |>
filter(event_id == "COMMON_CM")

# exploring event_repeat & event_date
library(dplyr)
clinsightful_data |>
filter(subject_id == "BEL_04_772") |>
group_by(subject_id, event_id, event_repeat, event_date) |>
summarize(n = n()) |>
# filter(event_repeat != form_repeat) |>
print(n = 36)

d_1pat <- clinsightful_data |>
filter(subject_id == "BEL_04_772") |>
filter(event_id == "COMMON_AE")

clinsightful_data |>
filter(subject_id == "BEL_04_772") |>
group_by(subject_id, event_id, event_repeat, event_date, form_repeat) |>
summarize(n = n()) |>
filter(event_repeat != form_repeat) |>
print(n = 36)


# metadata

clinsight::metadata$column_specs$col_type |> unique()

# Engineering

## Dependencies ----
Expand Down Expand Up @@ -47,6 +123,7 @@ usethis::use_test("app")

## Vignette ----
usethis::use_vignette("testgolem")
usethis::use_vignette(name = "data_spec", title = "Input Data Specification")
#devtools::build_vignettes()

## Code Coverage----
Expand Down
41 changes: 41 additions & 0 deletions dev/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

devtools::load_all()
# pkg_name <- "clinsight"
# library(pkg_name, character.only = TRUE)


# datapath <- "data1pt"
datapath <- app_sys("tests/testthat/fixtures/csvtestdata") # For interactive use

metadata <- get_metadata(filepath = here::here("data-raw/metadata.xlsx"))
usethis::use_data(metadata, overwrite = TRUE) # do I need this?
my_raw_data <- get_raw_data(data_path = datapath, column_specs = metadata$column_specs)
# fix_multiple_choice_vars() - metadata not found

merged_data <- merge_meta_with_data(
data = my_raw_data,
meta = metadata
)
# tempdir not useful for production mode
data_folder <- "."
data_path <- file.path(data_folder,
"merged_data.rds")
saveRDS(merged_data, data_path)
db_path <- file.path(data_folder, "user_db.sqlite")

# if test_mode == FALSE, you'll need to setup...
# DB_SECRET env var to setup credentials db
usethis::edit_r_environ()
Sys.getenv("DB_SECRET")

# initiate the user db
db_create(get_review_data(merged_data),
db_path = db_path
)

run_app(
data = data_path, #merged_data, # or db_path works too
# user_db = db_path, # defaults to "user_db.sqlite"
test_mode = FALSE#,
# onStart = \(){onStop(\(){unlink(data_folder, recursive = TRUE)})} # be careful here
)
2 changes: 1 addition & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default:
golem_name: clinsight
golem_version: 0.0.0.9004
golem_version: 0.0.0.9005
app_prod: no
user_identification: test_user
study_data: !expr clinsight::clinsightful_data
Expand Down
8 changes: 5 additions & 3 deletions man/clinsightful_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading