Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clinical TLF Visualization Platform

A comprehensive, production-ready Shiny application for visualizing clinical trial data following CDISC SDTM standards. This application demonstrates advanced features including cross-filtering, drill-down navigation, faceting, bookmarking, and user preferences.

Features

Core Capabilities

  • Modular Architecture: Scalable, maintainable codebase with reusable modules
  • SDTM Compliance: Supports standard CDISC domains (DM, AE, LB, VS)
  • TLF Visualization: Tables, Listings, and Figures optimized for clinical data

Advanced Features

  • Cross-Filtering: Filters cascade across all modules automatically
  • Drill-Down Navigation: Click tables/plots to explore detailed data
  • Faceting: Dynamic grouping and small multiples for comparative analysis
  • Bookmarking: Save and share application state via URL
  • User Preferences: Customize appearance, behavior, and defaults
  • State Management: Centralized reactive state for consistency

Project Structure

clinical_tlf_app/
├── app.R                          # Main application file
├── global.R                       # Global environment setup
├── ARCHITECTURE.md                # Detailed architecture documentation
├── README.md                      # This file
│
├── config/
│   └── app_config.R              # Configuration settings
│
├── data/
│   ├── create_sdtm_data.R        # Data generation script
│   └── sdtm/                     # SDTM datasets (RDS/CSV)
│       ├── dm.rds
│       ├── ae.rds
│       ├── lb.rds
│       └── vs.rds
│
├── utils/
│   ├── state_management.R        # Reactive state management
│   ├── bookmark_utils.R          # URL bookmarking utilities
│   └── data_utils.R              # Data processing functions
│
├── modules/
│   ├── core/
│   │   ├── filter_module.R       # Cross-domain filtering
│   │   └── preferences_module.R  # User preferences
│   │
│   └── tlf/
│       ├── tlf_table_module.R    # Summary tables
│       ├── tlf_listing_module.R  # Data listings
│       └── tlf_figure_module.R   # Interactive figures
│
└── www/
    └── custom.css                # Custom styling

Installation

Prerequisites

  • R (>= 4.0.0)
  • RStudio (recommended)

Required Packages

install.packages(c(
  "shiny",           # Web application framework
  "bslib",           # Modern UI theming
  "DT",              # Interactive tables
  "plotly",          # Interactive plots
  "ggplot2",         # Static plots
  "dplyr",           # Data manipulation
  "tidyr",           # Data tidying
  "shinyWidgets",    # Enhanced widgets
  "jsonlite"         # JSON parsing
))

Setup

  1. Clone or download the repository
  2. Navigate to the clinical_tlf_app directory
  3. Generate sample data:
    source("data/create_sdtm_data.R")
  4. Run the application:
    shiny::runApp()

Usage Guide

Getting Started

  1. Overview Tab: View study summary and quick statistics
  2. Filters: Use the sidebar to apply filters across all domains
  3. Tables: Generate summary tables grouped by various variables
  4. Listings: Explore detailed record-level data
  5. Figures: Create interactive visualizations with faceting

Cross-Filtering Workflow

  1. Navigate to any tab (Tables, Listings, or Figures)
  2. Open the filter sidebar
  3. Select filters from any domain (DM, AE, LB, VS)
  4. Click "Apply" to update all modules
  5. Filters persist across tab navigation

Example:

  • Filter to "Drug 50mg" treatment arm
  • Filter to "SEVERE" adverse events
  • All tables, listings, and figures update automatically

Drill-Down Navigation

From Tables:

  • Select rows in summary tables
  • View automatically filters to selected subgroups

From Listings:

  • Click any row to see full record details
  • Detail panel shows all fields for the selected record

From Figures:

  • Click plot points to filter to specific subgroups
  • Use plotly tools to zoom, pan, and explore

Faceting

  1. Navigate to the Figures tab
  2. Enable "Faceting" checkbox
  3. Select facet variable (ARM, SEX, SITEID)
  4. Choose facet layout (Wrap or Grid)
  5. Plot automatically splits into small multiples

Bookmarking

  1. Apply desired filters and navigate to desired view
  2. Click "Bookmark" button in header
  3. Copy the generated URL
  4. Share URL with colleagues or save for later
  5. Opening the URL restores exact application state

User Preferences

  1. Click "Preferences" button in header
  2. Customize:
    • Theme (light/dark)
    • Default page length
    • Default grouping variable
    • Export settings
  3. Click "Save Preferences"
  4. Settings persist across sessions

Data Domains

DM (Demographics)

  • Subject-level baseline characteristics
  • Variables: USUBJID, AGE, SEX, RACE, ARM, SITEID
  • Used for: Demographics tables, baseline summaries

AE (Adverse Events)

  • Safety event data
  • Variables: AETERM, AESEV, AESER, AEREL, AEOUT
  • Used for: Safety tables, AE visualizations

LB (Laboratory)

  • Clinical laboratory results
  • Variables: LBTESTCD, LBSTRESN, LBNRIND, VISIT
  • Used for: Lab tables, time-series plots, shift tables

VS (Vital Signs)

  • Physiological measurements
  • Variables: VSTESTCD, VSSTRESN, VISIT
  • Used for: Vital sign trends, safety monitoring

Configuration

App Configuration (config/app_config.R)

Customize application behavior:

  • Data paths and formats
  • UI theme and styling
  • Feature flags (enable/disable features)
  • Domain-specific settings
  • Plot colors and defaults

Example:

app_config$ui$theme <- "darkly"  # Dark theme
app_config$features$enable_bookmarking <- FALSE  # Disable bookmarking

Adding New Domains

  1. Create data generation function in create_sdtm_data.R
  2. Add domain configuration in app_config.R
  3. Update load_sdtm_data() in data_utils.R
  4. Create module in modules/tlf/ (optional)
  5. Add filters in filter_module.R

Advanced Usage

Custom Analysis

Add custom analyses by:

  1. Creating new module in modules/
  2. Sourcing module in global.R
  3. Adding UI/server in app.R
  4. Connecting to app_state for cross-filtering

Database Integration

Replace file-based data with database:

  1. Modify load_sdtm_data() in data_utils.R
  2. Use DBI package to connect to database
  3. Implement lazy loading for large datasets
  4. Add caching for performance

Export Enhancements

Extend export capabilities:

  1. Add export buttons to modules
  2. Use writexl for Excel export
  3. Use rmarkdown for PDF reports
  4. Include filter metadata in exports

Performance Considerations

  • Data Size: Tested with 150 subjects, ~15,000 records
  • Scalability: Use database backend for >100,000 records
  • Caching: Implement caching for expensive computations
  • Lazy Loading: Load modules on-demand
  • Async: Use promises for long operations

Development

Testing

Unit tests can be added using:

  • shinytest2 for module testing
  • testthat for utility function testing

Deployment

Deploy to:

  • Shiny Server (open source)
  • RStudio Connect (enterprise)
  • ShinyApps.io (cloud)
  • Docker (containerized)

Contributing

To extend the application:

  1. Follow modular architecture patterns
  2. Use state management for cross-module communication
  3. Document new features in ARCHITECTURE.md
  4. Add configuration options in app_config.R

Troubleshooting

Common Issues

Application won't start:

  • Check all packages are installed
  • Run source("global.R") to check for errors
  • Verify data files exist in data/sdtm/

Filters not working:

  • Ensure filter module is connected to app_state
  • Check get_filtered_data() is called in modules
  • Verify trigger_update is incrementing

Bookmarks not restoring:

  • Check URL parameters are present
  • Verify restore_from_url() is called
  • Ensure enableBookmarking() is set

License

This is a demonstration project for portfolio/professional purposes.

Contact

For questions or issues, please refer to the project documentation or contact the development team.


Version: 1.0.0 Last Updated: 2025-10-20 Built with: R Shiny, bslib, plotly, DT

About

Interactive R Shiny app for visualizing clinical trial data (CDISC SDTM). Features cross-filtering, drill-down analysis, faceting, and shareable bookmarks. Built for clinical data analysts and pharmaceutical research.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages