diff --git a/NEWS.md b/NEWS.md index 70bcec7..3f63abe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ ## New Features - - New `renv` lock files were setup (#ISSUE-NUMBER) + - Ophthalmology variants of `ex` and `qs` SDTM datasets added. (#15) ## Updates of Existing Functions diff --git a/R/data.R b/R/data.R index 3d146d1..659219e 100644 --- a/R/data.R +++ b/R/data.R @@ -54,6 +54,13 @@ #' @source \url{https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/ex.xpt?raw=true} # nolint "admiral_ex" +#' Ophthalmology Exposure Dataset +#' +#' An example Exposure SDTM dataset with ophthalmology-specific variables such as `EXLOC` and `EXLAT` +#' +#' @source Constructed using `ex` from the `{pharmaversesdtm}` package # nolint +"ex_ophtha" + #' Laboratory Measurements Dataset #' #' An updated SDTM LB dataset that uses data from the CDISC pilot project @@ -121,6 +128,13 @@ #' @source \url{https://github.com/pharmaverse/admiral.test/blob/main/data/admiral_qs.rda} # nolint "admiral_qs" +#' Ophthalmology Questionnaire Dataset +#' +#' An example Questionnaires SDTM dataset with ophthalmology-specific questionnaire of NEI VFQ-25 +#' +#' @source Constructed using `qs` from the `{pharmaversesdtm}` package # nolint +"qs_ophtha" + #' Subject Characteristic Dataset #' #' A SDTM SC dataset simulated by Ophthalmology team diff --git a/data-raw/ex_ophtha.R b/data-raw/ex_ophtha.R new file mode 100644 index 0000000..f93e9c5 --- /dev/null +++ b/data-raw/ex_ophtha.R @@ -0,0 +1,34 @@ +library(dplyr) +library(tidyselect) +library(pharmaversesdtm) + +# Make ex_ophtha dataset +ex_ophtha <- admiral_dm %>% + # Start by merging on ophtha_dm to use the SUBJID variable + select(USUBJID, SUBJID) %>% + right_join(admiral_ex, by = c("USUBJID"), multiple = "all") %>% + # Create EXLOC & EXLAT, change EXROUTE & EXDOSFRM to something eye-related + mutate( + EXLOC = "EYE", + EXDOSFRM = "INJECTION", + EXDOSFRQ = "ONCE", + EXLAT = ifelse(as.integer(SUBJID) %% 2 == 0, "LEFT", "RIGHT"), + EXROUTE = "INTRAVITREAL" + ) %>% + # Drop SUBJID and reorder variables + select( + "USUBJID", "STUDYID", "DOMAIN", "EXSEQ", "EXTRT", "EXDOSE", + "EXDOSU", "EXDOSFRM", "EXDOSFRQ", "EXROUTE", "EXLOC", + "EXLAT", "VISITNUM", "VISIT", "VISITDY", "EXSTDTC", + "EXENDTC", "EXSTDY", "EXENDY" + ) + +# Label new variables +attr(ex_ophtha$EXLOC, "label") <- "Location of Dose Administration" +attr(ex_ophtha$EXLAT, "label") <- "Laterality" +attr(ex_ophtha$EXROUTE, "label") <- "Route of Administration" +attr(ex_ophtha$EXDOSFRM, "label") <- "Dose Form" +attr(ex_ophtha$EXDOSFRQ, "label") <- "Dose Frequency per Interval" + +# Save Dataset +save(ex_ophtha, file = file.path("data", "ex_ophtha.rda"), compress = "bzip2") diff --git a/data-raw/qs_ophtha.R b/data-raw/qs_ophtha.R new file mode 100644 index 0000000..f9be6cb --- /dev/null +++ b/data-raw/qs_ophtha.R @@ -0,0 +1,130 @@ +library(pharmaversesdtm) +library(dplyr) +library(stringr) + +# create new QS data - keep standard variables from previous ADMIRAL project's QS ==== +qs1 <- admiral_qs %>% + # select standard variables + select(STUDYID, DOMAIN, USUBJID, QSBLFL, VISITNUM, VISIT, VISITDY, QSDTC, QSDY) %>% + # keep unique subjects and visits per subject + group_by(USUBJID, VISITDY) %>% + unique() + +# create dummy parameters and results ==== +dummy_param <- data.frame(QSTEST = c( + "Your Overall Health Is", + "Eyesight Using Both Eyes Is", + "How Often You Worry About Eyesight", + "How Often Pain in and Around Eyes", + "Difficulty Reading Newspapers", + "Difficulty Doing Work/Hobbies", + "Difficulty Finding on Crowded Shelf", + "Difficulty Reading Street Signs", + "Difficulty Going Down Step at Night", + "Difficulty Noticing Objects to Side", + "Difficulty Seeing How People React", + "Difficulty Picking Out Own Clothes", + "Difficulty Visiting With People", + "Difficulty Going Out to See Movies", + "Are You Currently Driving", + "Difficulty Driving During Daytime", + "Difficulty Driving at Night", + "Driving in Difficult Conditions", + "Eye Pain Keep You From Doing What You Like", + "I Stay Home Most of the Time", + "I Feel Frustrated a Lot of the Time", + "I Need a Lot of Help From Others", + "Worry I'll Do Embarrassing Things", + "Difficulty Reading Small Print", + "Difficulty Figure Out Bill Accuracy", + "Difficulty Shaving or Styling Hair", + "Difficulty Recognizing People", + "Difficulty Taking Part in Sports", + "Difficulty Seeing Programs on TV" +)) %>% + mutate( + QSTESTCD = paste0("VFQ", row_number()), + QSCAT = "NEI VFQ-25", + QSSCAT = "Original Response" + ) + +# dummy answers + +# difficulty in performing tasks +difficulty_res <- c( + "SOME DIFFICULTY", + "NO DIFFICULTY", + "VERY DIFFICULT" +) +difficulty_resn <- c(1:3) +difficulty <- setNames(difficulty_res, difficulty_resn) + +# frequency answers +freq_res <- c("SOMETIMES", "FREQUENTLY", "RARELY", "NEVER") +freq_resn <- c(1:4) +frequency <- setNames(freq_res, freq_resn) + +# quality answers +qual_res <- c("VERY GOOD", "GOOD", "FAIR", "POOR", "VERY POOR") +qual_resn <- c(1:5) +quality <- setNames(qual_res, qual_resn) + +# yesno answers +yn_res <- c("YES", "NO") +yn_resn <- c(1:2) +yesno <- setNames(yn_res, yn_resn) + +answers <- c(difficulty_res, freq_res, qual_res, yn_res) +answersn <- c(difficulty_resn, freq_resn, qual_resn, yn_resn) + +# assign answers to questions randomly for each subjects + +# take unique subjects +subjects <- qs1 %>% + ungroup() %>% + select(USUBJID) %>% + distinct() + +dummy_param_res_by_subj <- merge(subjects, dummy_param) %>% + mutate(QSORRES = case_when( + str_detect(QSTEST, "Difficult") ~ sample(difficulty, size = nrow(.), replace = T), + str_detect(QSTEST, "How") ~ sample(frequency, size = nrow(.), replace = T), + str_detect(QSTEST, "Are You") ~ sample(yesno, size = nrow(.), replace = T), + str_detect(QSTEST, "Overall Health") ~ sample(quality, size = nrow(.), replace = T), + str_detect(QSTEST, "Eyesight") ~ sample(quality, size = nrow(.), replace = T), + TRUE ~ sample(frequency, size = nrow(.), replace = T) + )) %>% + mutate( + QSSTRESC = QSORRES, + QSORRESU = "", + QSSTRESU = "", + QSDRVFL = "" + ) + +# merge standard QS with parameters and result variables from temp QS data + +qs2 <- merge(qs1, dummy_param_res_by_subj, by = "USUBJID") %>% + group_by(USUBJID) %>% + # create QSSEQ based on VFQ QS parameters + mutate(QSSEQ = row_number()) %>% + arrange(USUBJID, QSSEQ) + +qs3 <- qs2 %>% + group_by(QSTEST) %>% + # create numeric var for std result + mutate(QSSTRESN = as.numeric(factor(QSSTRESC))) %>% + select( + STUDYID, DOMAIN, USUBJID, QSSEQ, QSTESTCD, QSTEST, QSCAT, QSSCAT, QSORRES, QSORRESU, QSSTRESC, QSSTRESN, QSSTRESU, + QSBLFL, QSDRVFL, VISITNUM, VISIT, VISITDY, QSDTC, QSDY + ) %>% + ungroup() + +# NOTE: the QS2 dataset made above should be stacked below the admiral_qs dataset. +# output qs_ophtha.RDS +# remove the original vfq part from admiral_qs +admiral_qs_novfq <- admiral_qs %>% filter(QSCAT != "NEI VFQ-25") + +qs_ophtha <- rbind(admiral_qs_novfq, qs3) + +# ---- Save output for temporary usage ---- +save(qs_ophtha, file = file.path("data", "qs_ophtha.rda"), compress = "bzip2") diff --git a/data/ex_ophtha.rda b/data/ex_ophtha.rda new file mode 100644 index 0000000..89abf29 Binary files /dev/null and b/data/ex_ophtha.rda differ diff --git a/data/qs_ophtha.rda b/data/qs_ophtha.rda new file mode 100644 index 0000000..316623d Binary files /dev/null and b/data/qs_ophtha.rda differ diff --git a/inst/WORDLIST b/inst/WORDLIST index 361707f..a136f89 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -8,12 +8,15 @@ Contestí DM DS EG +EXLAT +EXLOC Farrugia Github GSK Gopi LinkedIn MH +NEI Onboarding Pharmacokinetic Pharmacokinetics @@ -30,6 +33,7 @@ SUPPTR SV TAs USUBJIDs +VFQ admiraldata admiraltemplate admiralxxx @@ -39,6 +43,7 @@ dev nolint onboarding pharmaverse +qs renv repo https diff --git a/man/ex_ophtha.Rd b/man/ex_ophtha.Rd new file mode 100644 index 0000000..5f6cb5e --- /dev/null +++ b/man/ex_ophtha.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{ex_ophtha} +\alias{ex_ophtha} +\title{Ophthalmology Exposure Dataset} +\format{ +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 591 rows and 19 columns. +} +\source{ +Constructed using `ex` from the `{pharmaversesdtm}` package # nolint +} +\usage{ +ex_ophtha +} +\description{ +An example Exposure SDTM dataset with ophthalmology-specific variables such as `EXLOC` and `EXLAT` +} +\keyword{datasets} diff --git a/man/qs_ophtha.Rd b/man/qs_ophtha.Rd new file mode 100644 index 0000000..b4ca50f --- /dev/null +++ b/man/qs_ophtha.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{qs_ophtha} +\alias{qs_ophtha} +\title{Ophthalmology Questionnaire Dataset} +\format{ +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 197671 rows and 20 columns. +} +\source{ +Constructed using `qs` from the `{pharmaversesdtm}` package # nolint +} +\usage{ +qs_ophtha +} +\description{ +An example Questionnaires SDTM dataset with ophthalmology-specific questionnaire of NEI VFQ-25 +} +\keyword{datasets}