Skip to content

Commit

Permalink
update: #84 merge in pkgdown update, explain data package, testing ou…
Browse files Browse the repository at this point in the history
…t label function

Merge remote-tracking branch 'origin/122_update_pkgdown' into 84_xportr_deep_dive_vignette

# Conflicts:
#	_pkgdown.yml
  • Loading branch information
bms63 committed May 15, 2023
2 parents beac75f + 18ce510 commit 3f419c1
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: xportr
Title: Utilities to Output CDISC SDTM/ADaM XPT Files
Version: 0.2.0
Version: 0.3.0
Authors@R:
c(
person(given = "Eli",
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# xportr 0.3.0

## New Features and Bug Fixes

* Fixed an issue where `xportr_type` would overwrite column labels, widths, and "sas.formats"
* Fixed messaging of `xportr_order`to give better visability of the number of variables being reordered.
* Add new argument to `xportr_write` to allow users to specify how xpt validation checks are handled.
* Fixed bug where character_types were case sensitive. They are now case insensitive.
* Updated `xportr_type` to make type coercion more explicit.

## Documentation

* Moved `{pkgdown}` site to bootswatch. Enabled search and linked slack icon (#122).

# xportr 0.2.0
* Added a new validation test that errors when users pass invalid formats (#60 #64). Thanks to @zdz2101!
* Fixed an issue where xportr_format could pass invalid formats to haven::write_xpt.
Expand Down
15 changes: 12 additions & 3 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ search:
exclude: ['news/index.html']
repo:
url:
home: https://atorus-research.github.io/xportr
source: https://atorus-research.github.io/xportrblob/main/
issue: https://atorus-research.github.io/xportr/issues/
home: https://github.com/atorus-research/xportr
source: https://github.com/atorus-research/xportr/blob/main
issue: https://github.com/atorus-research/xportr/issues
user: https://github.com/
news:
cran_dates: true

navbar:
structure:
right: [slack, github]
components:
slack:
icon: fa-slack
href: https://pharmaverse.slack.com/archives/C030EB2M4GM
aria-label: slack

reference:
- title: The six core xportr functions
Expand Down Expand Up @@ -54,3 +62,4 @@ articles:
navbar: Use Cases
contents:
- deepdive

96 changes: 83 additions & 13 deletions vignettes/deepdive.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,102 @@ library(DT)

# Introduction

This vignette will take you on a thorough journey of all the possibilities of the `xportr` package for applying specification attributes to multiple data sets through the `xportr` functions. We will explore the following:
This vignette will take you on a thorough journey of all the possibilities of the `{xportr}` package for applying information from a metadata object to multiple data sets through the core `{xportr}` functions. We will also explore the following:

* What goes in a Submission to a Health Authority?
* What is `{xportr}` validating?
* Breakdown of `{xportr}` and a ADaM dataset specification file
* Using `{xportr}` `options()`
* Understanding the warning and error messages for each `{xportr}` function
* Using `{xportr}` to bulk process multiple datasets and Validation Software (?)
* What is `{xportr}` validating behind the scenes?
* Using `options()` to enhance your `{xportr}` experience.
* Breakdown of `{xportr}` and a ADaM dataset specification file.
* Understanding the warning and error messages for each `{xportr}` function.
* Using `{xportr}` to bulk process multiple datasets.
* Preparing xpt files for upload to a validation software
* Future work

Before we begin, we encourage users to review the [Get Started Page](xportr.Rmd). This contains a simple walk through of applying `{xportr}` functions to an ADSL dataset given a specification file. It is way less verbose!


# What goes in a Submission to a Health Authority?

## FDA
Quite a bit! We will focus on the data deliverables needed for a successful submission to a Health Authority, which we can break down into three parts:

1) Study Data Standardization Plan
2) SDTM Data Package
3) ADaM Data Package

## Study Data Standardization Plan

The Study Data Standardization Plan (SDSP) establishes and documents a plan for describing the data standardization approach for clinical and nonclinical studies within a development program. The SDSP also assists the FDA in identifying potential data standardization issues early in the development program. We hope the brevity of this section does not belie the huge importance of this document. Please see [Study Data Standardisation Plan (SDSP) Package](https://advance.phuse.global/display/WEL/Study+Data+Standardisation+Plan+%28SDSP%29+Package) maintained by the [PHUSE working group](https://advance.phuse.global/display/WEL/Welcome+to+the+PHUSE+Advance+Hub). However, we want to focus more on the actual data and how `{xportr}` can play a role in the submission.

## SDTM Data Package

The primary pieces of the SDTM package are the SDTM annotated case report forms (acrf.pdf), the data definitions document (define.xml), the Study Data Reviewer's Guide (sdrg.pdf) and the datasets in xpt Version 5 format. The Version 5 xpt file is the **required** submission format for all datasets going to the Health Authorities.

In preparing the SDTM Data package, `{xportr}` can be used to apply information from the data specification files to the dataset. The `xportr_write()` can then be used to write out the final dataset as an `xpt` file that can be submitted to a Health Authority.

A Submission is a large package of information on a clinical trial.
## ADaM Data Package

Version 5 xpts are the ADaM datasets that are submitted through the eTcd portal
The key components of the ADaM package are very similar to SDTM package with a few additions: define.xml, Analysis Study Data Reviewer's Guide (adrg.pdf), Analysis Results Metadata (analysis-results-metadata.pdf) and datasets as Version 5 xpt format.

* What is `{xportr}` validating?
In preparing the SDTM Data package, `{xportr}` can be used to apply information from the data specification files to the dataset. The `xportr_write()` can then be used to write out the final dataset as an `xpt` file that can be submitted to a Health Authority.

In `{xportr} v0.3.0` we give the users the ability to apply labels, formats, types, lengths to the R dataframe. xportr also has the ability to order the dataset according to the specification file as well as write out the R dataframe as a version 5 xpt file, which is the preferred data standard to submit to health authoritries like the FDA.
## What is `{xportr}` validating?

The xpt Version 5 files form the backbone of any successful Submission and are govern by quite a lot of rules and suggested guidelines. As you are preparing your packages for submission the suite of `{xportr}` functions and `xprotr_write()`, help to check that your datasets are submission compliant.

In `{xportr} v0.3.0` we give the users the ability to apply labels, formats, types, lengths to the R dataframe. `{xportr}` also has the ability to order the dataset according to the specification file as well as write out the R dataframe as a xpt Version 5 file, which is the preferred data standard to submit to health authorities like the FDA.

We have developed the `{xportr}` functions to allow users flexibility to use errors and warnings to let them know of issues in their datasets or in their specification files. For example, let's say an accident deletion of the **TRTSDT** variable label occurred in the specification file. Using `xportr_label()` to apply all the labels would immediately alert the user that **TRTSDT**, while in the data, does not have an appropriate label available to applied to it.


```{r, message = FALSE, echo = FALSE}
library(dplyr)
library(xportr)
Several of the xportr function have custom checks to validate.
options(xportr.variable_name = "Variable",
xportr.label = "Label",
xportr.type_name = "Data Type",
xportr.format = "Format")
spec_loc <- here::here("example_data_specs", "TDF_ADaM_Pilot3.xlsx")
var_spec <- readxl::read_xlsx(spec_loc, sheet = "Variables") %>%
filter(Variable != "TRTSDT")
adsl_loc <- here::here("example_data_specs", "adsl.xpt")
adsl <- haven::read_xpt(adsl_loc) %>%
metatools::remove_labels()
```


```{r}
adsl_lbl <- xportr_label(adsl, var_spec, "ADSL", verbose = "warn")
```

```{r}
library(dplyr)
library(xportr)
options(xportr.variable_name = "Variable",
xportr.label = "Label",
xportr.type_name = "Data Type",
xportr.format = "Format")
spec_loc <- here::here("example_data_specs", "TDF_ADaM_Pilot3.xlsx")
var_spec <- readxl::read_xlsx(spec_loc, sheet = "Variables") %>%
mutate(Label = if_else(Variable == "TRTSDT",
"Date of First Exposure to Treatment Date of First Exposure to Treatment", Label))
adsl_loc <- here::here("example_data_specs", "adsl.xpt")
adsl <- haven::read_xpt(adsl_loc) %>%
metatools::remove_labels()
```


```{r}
adsl_lbl <- xportr_label(adsl, var_spec, "ADSL", verbose = "warn")
```

Example: `xportr_label()` while applying labels form the specification will make sure that the label is <40 characters.

Expand Down

0 comments on commit 3f419c1

Please sign in to comment.