Pre-processing of clinical data for clinical data review report

    echo = TRUE, 
    results = 'asis', 
    warning = FALSE, 
    error = FALSE, message = FALSE, cache = FALSE,
    fig.width = 8, fig.height = 7,
    fig.path = "./figures_vignette/",
    fig.align = 'center')
options(width = 170)#, stringsAsFactors = FALSE
options(warn = 1)#instead of warn = 0 by default -> to have place where warnings occur in the call to Sweave function

heightLineIn  <- 0.2

This vignette shows functionalities used for annotating and filtering the data within the clinDataReview package.

Utility functions to automate standard pre-processing steps of the data are available in the package.

Note that these functions are mainly useful in combination with the specification of the parameters in 'config' file in the clinical data reports (see the dedicated reporting vignette).

For this vignette, we will use example data available in the clinUtils package.


Data format

The input dataset for the clinical data review should be a data.frame with clinical data. Such data is typically imported from SAS data file or xpt data file.
Such dataset can be imported for multiple files at once via the clinUtils::loadDataADaMSDTM function.

The label of the variables stored in the SAS datasets is also used for title/captions.

A few ADaM datasets are included in the clinUtils package for the demonstration, via the dataset dataADaMCDISCP01 and corresponding variable labels.


labelVars <- attr(dataADaMCDISCP01, "labelVars")

dataLB <- dataADaMCDISCP01$ADLBC
dataDM <- dataADaMCDISCP01$ADSL
dataAE <- dataADaMCDISCP01$ADAE

Annotate data

The annotateData enables to add metadata for a specific domain/dataset.

dataLBAnnot <- annotateData(
    data = dataLB, 
    annotations = list(data = dataDM, vars = c("ETHNIC", "ARM")), 
    verbose = TRUE
    caption = paste("Laboratory parameters annotated with",
        "demographics information with the `annotatedData` function"

Filter data

The filterData enables to filter a dataset.

dataLBAnnotTreatment <- filterData(
    data = dataLBAnnot, 
    filters = list(var = "ARM", value = "Placebo", rev = TRUE), 
    verbose = TRUE
    unique(dataLBAnnotTreatment[, c("USUBJID", "ARM")]), 
    caption = paste("Subset of laboratory parameters filtered",
        "with placebo patients"

Transform data

The transformData enables to convert data to a different format.

For example, the laboratory data is converted from a long format, containing one record per endpoint * visit * subject to a wide format containing one record per visit * subject. The endpoints are included in different columns.

eDishData <- transformData(
    data = subset(dataLB, PARAMCD %in% c("ALT", "BILI")),
    transformations = list(
        type = "pivot_wider",
        varsID = c("USUBJID", "VISIT"), 
        varsValue = c("LBSTRESN", "LBNRIND"),
        varPivot = "PARAMCD"
    verbose = TRUE,
    labelVars = labelVars

Process data

The processData function executes all the pre-processing steps described in the previous section at once.

dataLBAnnotTreatment2 <- processData(
    data = dataLB,
    processing = list(
        list(annotate = list(data = dataDM, vars = c("ETHNIC", "ARM"))),
        list(filter = list(var = "ARM", value = "Placebo", rev = TRUE))
    verbose = TRUE

identical(dataLBAnnotTreatment, dataLBAnnotTreatment2)


Session info


Try the clinDataReview package in your browser

Any scripts or data that you put into this service are public.

clinDataReview documentation built on March 18, 2022, 6:10 p.m.