Skip to content

Commit

Permalink
Closes #2 moving ophtha datasets to {pharmaversesdtm} (#37)
Browse files Browse the repository at this point in the history
* #15 added `EX` and `QS` ophtha variants

* #2 chore: spelling

* #2 chore: spellcheck
  • Loading branch information
manciniedoardo authored Jul 18, 2023
1 parent b723d80 commit ffcf7e0
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file added data/ex_ophtha.rda
Binary file not shown.
Binary file added data/qs_ophtha.rda
Binary file not shown.
34 changes: 34 additions & 0 deletions dev/ex_ophtha.R
Original file line number Diff line number Diff line change
@@ -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")
130 changes: 130 additions & 0 deletions dev/qs_ophtha.R
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 5 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ Contestí
DM
DS
EG
EXLAT
EXLOC
Farrugia
Github
GSK
Gopi
LinkedIn
MH
NEI
Onboarding
Pharmacokinetic
Pharmacokinetics
Expand All @@ -30,6 +33,7 @@ SUPPTR
SV
TAs
USUBJIDs
VFQ
admiraldata
admiraltemplate
admiralxxx
Expand All @@ -39,6 +43,7 @@ dev
nolint
onboarding
pharmaverse
qs
renv
repo
https
Expand Down
19 changes: 19 additions & 0 deletions man/ex_ophtha.Rd

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

19 changes: 19 additions & 0 deletions man/qs_ophtha.Rd

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

0 comments on commit ffcf7e0

Please sign in to comment.