diff --git a/.github/CODEOWNERS.txt b/.github/CODEOWNERS.txt new file mode 100644 index 0000000..00db6f3 --- /dev/null +++ b/.github/CODEOWNERS.txt @@ -0,0 +1,7 @@ +# This a CODEOWNERS file, where you can establish code owners. +# Code owners are automatically requested for review when someone opens a pull request +# that modifies code that they own. +# +# +data/ts.rda @kaz462 +R/ts.R @kaz462 diff --git a/R/data.R b/R/data.R index 6b03d62..33cfe0c 100644 --- a/R/data.R +++ b/R/data.R @@ -93,13 +93,6 @@ #' @author Antonio Rodríguez Contestí "pp" -#' Questionnaire Dataset -#' -#' A SDTM QS dataset from the CDISC pilot project & Ophthalmology test data -#' -#' @source \url{https://github.com/pharmaverse/admiral.test/blob/main/data/admiral_qs.rda} # nolint -"qs" - #' Ophthalmology Questionnaire Dataset #' #' An example Questionnaires SDTM dataset with ophthalmology-specific questionnaire of NEI VFQ-25 diff --git a/README.md b/README.md index 63f8fe4..e6e9608 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,21 @@ -[](https://pharmaverse.org) -[![Test Coverage](https://raw.githubusercontent.com/pharmaverse/pharmaversesdtm/badges/main/test-coverage.svg)](https://github.com/pharmaverse/pharmaversesdtm/actions/workflows/code-coverage.yml) +[](https://pharmaverse.org) [![Test Coverage](https://raw.githubusercontent.com/pharmaverse/pharmaversesdtm/badges/main/test-coverage.svg)](https://github.com/pharmaverse/pharmaversesdtm/actions/workflows/code-coverage.yml) -Test data (SDTM) for the pharmaverse family of packages +Test data (SDTM) for the pharmaverse family of packages # Purpose -To provide a one-stop-shop for SDTM test data in the pharmaverse family of packages. This includes datasets that are therapeutic area (TA)-agnostic (`DM`, `VS`, `EG`, etc.) as well TA-specific ones (`RS`, `TR`, `OE`, etc.). +To provide a one-stop-shop for SDTM test data in the pharmaverse family of packages. This includes datasets that are therapeutic area (TA)-agnostic (`DM`, `VS`, `EG`, etc.) as well TA-specific ones (`RS`, `TR`, `OE`, etc.). # Installation -The package is available from CRAN and can be installed by running `install.packages("pharmaversesdtm")`. -To install the latest development version of the package directly from GitHub use the following code: +The package is available from CRAN and can be installed by running `install.packages("pharmaversesdtm")`. To install the latest development version of the package directly from GitHub use the following code: -```r +``` r if (!requireNamespace("remotes", quietly = TRUE)) { install.packages("remotes") } @@ -28,39 +26,45 @@ remotes::install_github("pharmaverse/pharmaversesdtm", ref = "devel") # Data Sources -Some of the test datasets has been sourced from the [CDISC pilot project](https://github.com/cdisc-org/sdtm-adam-pilot-project), while other datasets have been constructed ad-hoc by the admiral team. Please check the [Github repository](https://github.com/pharmaverse/admiral.test/tree/main/data) for detailed information regarding the source of specific datasets. +Some of the test datasets has been sourced from the [CDISC pilot project](https://github.com/cdisc-org/sdtm-adam-pilot-project), while other datasets have been constructed ad-hoc by the admiral team. Please check the [Reference page](https://pharmaverse.github.io/pharmaversesdtm/cran-release/reference/index.html) for detailed information regarding the source of specific datasets. + +# Naming Conventions {#naming} -# Naming Conventions * Datasets that are TA-agnostic: same as SDTM domain name (e.g., `dm`, `rs`). -* Datasets that are TA-specific: prefix the domain name with the TA (e.g., `onco_rs`, `ophtha_oe`). +* Datasets that are TA-specific: domain_TA_others, others go from broader categories to more specific ones (e.g., `oe_ophtha`, `rs_onco`, `rs_onco_irecist`). -**Note**: *If an SDTM domain is used by multiple TAs, `{pharmaversesdtm}` may provide multiple versions of the corresponding test dataset. For instance, the package contains `ex` and `ophtha_ex` as the latter contains ophthalmology-specific variables such as `EXLAT` and `EXLOC`, and `EXROUTE` is exchanged for a plausible ophthalmology value.* +**Note**: *If an SDTM domain is used by multiple TAs, `{pharmaversesdtm}` may provide multiple versions of the corresponding test dataset. For instance, the package contains `ex` and `ex_ophtha` as the latter contains ophthalmology-specific variables such as `EXLAT` and `EXLOC`, and `EXROUTE` is exchanged for a plausible ophthalmology value.* # How To Update -Firstly, make a GitHub issue in this repo with the planned updates and tag `@pharmaverse/admiral` so that one of the development core team can sanity check the request. +Firstly, make a GitHub issue in [`{pharmaversesdtm}`](https://github.com/pharmaverse/pharmaversesdtm) with the planned updates and tag `@pharmaverse/admiral` so that one of the development core team can sanity check the request. Then there are two main ways to extend the test data: either by adding new datasets or extending existing datasets with new records/variables. Whichever method you choose, it is worth noting the following: -* Programs that generate test data are stored in the `dev/` folder. -* Each of these programs is written as a standalone R script: if any packages need to be loaded for a given program, then call `library()` at the start of the program (but please do __not__ call `library(pharmaversesdtm)`). -* Most of the packages that you are likely to need will already be specified in the `renv.lock` file, so they will already be installed if you have been keeping in sync--you can check this by entering `renv::status()` in the Console. However, you may also wish to install `{metatools}` and `{ggplot2}`, which are currently not specified in the `renv.lock` file. If you feel that you need to install any other packages in addition to those just mentioned, then please tag `@pharmaverse/admiral` to discuss with the development core team. -* When you have created a program in the `dev/` folder, you need to run it as a standalone R script, in order to generate a test dataset that will become part of the `{pharmaversesdtm}` package, but you do not need to build the package. -* Following [best practice](https://r-pkgs.org/data.html#sec-data-data), each dataset is stored as a `.rda` file whose name is consistent with the name of the dataset: for example, the dataset `dm` should be renamed to `raw_dm` before saving it as `raw_dm.rda`; if you save `dm` as `raw_dm.rda` and subsequently load the `.rda` file, then `dm` (not `raw_dm`) will be loaded into the global environment. -* The programs in `dev/` are stored within the `{pharmaversesdtm}` GitHub repository, but they are __not__ part of the `{pharmaversesdtm}` package--the `dev/` folder is specified in `.Rbuildignore`. -* When you run a program that is in the `dev/` folder, you generate a dataset that is written to the `data/` folder, which will become part of the `{pharmaversesdtm}` package. -* The names of test datasets are specified in `R/data.R`, for the purpose of generating documentation in the `man/` folder. +* Programs that generate test data are stored in the `data-raw/` folder. +* Each of these programs is written as a standalone R script: if any packages need to be loaded for a given program, then call `library()` at the start of the program (but please do **not** call `library(pharmaversesdtm)`). +* Most of the packages that you are likely to need will already be specified in the `renv.lock` file, so they will already be installed if you have been keeping in sync--you can check this by entering `renv::status()` in the Console. However, you may also wish to install `{metatools}`, which is currently not specified in the `renv.lock` file. If you feel that you need to install any other packages in addition to those just mentioned, then please tag `@pharmaverse/admiral` to discuss with the development core team. +* When you have created a program in the `data-raw/` folder, you need to run it as a standalone R script, in order to generate a test dataset that will become part of the `{pharmaversesdtm}` package, but you do not need to build the package. +* Following [best practice](https://r-pkgs.org/data.html#sec-data-data), each dataset is stored as a `.rda` file whose name is consistent with the name of the dataset, e.g., dataset `xx` is stored as `xx.rda`. The easiest way to achieve this is to use `usethis::use_data(xx)` +* The programs in `data-raw/` are stored within the `{pharmaversesdtm}` GitHub repository, but they are **not** part of the `{pharmaversesdtm}` package--the `data-raw/` folder is specified in `.Rbuildignore`. +* When you run a program that is in the `data-raw/` folder, you generate a dataset that is written to the `data/` folder, which will become part of the `{pharmaversesdtm}` package. +* The names and sources of test datasets are specified in `R/data.R`, for the purpose of generating documentation in the `man/` folder. ## Adding New SDTM Datasets -* Create a program in the `dev/` folder, named `.R`, where `` is the SDTM domain name, (e.g. `rs.R`), to generate the test data and output `.rda` to the `data/` folder. Use CDISC pilot data such as `dm` as input in this program in order to create realistic synthetic data that remains consistent with other domains. Note that __no personal data should be used__ as part of this package, even if anonymized. +* Create a program in the `data-raw/` folder, named `.R`, where `` should follow the [naming convention](#naming), to generate the test data and output `.rda` to the `data/` folder. + * Use CDISC pilot data such as `dm` as input in this program in order to create realistic synthetic data that remains consistent with other domains (not mandatory). + * Note that **no personal data should be used** as part of this package, even if anonymized. * Run the program. * Reflect this update, by specifying `` in `R/data.R`. * Run `devtools::document()` in order to update `NAMESPACE` and update the `.Rd` files in `man/`. +* Add your GitHub handle to `.github/CODEOWNERS`. +* Update `NEWS.md`. ## Updating Existing SDTM Datasets -* Rename the source dataset as `raw_`, where `` is the SDTM domain name (e.g. rename `ds` to `raw_ds`), and then save it to the `data/` folder as `raw_.rda` (e.g. `save(raw_ds, file = "data/raw_ds.rda")`). -* Create a program in the `dev/` folder, named `update_.R`, to load `raw_.rda`, make the updates, and output `.rda` to the `data/` folder. -* Run the program. -* Reflect this update, by specifying both `raw_` and `` in `R/data.R`. +* Locate the existing program `.R` in the `data-raw/` folder, update it accordingly. +* Run the program, and output updated `.rda` to the `data/` folder. * Run `devtools::document()` in order to update `NAMESPACE` and update the `.Rd` files in `man/`. +* Add your GitHub handle to `.github/CODEOWNERS`. +* Update `NEWS.md`. + diff --git a/_pkgdown.yml b/_pkgdown.yml index f6c000d..3dabdee 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -12,56 +12,14 @@ repo: user: https://github.com/ news: cran_dates: true -reference: -- title: Derivations for Adding Variables -- subtitle: ADXX-specific - desc: Derivation Functions helpful for building the ADXX dataset -- contents: - - has_keyword("der_adxx") - -- title: Derivations for Adding Parameters -- subtitle: ADXX-specific - desc: Parameter Derivation Functions helpful for building the ADXX dataset -- contents: - - has_keyword("der_prm_adxx") - -- title: Advanced Functions -- subtitle: Pre-Defined Source Objects - desc: Source objects defined by {pharmaversesdtm} -- contents: - - has_keyword("source_specifications") - -- title: Utility Functions -- subtitle: Utilities for Formatting Observations -- contents: - - has_keyword('utils_fmt') - -- subtitle: Utilities for Dataset Checking -- contents: - - has_keyword('utils_ds_chk') - -- subtitle: Utilities for Filtering Observations -- contents: - - has_keyword('utils_fil') - -- title: Example Datasets - desc: You can run `admiral::use_ad_template()` to produce additional datasets -- contents: - - has_keyword('datasets') navbar: structure: - left: [getstarted, reference, articles, news] + left: [reference, news] components: - getstarted: - text: Get Started - href: articles/pharmaversesdtm.html reference: - text: Reference - href: reference/index.html - articles: - text: User Guides - menu: - - text: Creating ADXX - href: articles/adxx.html + text: Reference + href: reference/index.html + + diff --git a/data-raw/pc.R b/data-raw/pc.R index 5e43b0e..4b7cd6c 100644 --- a/data-raw/pc.R +++ b/data-raw/pc.R @@ -2,7 +2,6 @@ library(haven) # Load xpt library(plyr) library(dplyr) # apply distincts library(lubridate) -library(ggplot2) library(labelled) library(admiral) @@ -152,11 +151,6 @@ pc <- pc %>% ) -# Some test to look the overall figure -plot <- ggplot(pc, aes(x = PCTPTNUM, y = PCSTRESN, group = USUBJID)) + - geom_line() + - geom_point() - # ---- Save output ---- save(pc, file = "data/pc.rda", compress = "bzip2") diff --git a/data-raw/pp.R b/data-raw/pp.R index 653a83f..c75c5f6 100644 --- a/data-raw/pp.R +++ b/data-raw/pp.R @@ -1,7 +1,6 @@ library(haven) # Load xpt library(dplyr) # apply distincts library(lubridate) -library(ggplot2) library(labelled) library(admiral) diff --git a/data-raw/qs.R b/data-raw/qs.R deleted file mode 100644 index bc8c4cc..0000000 --- a/data-raw/qs.R +++ /dev/null @@ -1,107 +0,0 @@ -#' Description : create VFQ questionnaire test data for ADMIRAL Ophtha - -library(metatools) -library(dplyr) -library(haven) -library(admiral) - - -# from CDISC pilot study ---- -sdtm_path <- "https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/" # nolint -raw_qs <- read_xpt(paste0(sdtm_path, "qs", ".xpt?raw=true")) %>% - convert_blanks_to_na() - -# create new QS data - keep standard variables from previous ADMIRAL project's QS ---- -qs1 <- raw_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() %>% - ungroup() - -dummy_param <- tibble(tribble( - ~QSTEST, ~QSSTRESC, ~QSSTRESN, - "Your Overall Health Is", "GOOD", 1, - "Eyesight Using Both Eyes Is", "FAIR", 3, - "How Often You Worry About Eyesight", "RARELY", 4, - "How Much Pain in and Around Eyes", "NO", 3, - "Difficulty Reading Newspapers", "SOME DIFFICULTY", 2, - "Difficulty Doing Work/Hobbies", "NO DIFFICULTY", 1, - "Difficulty Finding on Crowded Shelf", "NO DIFFICULTY", 1, - "Difficulty Reading Street Signs", "SOME DIFFICULTY", 2, - "Difficulty Going Down Step at Night", "SOME DIFFICULTY", 2, - "Difficulty Noticing Objects to Side", "SOME DIFFICULTY", 2, - "Difficulty Seeing How People React", "SOME DIFFICULTY", 2, - "Difficulty Picking Out Own Clothes", "NO DIFFICULTY", 1, - "Difficulty Visiting With People", "NO DIFFICULTY", 1, - "Difficulty Going Out to See Movies", "SOME DIFFICULTY", 2, - "Are You Currently Driving", "YES", 1, - "Never Driven or Given Up Driving", "NO", 3, - "Main Reason You Gave Up Driving", "NO", 3, - "Difficulty Driving During Daytime", "NO", 3, - "Difficulty Driving at Night", "YES", 1, - "Driving in Difficult Conditions", "YES", 1, - "Eye Pain Keep From Doing What Like", "YES", 1, - "I Stay Home Most of the Time", "NO", 3, - "I Feel Frustrated a Lot of the Time", "SOMETIMES", 2, - "I Need a Lot of Help From Others", "SOMETIMES", 2, - "Worry I'll Do Embarrassing Things", "YES", 1, - "Difficulty Reading Small Print", "VERY DIFFICULT", 3, - "Difficulty Figure Out Bill Accuracy", "SOME DIFFICULTY", 2, - "Difficulty Shaving or Styling Hair", "NO DIFFICULTY", 1, - "Difficulty Recognizing People", "NO DIFFICULTY", 1, - "Difficulty Taking Part in Sports", "SOME DIFFICULTY", 2, - "Difficulty Seeing Programs on TV", "NO DIFFICULTY", 1, -)) - -# create dummy qs ==== -dummy_qs <- dummy_param %>% - mutate( - QSORRES = QSSTRESC, - QSTESTCD = paste0("VFQ", row_number()), - QSCAT = "NEI VFQ-25", - QSSCAT = "Original Response" - ) - -# merge standard QS with parameters and result variables from temp QS data -ophtha_qs <- merge(qs1, dummy_qs) %>% - group_by(USUBJID) %>% - # create QSSEQ based on VFQ QS parameters - mutate(QSSEQ = row_number()) %>% - arrange(USUBJID, QSSEQ) %>% - select( - STUDYID, DOMAIN, USUBJID, QSSEQ, QSTESTCD, QSTEST, QSCAT, QSSCAT, - QSORRES, QSSTRESC, QSSTRESN, QSBLFL, VISITNUM, - VISIT, VISITDY, QSDTC, QSDY - ) %>% - ungroup() - -# Add Ophthamology questionnaire to CDISC to questionnaire -admiral_qs <- raw_qs %>% - bind_rows(ophtha_qs) %>% - add_labels( - STUDYID = "Study Identifier", - DOMAIN = "Domain Abbreviation", - USUBJID = "Unique Subject Identifier", - QSSEQ = "Sequence Number", - QSTESTCD = "Question Short Name", - QSTEST = "Question Name", - QSCAT = "Category of Question", - QSSCAT = "Subcategory for Question", - QSORRES = "Findings in Original Units", - QSORRESU = "Original Units", - QSSTRESC = "Character Result/Finding in Std Format", - QSSTRESN = "Numeric Result/Finding in Standard Units", - QSSTRESU = "Standard Units", - QSBLFL = "Baseline Flag", - QSDRVFL = "Derived Flag", - VISITNUM = "Visit Number", - VISIT = "Visit Name", - VISITDY = "Planned Study Day of Visit", - QSDTC = "Date/Time of Finding", - QSDY = "Study Day of Finding" - ) - -qs <- admiral_qs -save(qs, file = "data/qs.rda", compress = "bzip2") diff --git a/data/qs.rda b/data/qs.rda deleted file mode 100644 index 28f7f49..0000000 Binary files a/data/qs.rda and /dev/null differ diff --git a/man/qs.Rd b/man/qs.Rd deleted file mode 100644 index b9f5eab..0000000 --- a/man/qs.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{qs} -\alias{qs} -\title{Questionnaire Dataset} -\format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 202907 rows and 20 columns. -} -\source{ -\url{https://github.com/pharmaverse/admiral.test/blob/main/data/admiral_qs.rda} # nolint -} -\usage{ -qs -} -\description{ -A SDTM QS dataset from the CDISC pilot project & Ophthalmology test data -} -\keyword{datasets} diff --git a/staged_dependencies.yaml b/staged_dependencies.yaml index 0870191..c941541 100644 --- a/staged_dependencies.yaml +++ b/staged_dependencies.yaml @@ -1,12 +1,15 @@ --- current_repo: - repo: pharmaverse/admiraltemplate + repo: pharmaverse/pharmaversesdtm host: https://github.com upstream_repos: +downstream_repos: - repo: pharmaverse/admiral host: https://github.com - - repo: pharmaverse/admiral.test + - repo: pharmaverse/admiralonco host: https://github.com - - repo: pharmaverse/admiraldev + - repo: pharmaverse/admiralvaccine host: https://github.com -downstream_repos: + - repo: pharmaverse/admiralophtha + host: https://github.com + diff --git a/vignettes/adxx.Rmd b/vignettes/adxx.Rmd deleted file mode 100644 index 0cd1331..0000000 --- a/vignettes/adxx.Rmd +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: "Creating ADXX" -output: - rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Creating ADXX} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -```{r setup, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -# Introduction - -This article describes creating SDTM datasets. diff --git a/vignettes/pharmaversesdtm.Rmd b/vignettes/pharmaversesdtm.Rmd deleted file mode 100644 index 1afced6..0000000 --- a/vignettes/pharmaversesdtm.Rmd +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: "Get Started" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Get Started} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -```{r eval=FALSE} -library(pharmaversesdtm) -``` - -Introduction to how to use the package extension...