Survival Analysis with visR using CDISC ADaM Time-To-Event Analysis Dataset (ADTTE)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

This tutorial illustrates how a standard time-to-event analysis can be done very efficiently when the data set adheres to the CDISC ADaM standard. A more detailed time-to-event analysis with a more broad overview of visR's functionality is presented in another vignette.

library(ggplot2)
library(visR)

Global Document Setup

# Metadata Title
DATASET <- paste0("Analyis Data Time-To-Event (ADTTE)")

# Save original options()
old <- options()  

# Global formatting options
options(digits = 3)

# Global ggplot settings
theme_set(theme_bw())

# Global table settings 
options(DT.options = list(pageLength = 10, 
                          language = list(search = 'Filter:'), 
                          scrollX = TRUE))

# load ADTTE from CDISC pilot 
data(adtte)

# Restore original options()
options(old)

Time-to-event analysis

visR includes a wrapper function to easily display summary tables (e.g. tableone)

# Display a summary table (e.g. tableone)
visR::tableone(adtte[,c("TRTP", "AGE")],
         title = "Demographic summary" , datasource = DATASET)

The wrapper function to estimate a Kaplan-Meier curve is compatible with %>% and purrr::map functions without losing traceability of the dataset name inside the call of the object. If a data set adheres to the CDISC ADaM standards, only a stratifier needs to be specified.

# Estimate a survival object
survfit_object <-  adtte %>%
  visR::estimate_KM(data = ., strata = "TRTP")
survfit_object

Given a survival object, visR includes several functions to quickly extract additional information from the survival object (e.g. test statistics and p-values) and a general function to display a table (render).

# Display test statistics associated with the survival estimate

visR::render(survfit_object %>% get_pvalue(), title = "P-values", datasource = DATASET)

A survival object can be plotted using the visR function visr. Additional information like confidence intervals and a risktable can be added to the plot.

# Create and display a Kaplan-Meier from the survival object and add a risktable
visr(survfit_object) %>% 
  visR::add_CI() %>%
  visR::add_risktable()


Try the visR package in your browser

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

visR documentation built on Nov. 21, 2023, 1:07 a.m.