From 26cac246fccca2d27e0f1f072f179c9e1176f272 Mon Sep 17 00:00:00 2001 From: Edoardo Mancini <53403957+manciniedoardo@users.noreply.github.com> Date: Tue, 5 Nov 2024 09:29:13 +0000 Subject: [PATCH] Closes #39: CoEQ test data (#45) * Closes #39: CoEQ test data * #39 chore: styler updates * #39 chore: spelling * Apply suggestions from code review #39: implemented suggestions from code review Co-authored-by: Anders Askeland * #39 updated disclaimer based on review * #39 fixed typo in QSSCATSs * #39 fixed typo in data.R * Apply suggestions from code review Co-authored-by: Anders Askeland * Apply suggestions from code review Co-authored-by: Andrii Yurovskyi * #39 updates following review --------- Co-authored-by: Anders Askeland Co-authored-by: Andrii Yurovskyi --- R/data.R | 11 ++++ data-raw/qs_metabolic.R | 123 ++++++++++++++++++++++++++++++++++++++++ data/qs_metabolic.rda | Bin 0 -> 6255 bytes inst/WORDLIST | 1 + man/qs_metabolic.Rd | 23 ++++++++ 5 files changed, 158 insertions(+) create mode 100644 data-raw/qs_metabolic.R create mode 100644 data/qs_metabolic.rda create mode 100644 man/qs_metabolic.Rd diff --git a/R/data.R b/R/data.R index d44d3db..26b7c43 100644 --- a/R/data.R +++ b/R/data.R @@ -11,3 +11,14 @@ #' #' @source Constructed using `vs` from the `{pharmaversesdtm}` package and `dm_metabolic` from `{admiralmetabolic}` package "vs_metabolic" + +#' Example questionnaire dataset +#' +#' An example questionnaire SDTM dataset (containing Control of Eating Questionnaire, CoEQ, test data) for metabolic studies. +#' Note that University of Leeds are the copyright holders of the CoEQ and the test data included within {admiralmetabolic} +#' is for not-for-profit use only within `{admiralmetabolic}` and `pharmaverse`-related examples/documentation. Any persons +#' or companies wanting to use the CoEQ should request a license to do so from the following +#' [link](https://licensing.leeds.ac.uk/product/control-of-eating-questionnaire-coeq). +#' +#' @source Constructed using `dm_metabolic` from `{admiralmetabolic}` package +"qs_metabolic" diff --git a/data-raw/qs_metabolic.R b/data-raw/qs_metabolic.R new file mode 100644 index 0000000..acefe61 --- /dev/null +++ b/data-raw/qs_metabolic.R @@ -0,0 +1,123 @@ +#' Dataset: qs_metabolic +#' Description: Create QS test SDTM dataset for metabolic studies, +#' containing COEQ data (Control of Eating Questionnaire) +#' Note: the University of Leeds are the copyright holders of the CoEQ and the test data included within {admiralmetabolic} +#' is for not-for-profit use only within `{admiralmetabolic}` and `pharmaverse`-related examples/documentation. Any persons +#' or companies wanting to use the CoEQ should request a license to do so from the following +#' [link](https://licensing.leeds.ac.uk/product/control-of-eating-questionnaire-coeq). + +# Load libraries ---- + +library(tibble) +library(dplyr) +library(stringr) + +# Set seed for random data generation ---- +set.seed(3.14159265) + +# Read input data ---- + +vs_metabolic <- admiralmetabolic::vs_metabolic + +# Set up questions, codes and categories ---- +coeq_structure <- tibble::tribble( + ~QSCAT, ~QSTESTCD, ~QSTEST, + "COEQ", "COEQ01", "How hungry have you felt?", + "COEQ", "COEQ02", "How full have you felt?", + "COEQ", "COEQ03", "How strong was your desire to eat sweet foods?", + "COEQ", "COEQ04", "How strong was your desire to eat savoury foods?", + "COEQ", "COEQ05", "How happy have you felt?", + "COEQ", "COEQ06", "How anxious have you felt?", + "COEQ", "COEQ07", "How alert have you felt?", + "COEQ", "COEQ08", "How contented have you felt?", + "COEQ", "COEQ09", "During the last 7 days how often have you had food cravings?", + "COEQ", "COEQ10", "How strong have any food cravings been?", + "COEQ", "COEQ11", "How difficult has it been to resist any food cravings?", + "COEQ", "COEQ12", "How often have you eaten in response to food cravings?", + "COEQ", "COEQ13", "Chocolate or chocolate flavoured foods", + "COEQ", "COEQ14", "Other sweet foods (cakes, pastries, biscuits, etc)", + "COEQ", "COEQ15", "Fruit or fruit juice", + "COEQ", "COEQ16", "Dairy foods (cheese, yoghurts, milk, etc)", + "COEQ", "COEQ17", "Starchy foods (bread, rice, pasta, etc)", + "COEQ", "COEQ18", "Savoury foods (french fries, crisps, burgers, pizza, etc)", + "COEQ", "COEQ19", "Generally, how difficult has it been to control your eating?", + "COEQ", "COEQ20", "Which one food makes it most difficult for you to control eating?", + "COEQ", "COEQ21", "How difficult has it been to resist eating this food during the last 7 days?", +) + +# Use visit schedule and days from VS ---- +visit_schedule <- vs_metabolic %>% + select(STUDYID, USUBJID, VISIT, VISITNUM, VISITDY, VSDTC, VSDY) %>% + filter(str_detect(VISIT, "AMBUL|RETRIEVAL", negate = TRUE)) %>% + rename(QSDTC = VSDTC, QSDY = VSDY) %>% + distinct() + +# Cross join to get questions at each visit ---- +qs_metabolic_shell <- visit_schedule %>% + cross_join(coeq_structure) + +# Simulate question answers ---- +qs_metabolic_results <- qs_metabolic_shell %>% + mutate( + DOMAIN = "QS", + QSORRES = as.character(round(runif(n(), min = 0, max = 100))), + QSORRESU = "mm", + QSSTRESU = "mm", + QSSTRESN = as.numeric(QSORRES), + QSSTRESC = QSORRES, + QSBLFL = if_else(VISIT == "BASELINE", "Y", NA_character_) + ) %>% + # Update the free text question (COEQ20) + mutate( + QSSTRESC = case_when( + QSTESTCD == "COEQ20" & QSSTRESN < 33 ~ "Ice Cream", + QSTESTCD == "COEQ20" & QSSTRESN < 66 ~ "Pizza", + QSTESTCD == "COEQ20" ~ "Pasta", + TRUE ~ QSSTRESC + ) + ) %>% + mutate( + QSSTRESN = if_else(QSTESTCD == "COEQ20", NA, QSSTRESN), + QSORRES = if_else(QSTESTCD == "COEQ20", QSSTRESC, QSORRES), + QSORRESU = if_else(QSTESTCD == "COEQ20", NA_character_, QSORRESU), + QSSTRESU = if_else(QSTESTCD == "COEQ20", NA_character_, QSSTRESU), + ) + +# Order variables, sort and add sequence number ---- +qs_metabolic_seq <- qs_metabolic_results %>% + select( + STUDYID, USUBJID, DOMAIN, VISIT, VISITNUM, VISITDY, QSBLFL, QSDTC, QSDY, + QSCAT, QSTEST, QSTESTCD, QSORRES, QSORRESU, QSSTRESC, QSSTRESN, QSSTRESU + ) %>% + arrange(STUDYID, USUBJID, VISITNUM, QSTESTCD) %>% + group_by(USUBJID) %>% + mutate(QSSEQ = row_number()) %>% + ungroup() + +# Add labels to variables that don't have them yet ---- +labels <- list( + DOMAIN = "Domain Abbreviation", + QSBLFL = "Baseline Flag", + QSCAT = "Category for Questionnaire", + QSTEST = "Questionnaire Test Name", + QSTESTCD = "Questionnaire Test Short Name", + QSORRES = "Result or Finding in Original Units", + QSORRESU = "Original Units", + QSSTRESC = "Character Result/Finding in Std Format", + QSSTRESN = "Numeric Result/Finding in Standard Units", + QSSTRESU = "Standard Units", + QSSEQ = "Sequence Number" +) + +for (var in names(labels)) { + attr(qs_metabolic_seq[[var]], "label") <- labels[[var]] +} + +# Label QS dataset ---- +attr(qs_metabolic_seq, "label") <- "Questionnaires" + +# Final dataset ---- +qs_metabolic <- qs_metabolic_seq + +# Save dataset ---- +usethis::use_data(qs_metabolic, overwrite = TRUE) diff --git a/data/qs_metabolic.rda b/data/qs_metabolic.rda new file mode 100644 index 0000000000000000000000000000000000000000..b2f3f1eb3716e3c6f02db7f01317040308f5d2e1 GIT binary patch literal 6255 zcmai1c~sKr*Qdo&Q8QC8Ez62V5zx$W(xwfi6s(X~WYaJ)$xt)3)nA)mQ?tg5#cWzo zaREg|K*goPauO;P6_-+@(%fy+rfHg9<~`><=l$z_@AsVh-1BVrx%aux{eCW*7UQ>R z7j@$S>MU=Y`+}pf=YIS@^!*j=?9$?n1)v2B;?ILXAZyp1CJxGQU0}Wr4cKjPOREAc z27%oE?F50sU1rzrkz9=F3dt;9ALDeVI4`f~m$LmFThrJ|>!J?OO3~1yJP5S#ASf?nqea?-jkaDZ7C*=a zel01<-5)&iYfMOY|Id3(=kWO-oj#x? z=NGMYwu_mwUc~XeN7}n2?ZCSH; z^_Y9v&ICS^1h5?u6>jcOw=+syI=&?%axgx^kZgtDnZKQVMPt8q zFNJPMLS&mq9!$HjLUN?FTIHU5uzNYE4`k#@LTu{d)~@W zAkp_t5Bc~piD&R!f@-`Ht4!X8g?8C%H>Z-ntW5E;=byQRszI)^xDmb4=-qvCZgus= zmMzKL0t>iV+BwHv3y}bZ$=oP0cic>BNq!04w1(LmyK7tD(a_X!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