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

Closes #39: CoEQ test data #45

Merged
merged 11 commits into from
Nov 5, 2024
10 changes: 10 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@
#'
#' @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. Any persons
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
#' 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"
104 changes: 104 additions & 0 deletions data-raw/qs_metabolic.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#' Dataset: qs_metabolic
#' Description: Create QS test SDTM dataset for metabolic studies,
#' containing COEQ data (Control of Eating Questionnaire)
#' Note that University of Leeds are the copyright holders of the CoEQ and the test data included within
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
#' `{admiralmetabolic}`is for not-for-profit use only. 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(pharmaversesdtm)
library(purrr)
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved

# 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, ~QSSCAT, ~QSTESTCD, ~QSTEST,
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
"COEQ", "EATING", "COEQ01", "How hungry have you felt?",
"COEQ", "EATING", "COEQ02", "How full have you felt?",
"COEQ", "EATING", "COEQ03", "How strong was your desire to eat sweet foods?",
"COEQ", "EATING", "COEQ04", "How strong was your desire to eat savoury foods?",
"COEQ", "EMOTIONS", "COEQ05", "How happy have you felt?",
"COEQ", "EMOTIONS", "COEQ06", "How anxious have you felt?",
"COEQ", "EMOTIONS", "COEQ07", "How alert have you felt?",
"COEQ", "EMOTIONS", "COEQ08", "How contented have you felt?",
"COEQ", "GENERAL CRAVINGS", "COEQ09", "During the last 7 days how often have you had food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ10", "How strong have any food cravings been?",
"COEQ", "GENERAL CRAVINGS", "COEQ11", "How difficult has it been to resist any food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ12", "How often have you eaten in response to food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ13", "Chocolate or chocolate flavoured foods",
"COEQ", "SPECIFIC CRAVINGS", "COEQ14", "Other sweet foods (cakes, pastries, biscuits, etc)",
"COEQ", "SPECIFIC CRAVING", "COEQ15", "Fruit or fruit juice",
"COEQ", "SPECIFIC CRAVING", "COEQ16", "Dairy foods (cheese, yoghurts, milk, etc)",
"COEQ", "SPECIFIC CRAVING", "COEQ17", "Starchy foods (bread, rice, pasta, etc)",
"COEQ", "SPECIFIC CRAVING", "COEQ18", "Savoury foods (french fries, crisps, burgers, pizza, etc)",
"COEQ", "CONTROL EATING", "COEQ19", "Generally, how difficult has it been to control your eating?",
"COEQ", "CONTROL EATING", "COEQ20", "Which one food makes it most difficult for you to control eating?",
"COEQ", "CONTROL EATING", "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(!grepl("AMBUL|RETRIEVAL", VISIT)) %>%
rename(QSDTC = VSDTC, QSDY = VSDY) %>%
distinct()
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved

# Cross join to get questions at each visit ----
qs_metabolic_shell <- visit_schedule %>%
dplyr::cross_join(coeq_structure)
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved

# Simulate question answers ----
qs_metabolic_results <- qs_metabolic_shell %>%
mutate(
DOMAIN = "QS",
QSORRES = floor(runif(1) * 10) + round(runif(1)),
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
QSORRESU = "cm",
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
QSSTRESU = "cm",
QSSTRESN = QSORRES,
QSSTRESC = as.character(QSORRES),
QSBLFL = ifelse(VISIT == "BASELINE", "Y", NA_character_)
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
)

# Order variables, sort and add sequence number ----
qs_metabolic_seq <- qs_metabolic_results %>%
select(
STUDYID, USUBJID, DOMAIN, VISIT, VISITNUM, VISITDY, QSBLFL, QSDTC, QSDY,
QSCAT, QSSCAT, 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 ----
attr(qs_metabolic_seq$DOMAIN, "label") <- "Domain Abbreviation"
attr(qs_metabolic_seq$QSBLFL, "label") <- "Baseline Flag"
attr(qs_metabolic_seq$QSCAT, "label") <- "Category for Questionnaire"
attr(qs_metabolic_seq$QSSCAT, "label") <- "Subcategory for Questionnaire"
attr(qs_metabolic_seq$QSTEST, "label") <- "Questionnaire Test Name"
attr(qs_metabolic_seq$QSTESTCD, "label") <- "Questionnaire Test Short Name"
attr(qs_metabolic_seq$QSORRES, "label") <- "Result or Finding in Original Units"
attr(qs_metabolic_seq$QSORRESU, "label") <- "Original Units"
attr(qs_metabolic_seq$QSSTRESC, "label") <- "Character Result/Finding in Std Format"
attr(qs_metabolic_seq$QSSTRESN, "label") <- "Numeric Result/Finding in Standard Units"
attr(qs_metabolic_seq$QSSTRESU, "label") <- "Standard Units"
attr(qs_metabolic_seq$QSSEQ, "label") <- "Sequence Number"
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved

# Label QS dataset ----
attr(qs_metabolic_seq, "label") <- "Questionnaire"
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved

# Final dataset ----
qs_metabolic <- qs_metabolic_seq

# Save dataset ----
usethis::use_data(qs_metabolic, overwrite = TRUE)
Binary file added data/qs_metabolic.rda
Binary file not shown.
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Biologics
BMI
CDISC
Changelog
CoEQ
DM
Farrugia
GSK
Expand Down
22 changes: 22 additions & 0 deletions man/qs_metabolic.Rd

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

Loading