The introduction of innovative tools like Shiny and Quarto has empowered researchers and data scientists to transform complex data into interactive and insightful reports. This progress is not just an improvement in data visualization but a significant leap towards a new paradigm in clinical research.
In this article, we’ll delve into the core functionalities of Shiny and Quarto and explore how we can create dynamic and interactive reports with practical examples.
Before we dive into the practical aspects of using Shiny and Quarto in clinical research, let’s get a brief understanding of these powerful tools:
Shiny is an R package that empowers you to create interactive web applications with ease. It’s particularly well-suited for building interactive reports and dashboards, making it an excellent choice for presenting clinical research data in an engaging and user-friendly manner. With Shiny, you can seamlessly integrate R code with web-based user interfaces, allowing you to create interactive elements like sliders, buttons and plots that respond to user inputs in real time.
Quarto is a dynamic document format that combines code, text and graphics into a single, cohesive document. It’s designed to make reproducible reporting and sharing of research findings straightforward. Quarto integrates with R and other programming languages, making it a valuable tool for creating dynamic clinical research reports that can be easily updated as new data becomes available.
To get started with Shiny and Quarto, you’ll need to set up your environment. Here’s a step-by-step guide to help you install and configure these tools:
install.packages("shiny")
install.packages("tidyverse") install.packages("palmerpenguins")
New Quarto Document Creation Interface
Now that you have Shiny and Quarto set up, you can begin creating interactive clinical research reports and dashboards. In the following sections, we’ll delve deeper into how to harness the power of Shiny and Quarto to transform your clinical research projects.
Next, let’s explore practical examples and case studies that demonstrate their capabilities.
Wondering how open-source technology is transforming pharmaceutical data analysis? Check out this article for an in-depth look at how R Shiny is leading the way in creating more efficient and transparent research methodologies.
In this case study, we’ll explore how Shiny and Quarto can be employed in a clinical trial setting to enhance data analysis, visualization and reporting. Clinical trials are pivotal in evaluating the safety and efficacy of new medical treatments, making them an ideal scenario for demonstrating the capabilities of these tools.
Imagine you’re conducting a clinical trial to assess the effectiveness of a new drug for treating a specific medical condition. Traditional reporting methods might involve static charts and tables that are time-consuming to update as new trial data emerges.
However, with Shiny and Quarto, you can create an interactive dashboard that allows real-time exploration of trial outcomes, ensuring that medical professionals and researchers always have access to the latest information.
Let’s create a Quarto Shiny web application for analyzing clinical trial data using the echarts4r
and reactable
packages. This is a Shiny web application that analyzes clinical trial data using the echarts4r
and reactable
packages within the Shiny framework. It creates an interactive dashboard for exploring and visualizing clinical data.
Let’s break down the Quarto code step by step:
title: "Clinical Data Analysis with {echarts4r} and {reactable} in a Shiny App" format: html: page-layout: custom server: shiny
This specifies metadata and configuration for the document.
# Load your clinical trial data remotes::install_github( "insightsengineering/random.cdisc.data" ) data( "cadsl", package = "random.cdisc.data" ) # Load the required libraries library(shiny) library(echarts4r) library(reactable) library(rmarkdown) library(dplyr)
This code chunk loads the necessary data and libraries.
{random.cdisc.data}
{shiny}
, {echarts4r}
, {reactable}
, {rmarkdown}
and {dplyr}
are loaded to provide the required functionality.#| panel: sidebar selectInput( "sex_filter", "Select Sex", choices = c( "All", unique(as.character(cadsl$SEX)) ) ) selectInput( "race_filter", "Select Race", choices = c( "All", unique(as.character(cadsl$RACE)) ) )
selectInput
elements within the sidebar panel, allowing users to select a sex and a race for data filtering.#| panel: fill echarts4rOutput("echarts_plot") h4("Data used for plot") reactableOutput("reactable_table")
(echarts_plot)
and a reactable table output (reactable_table)
within the main content area.#| context: server filtered_data <- reactive({ df <- cadsl if (input$sex_filter != "All") { df <- df[df$SEX == input$sex_filter, ] } if (input$race_filter != "All") { df <- df[df$RACE == input$race_filter, ] } return(df) }) # ECharts4R plot output$echarts_plot <- renderEcharts4r({ filtered_data() |> group_by(DTHFL) |> e_charts_("AGE") |> e_scatter_("BMRKR1", symbol_size = 5) |> echarts4r::e_title("Safety Analysis") |> echarts4r::e_color( c("green", "red") ) |> echarts4r::e_legend( formatter = 'Death {name}' ) |> e_axis_labels("Age", "Biomarker") |> e_tooltip( formatter = JS( "function(params) { console.log(params); return( 'Age: ' + params.value[0] + '' + 'Biomarker Value: ' + Math.round(params.value[1]) + '' + 'Death: ' + params.seriesName )}" ) ) }) # reactable table output$reactable_table <- renderReactable({ filtered_data() |> reactable() })
filtered_data
that filters the clinical data based on user inputs (selected sex and race).renderEcharts4r
function generates an interactive scatter plot using echarts4r based on the filtered data. The plot visualizes Age vs Biomarker value. The colours on the plot indicate whether a patient has passed away.reactable
based on the filtered data.This code sets up a Shiny web application that allows users to select and filter clinical trial data by sex and race, visualizing the data through an interactive scatter plot and an interactive table. The echarts4r
package is used for creating the scatter plot and the reactable
package is used for generating the interactive table. This interactive dashboard provides a dynamic way to explore and analyze clinical trial data.
--- title: "Clinical Data Analysis with {echarts4r} and {reactable} in a Shiny App" format: html: page-layout: custom server: shiny --- # Load your clinical trial data remotes::install_github( "insightsengineering/random.cdisc.data" ) data( "cadsl", package = "random.cdisc.data" ) # Load the required libraries library(shiny) library(echarts4r) library(reactable) library(rmarkdown) library(dplyr) #| panel: sidebar selectInput( "sex_filter", "Select Sex", choices = c( "All", unique(as.character(cadsl$SEX)) ) ) selectInput( "race_filter", "Select Race", choices = c( "All", unique(as.character(cadsl$RACE)) ) ) #| panel: fill echarts4rOutput("echarts_plot") h4("Data used for plot") reactableOutput("reactable_table") #| context: server filtered_data <- reactive({ df <- cadsl if (input$sex_filter != "All") { df <- df[df$SEX == input$sex_filter, ] } if (input$race_filter != "All") { df <- df[df$RACE == input$race_filter, ] } return(df) }) # ECharts4R plot output$echarts_plot <- renderEcharts4r({ filtered_data() |> group_by(DTHFL) |> e_charts_("AGE") |> e_scatter_("BMRKR1", symbol_size = 5) |> echarts4r::e_title("Safety Analysis") |> echarts4r::e_color( c("green", "red") ) |> echarts4r::e_legend( formatter = 'Death {name}' ) |> e_axis_labels("Age", "Biomarker") |> e_tooltip( formatter = JS( "function(params) { console.log(params); return( 'Age: ' + params.value[0] + '' + 'Biomarker Value: ' + Math.round(params.value[1]) + '' + 'Death: ' + params.seriesName )}" ) ) }) # reactable table output$reactable_table <- renderReactable({ filtered_data() |> reactable() })
Finally, click on “Run Document” at the top of the page. Then open the port where the app is deployed on your browser.
R Console Output with Shiny App Initialization
In this case, it is http://127.0.0.1:7341.
Open this link on the browser. And Voila! We have a Shiny App launched from a Quarto document. Yes, it’s that easy!
In our exploration of clinical research, we’ve uncovered the remarkable potential of Shiny and Quarto to revolutionize the way we collect, analyze and report data.
Clinical research, a cornerstone of medical progress, demands tools that can keep pace with the complexity of healthcare data and the urgency of patient care. Shiny and Quarto rise to this challenge with remarkable capabilities.
The transformative power of Shiny and Quarto in clinical research is undeniable. Their ability to make data come to life, facilitate collaboration and expedite decision-making is a game-changer.
The journey ahead is filled with exciting possibilities, and we encourage you to embark on it with enthusiasm and dedication. Embrace interactive reporting, explore its potential and be part of the movement that is reshaping the future of healthcare research for the betterment of all.
These resources should serve as valuable references for those interested in Shiny, Quarto and the pharmaceutical domain, whether you’re looking to develop interactive applications, create dynamic documents, or stay informed about industry trends and regulations.
We at Appsilon are dedicated advocates of Shiny and Quarto, driven by a profound fascination for their potential in clinical research. With 10+ years of hands-on experience in utilizing these tools, we’ve witnessed their transformative capabilities in enhancing data analysis and reporting in the medical field.
If you’re eager to explore Shiny, Quarto, or have questions and insights to share, we’re here to connect, collaborate, and empower your journey.
Interested in enhancing data integrity in life sciences? Discover the role of R package validation in ensuring reliable and compliant data analysis in this detailed exploration.
The post appeared first on appsilon.com/blog/.