3  Creating SDTMs in R

3.1 Introduction to the SDTM

SDTM stands for Study Data Tabulation Model. It is a data structure developed by CDISC to harmonize raw clinical data. The full implementation guidelines of this model are found in a document called the SDTM Implementation Guide. The latest versions of this guide can be found on the CDISC website SDTM IG. You will need to create an account on the website before downloading the implementation guide.

The harmonization is done by topic and therefore all related clinical data are grouped under one topic e.g laboratory findings and given a domain name in this case LB (Laboratory Test Results).

Raw clinical data is organized into various domain classes which form part of the SDTM. These classes and specific domains (data sets) contained in each are summarized below;

3.1.1 Special Purpose Domain Class

This class contains the following data sets;

  • Demographics (DM)

This domain contains subject level information like age, race, gender, ethnicity and other important treatment related variables. This is the parent domain for all other observations for human clinical subjects.

  • Subject Visits (SV)

This domain contains information on subject visits as planned in the protocol. It contains information on both actual and planned visits. When combined with Trial Visit information, it can help the sponsor in identifying missed visits.

  • Subject Elements (SE)

This domain contains the actual order of elements followed by the subject together with start and end dates for each element. An element is more gradular than epoch, an element is defined at a subjec level, whereas an epoch is defined at a study level.

  • Comments Dataset (CO)

This domain contains other descriptive comments that may be collected alongside other data.

3.1.2 Events Domain Class

This class contains the following data sets;

  • Adverse Events (AE)

This domain contains information on any untoward medical occurrence experienced by the subject which may not necessarily be associated with the medical product being administered. Examples of untoward occurrences may include nausea, skin rash etc.

  • Medical History (MH)

This domain contains information on the past medical history of the subject.

  • Clinical Events (CE)

This domain contains other clinical events that would not be classified as adverse events.

  • Biospecimen Events (BE)

This domain documents actions taken that affect or may affect a specimen (e.g., specimen collection, freezing and thawing, aliquoting, transportation)

  • Dispositions (DS)

This domains contains information on a subject’s disposition status. It provides an accounting for all subjects who entered the study and may include protocol milestones, such as randomization,as well as the subject’s completion status or reason for discontinuation for the entire study or each phase or segment of the study, including screening and post-treatment follow-up.

  • Healthcare Encounters (HO)

An events domain that contains data for inpatient and outpatient healthcare events (e.g., hospitalization, nursing home stay, rehabilitation facility stay, ambulatory surgery).

  • Protocol Deviations (DV)

An events domain that contains protocol violations and deviations during the course of the study. These are deviations that occur after a subject has been randomized or received their first dose of the study treatment.

3.1.3 Findings Domain Class

This class contains the following data sets;

  • Laboratory Findings (LB)

A findings domain that contains laboratory test data such as hematology, clinical chemistry and urinalysis. This domain does not include microbiology or pharmacokinetic data, which are stored in separate domains.

  • Vital Signs (VS)

A findings domain that contains measurements including but not limited to blood pressure, temperature, respiration, body surface area, body mass index, height and weight. This information is useful in evaluating patient safety.

  • Electrocardiograms (ECGs)

A findings domain that contains ECG data, including position of the subject, method of evaluation, all cycle measurements and all findings from the ECG including an overall interpretation if collected or derived.

Electrocardiograms are tests meant to record your heart’s electrical activity. This is useful in determining your heart rate and rhythm and detecting any abnormal electrical activities. This information can be used in diagnosis of heart attacks.

  • Questionnaire data set (QS)

A findings domain that contains data for named, stand-alone instruments designed to provide an assessment of a concept. Questionnaires have a defined standard structure, format, and content; consist of conceptually related items that are typically scored; and have documented methods for administration and analysis.

This information in useful in evaluation of patient reported outcomes (PROs) in clinical research. The information in this domain is also useful in assessing the quality of life (QoL) of the study participants.

  • Drug/Product Accountability (DA)

A findings domain that contains the accountability of study products, such as information on the receipt, dispensing, return, and packaging.

  • Death Details (DD)

A findings domain that contains the diagnosis of the cause of death for a subject.The domain is designed to hold supplemental data that are typically collected when a death occurs, such as the official cause of death and the date on which the death occurred.

  • Inclusion/Exclusion Criteria (IE)

A findings domain that contains those criteria that cause the subject to be in violation of the inclusion/exclusion criteria. The main purpose of this domain is to collect responses to only those criteria that the subject did not meet. This information should be collected at the end of a run-in period or before randomization. The violations or deviations found during the course of the study after randomization should not be kept in this domain, it should be kept in the DV domain instead.

  • Findings (FA)

A findings domain that contains the findings about an event or intervention that cannot be represented within an events or interventions domain record or as a supplemental qualifier.

  • PK data (PC/PP)

PC Domain

A findings domain that contains concentrations of drugs or metabolites in fluids or tissues as a function of time.

PP Domain

A findings domain that contains pharmacokinetic parameters derived from pharmacokinetic concentration-time (PC) data.

TipUseful side notes

Pharmacokinetics - refers to how the body reacts to the drug substance.

Four stages of pharmacokinetics

ADME - Absorption, Distribution, Metabolism, and Excretion.

Pharmacodynamics - refers to how the drug interacts with the body, how the drug acts on target sites of action in the body.

Key PK parameter

AUC (Area under the PC concentration time curve).

Tmax - time taken to reach maximum plasma concentration.

T_half (half life) - time taken for the plasma concentration to fall by half once the distribution equilibrium has been reached.

Cmax - maximum plasma concentration.

3.1.4 Intervensions Domain Class

This class contains data sets with information related to the uptake of the drug compound by the trial participant.

  • Exposure (EX)

This domain contains information on the subject’s exposure to protocol specified study treatment. This dataset is usually a derived dataset, it’s derived from EC dataset.

  • Exposure as collected (EC)

This dataset contains information on the subject’s exposure to the treatment as collected. Its usually constructed first before constructing EX.

  • Substance use (SU)

  • Meal data (ML)

3.1.5 Trial Design Class

This is related to information about the experimental study design. It’s not raw data collected. It contains the following data sets;

  • Trial Arms (TA)
  • Trial Visits (TV)
  • Trial Summary (TS)
  • Trial Inclusion and Exclusion criteria (TI)

Some key definitions

Epoch - a period of time that serves a purpose in the trial as a whole.

Arm - a planned path through the trial.

Element - a basic building block in the trial design.

3.1.6 Relationship Class

This contains data sets that represent relationship of variables among data sets. Examples in this class include;

  • Supplimental data sets
  • RelRec data set

3.1.7 Some good images to jog your memory

3.2 Programming SDTMs in R

Space and time does not allow for presentation of R code of all the SDTM domains, so just a few of the domains shall presented in this section. This section is hands-on so please ensure that you already have R and Rstudio (or any editor of choice) installed alongside any necessary packages.

3.2.1 Programming Demographics Dataset (DM)

Demographics data set contain subject level information on trial participants. Information on their gender, race, age, date of randomization, treatments assigned is usually captured in this domain. This data set should strictly contain one record per subject.

In a typical work environment, you will be provided with raw data by the data management team. You will need to create a folder that will store these raw data and then read data from this folder. However for our learning purposes, we have some fake data that we will use. This fake data is stored in the pharmaverseraw and pharmaversesdtm packages.

library(tidyverse)
library(pharmaverseraw)
library(pharmaversesdtm)

raw_dm = pharmaverseraw::dm_raw
raw_ec = pharmaverseraw::ec_raw

glimpse(raw_dm)
Rows: 306
Columns: 13
$ STUDY         <chr> "CDISCPILOT01", "CDISCPILOT01", "CDISCPILOT01", "CDISCPI…
$ PATNUM        <chr> "701-1015", "701-1023", "701-1028", "701-1033", "701-103…
$ IT.AGE        <dbl> 63, 64, 71, 74, 77, 85, 59, 68, 81, 84, 52, 84, 81, 57, …
$ IT.SEX        <chr> "Female", "Male", "Male", "Male", "Female", "Female", "F…
$ IT.ETHNIC     <chr> "Hispanic or Latino", "Hispanic or Latino", "Not Hispani…
$ IT.RACE       <chr> "White", "White", "White", "White", "White", "White", "W…
$ COUNTRY       <chr> "USA", "USA", "USA", "USA", "USA", "USA", "USA", "USA", …
$ PLANNED_ARM   <chr> "Placebo", "Placebo", "Xan High", "Xan Low", "Xan High",…
$ PLANNED_ARMCD <chr> "Pbo", "Pbo", "Xan_Hi", "Xan_Lo", "Xan_Hi", "Pbo", "Scrn…
$ ACTUAL_ARM    <chr> "Placebo", "Placebo", "Xan High", "Xan Low", "Xan High",…
$ ACTUAL_ARMCD  <chr> "Pbo", "Pbo", "Xan_Hi", "Xan_Lo", "Xan_Hi", "Pbo", "Scrn…
$ COL_DT        <chr> "12/26/2013", "07/22/2012", "07/11/2013", "03/10/2014", …
$ IC_DT         <chr> "12/26/2013", "07/29/2012", "07/12/2013", "03/11/2014", …
# We start by creating variables that have direct copies in raw DM. Our new columns should conform to 
# the naming convention provided by CDISC SDTMIG; Please have the IG open as you program this data set.

dm1 <- raw_dm |> 
  mutate(USUBJID = str_c(STUDY, PATNUM, sep = "_"),
         STUDYID = STUDY,
         SUBJID  = PATNUM)