Clinical Report with R II

A Shiny App for Fast Statistical Analysis


Tao Xiang

2026-01-23

Agenda

  • Background and Introduction

  • App Development and how to use

  • Live Demo and Discussion

Background and Introduction

Backgroud of development

“Clinical Report with R” is on of workshop I made in summer of 2024. The core is developing TFL workflow in R, which is a migration from our SAS workflow to R. However, comparing with common programming method to generate TFL, more efficient, automatical visualization tool is desired by our department. So, I turned to another powerful solution, R Shiny.

Introduction to R Shiny

Shiny is an R package that makes it easy to build interactive web applications (apps) straight from R without any frontend knowledge(HTML, CSS, or JavaScript).

install.packages("shiny")

Components of Shiny app

  1. The UI (short for user interface) which defines how your app looks
  2. The server function which defines how your app works
library(shiny)
ui <- fluidPage(
  "Hello, world!"
)
server <- function(input, output, session) {
}
shinyApp(ui, server)

What we need from Shiny app

  • Replace SAS/Viya VA/JMP?

  • Give a nice appearance to SAS macros?

  • Compete with other tools?

Nah

Purpose of development

  1. Improve Efficiency

  2. Standardized Workflow

  3. For the whole team

  4. Reproducibility and Traceability

  5. Low cost of app development

What is teal?

  • A RShiny-based interactive data exploration framework

  • Modularized and standardized building blocks

  • Collection of specialized R packages

  • Streamlines creation of web-apps that offers:

    • Dynamic filtering facility
    • Code reproducibility
    • Reporting engine
    • Many data summarization and visualizations

Traditional Shiny App

teal workflow

teal product map

Why choose teal?

Spending months on diving into open-source solutions to statistical analysis. I picked teal for app development baseline framework for the rest but not least reasons:

  • teal is an interactive data exploration framework based on shiny, designed primarily to analyze CDISC clinical trial data

  • teal framework provides application developers with a wide range of customizable standard analysis modules

  • No need to spending a lot of time on UI/UX matters (Bootstrap V5 themes since teal v1.0.0)

  • Built by renowned Roche NEST project team, accepted and collaborated with multiple big pharma. (Sustained development)

  • Rich source of help documents and examples.

Challenges in development

  • Rich source of help documents and examples, which also brought steep learning curve and burdens.

  • Lack of Shiny basic knowledges.

  • Reproducible R environment and continuous integration.

  • AI performed not ideally in solving teal development problems.

Actors

Roles Primary Responsibility
teal app user Use app to product statistical reports, all faculty in BIOS. R knowledge is not required.
teal app developer Create app from built functions from teal ecosystem. Need intermediate R skills like Basic, tidyverse, Shiny, functional programming. Have to learn teal framework with bunch of resources.
teal module developer Create customized modules on internal analysis purpose. Need a little advanced R knowledge. Understand reactive programming in Shiny, meta-programming for source development, familiar with table-grammar R packages like rtables, draw complicated plots with ggplot2, rendering engine R packages for output, so and so forth.
teal framework developer Roche NEST project team and collaborators from other open-source developing team. Create and maintain this frameworks by those SDEs and data scientists.
App Development and how to use

teal4dv

teal4dv is the given name for this shiny app, created and modified from teal ecosystem designed and open sourced by Roche NEST Project. This app is developed for internal use by Innocare Biostat team, applied for statistical monitor and data visualization purpose.

This app (teal4dv v0.0.0.9000) is created for local use at beginning. We will figure out server deployment strategy in future.

App Structure

It was created via usethis::create_package() to make this app a r-package like structure. App version is recorded in DESCRIPTION file.

teal4dv/
    ├── data/
    │   ├── adae.sas7bdat
    │   ├── adlb.sas7bdat
    │   ├── adrs.sas7bdat
    │   ├── adsl.sas7bdat
    │   ├── adtr.sas7bdat
    │   ├── adtte.sas7bdat
    ├── R/
    │   ├── table_with_setting_mod.R
    │   ├── tm_gmod_boxplot.R
    │   ├── tm_gmod_kmplot.R
    │   ├── tm_gmod_spider.R
    │   ├── tm_gmod_swim.R
    │   ├── tm_gmod_waterfall.R
    │   ├── tm_tmod_aesocpt_grade.R
    │   ├── tm_tmod_aesocpt.R
    │   ├── tm_tmod_aesum.R
    │   ├── tm_tmod_summary_bds.R
    │   ├── tm_tmod_summary.R
    │   ├── utils.R
    ├── renv/
    │   ├── .gitignore
    │   ├── activate.R
    │   └── settings.json
    ├── app.R
    ├── DESCRIPTION
    ├── renv.lock
    └── teal4dv.Rproj

Resolve reproducible environment issues

  • Require R >= 4.4.1

  • The renv package helps create reproducible environments for this project and make this app more isolated, portable and reproducible.

Install and running app

Make sure you have installed renv first:

install.packages("renv")

Project Environment was isolated and reproducible via renv. Restore the enviroment for package dependencies each time when version is bumped.

renv::restore()

Run App via:

shiny::runApp()

Development Principles

  • Based on analysis ready source data - ADaM.

  • Accuracy and efficiency first.

  • No coding for users. Meet analysis requirement in ADaM procedures not in Shiny Server back-end.

  • The output format is Shell. So, no need to draw shell for existing modules.

  • Find balance between internal customized format/rules and app performance. (Discuss in demo)

Live Demo

Released modules

  • General Data/Variable Viewer
    • Data Table
    • Variable Browser
  • Disposition, Demographic and baseline summary
    • Demographic and baseline Table
    • Disposition Table
  • Adverse Events
    • AE Summary
    • AE by SOC & PT
    • AE by SOC & PT & Grade
  • Efficacy Analysis
    • Swim Plot
    • Spider Plot
    • Waterfall Plot
    • Kaplan Meier Plot
    • KM Plot (ggsurvfit)
  • Laboratory Evaluations
    • Lab Box Plot
    • Labs Summary Table
Conclusion

Limitation

  • Not able to follow internal standard format completely.

  • Customized modules are limited in starting stage.

  • Lack of support for RTF output format

  • Table output relies on rtables ecosystem.

In-plan works

  • Testing and Bug fixed

  • Validating existing modules compare with SAS

  • Training

  • Continuously develop essential modules (Efficacy summary tables for Response/Time-to-event endpoints, line plot for average change from baseline)

Server deployment concept

Future development

  • More customized modules or use validated teal.module.clinical & teal.module.general modules for internal outputs.

  • Break the limitation of table grammar with rtables (like gtsummary, tplyr)

  • More customized functions for output enhancement.

Thanks