Why a Shiny Tutorial for Pharmacometrics?
R is part of the normal workflow of many in our discipline. We use it to prepare datasets, for analysis, and for visualization and reporting of results.
In our roles, we are often asked to explore other scenarios with our models, simulations and analyses, which typically involves going away, redoing the work and representing the results. Development of end-user applications using the R package shiny is a logical extension of an R-based workflow and allows us to share our work and empower non-quantitative team members to explore data and analyses in real-time. Basic R shiny app development. is fun and easy for even someone with limited R skills.
A tutorial on developing apps with R shiny fits within the mission of ISOP, and was presented at ACOP6 in Crystal City, VA, on October of 2015. This is an online version of that training that provides the basic materials for development of Pharmacometric applications using R shiny.
Rstudio maintains a wonderful introductory tutorial entitled Teach Yourself Shiny that can serve as a starting point for learning how to use the R shiny package If you are completely new to shiny, it may be useful to review this tutorial before reviewing the material below. If R is also new to you, you may want to check out the learning resources at www.rstudio.com/training before taking this tutorial.
Jessica has also prepared a tutorial in CPT:PSP entitled “Interactive Pharmacometric Applications Using R and the Shiny Package” that covers the basics, but also demonstrates how to prepare an app more specific to our discipline, such as preparing a pop PK application.
A total of four presentations were given by the presentors,and the presentations are included as files here.
The Basics of shiny and Workflow(Devin Pastoor)
Devin Pastoor is a PhD Candidate at the University of Maryland. Devin is a PhD Candidate and Clinical Research Scientist. Devin is an experienced Course Instructor for R, and has taught Shiny Intro/Modern R.
During his presentation, Devin and Samer covered building a basic app, server and ui interaction, automating workflows programmatically function writing, ggplot aes_string, and dplyr standard evaluation versions, and converting automated analytic/plot workflows to shiny app. The scripts supporting this are supplied here: https://github.com/dpastoor/acop_shiny_tutorial
Developing Shiny Applications to Simulate Pharmacometric Models (Jessica Wojciechowski)
Jessica Wojciechowski [B.Pharm Sci, B.Pharm (Hons)], PhD Candidate, University of South Australia. Jessica is a Clinical Educator in Pharmacy at the University of South Australia. She has also authored a wonderful tutorial for shiny entitled Interactive Pharmacometric Applications Using R and the Shiny Package in 2015 in CPT:PSP. Jessica’s presentation covers:
- Simulating (and presenting the results of) pharmacometric models
coded in R using differential equations
- Controlling application speed using features from Shiny
- Increasing application speed from R programming
- Designing user-interfaces for others who may use your application
Application of R Shiny in Survival and Meta-Analyses: Tips and Tricks (Jinzhong Liu)
Jinzhong Liu (PhD, Indiana University) is an ORISE Fellow, FDA, Division of Clinical Pharmacology and has authored multiple Shiny Applications. Jinzhong also serves as the Administrator for the ISOP Shiny Server.
In this presentation, Jinzhong covers developing applications for Survival analysis (SASR) and metaanalysis.
Using SASR, data from any user-uploaded file can be viewed in the ‘Data File’ tab. The ideal data file should be a comma-separated values (csv) format for survival analysis. After the user selects a time variable (e.g. stimes), an event variable (e.g. event) and a stratification variable (e.g. treatment), the Kaplan-Meier plot can be viewed or downloaded in the ‘Kaplan-Meier Plot’ tab. This web application is able to visualize ‘logrank test’, ‘multivariate Cox model’ and ‘parametric survival model (accelerated failure time model)’, after the user selects the covariates. Also, once the user selects a drug exposure variable, an E-R analysis with Kaplan-Meier analysis can be viewed or downloaded. R package ‘survival’ was used to perform Kaplan-Meier analysis, log-rank test, Cox model and parametric model.
Jinzhong’s files are attached. The survival analysis app is availabale at https://jzliu.shinyapps.io/SASR/
Using [MARS], literature based data from any user-uploaded file can be viewed in the ‘Data File’ tab. The ideal data file should be a comma-separated values (csv) format available for Meta-Analysis. The data can be either a statistical meta-analysis data file (usually one record for a study) or a pharmacometric data file (longitudinal format, repeated records for a study). For statistical data, 3 main categories of outcomes are ‘two-group comparisons’, ‘individual group comparison’ and ‘variable association computation’. In each category, 3 types of variables are included (continuous variables, dichotomous variables and event counts). After the user selects the outcome type (e.g. two-group comparisons), variable type (e.g. dichotomous variable) and measurement type (e.g. RR, relative risk), the corresponding measurement can be calculated, viewed or downloaded in the ‘Outcomes Measures’ tab. The modeling summary and diagnostic plots of Meta-Analysis fitting model can be obtained in the ‘Fitting Model’ tab, after selecting the fitting method (e.g. FE or REML or ML) and moderators adjustment (not required). In the ‘Diagnostic Plots’ tab, separate diagnostic plot (e.g. forest plot, funnel plot, radial plot, normal Q-Q plot, Baujat plot and residual/outlier check) can be viewed or downloaded.The metanalysis app is available at https://jzliu.shinyapps.io/MARS/
GGplot-Shiny: A Shiny App That Facilitates Data Manipulation And Exploration (Samer Mouksassi)
Samer Mouksassi (PhD, Université de Montréal is a Director at Certara in Montreal, Canada
In this presentation, Samer covers development of a simple interface of ggplot where the user can upload their csv file and chose how to plot it. The user can specify the x and y variable and then an automatic slider will update to the data range. User can also flexibly specify which variables are to be treated as categorical and how to categorize continuous variables using number of cut points.non-R users to prepare ggplots. The objectives of developing this Shiny application were two fold: 1) to develop an application that enables non-R users to manipulate their data and
to produce rich graphics using modern R packages ggplot2 and dplyr. and 2) to provide a reference extensible application that demonstrates many of the elements required for future applications in our field.
The application is available at https://pharmacometrics.shinyapps.io/ggplotmydata or
Samer Maintains the most recent code that can be shared and used at https://github.com/isop-phmx/GGplot-Shiny
ISOP and Shiny
ISOP and Rstudio have also worked together to provide a shiny server for ISOP that can be a home for non-proprietary data and applications developed by individuals in the pharmacometrics community. Developers can submit their code to Jinzhong Liu, who will work with them to launch on the ISOP server. More information and basic guidelines for how to do this can be found for at Hosting Pharmacometric Related Applications: The ISOP Shiny Server.
A Pharmacometrics community forum (moderated by the folks here) for discussion of R and issues around using Shiny for pharmacometric applications is available here.
Other Useful Shiny Pharmacometrics Resources
A number of examples from Marc Lavielle using shiny and the [mlxR package] for the simulation and visualization of longitudinal data.
A guide for developing Simulaton Apps
ACoP Tutorial - Jessica Wojciechowski.pdf (1.3 MB)
IbuprofenNeonates.zip (73.2 KB)
shiny_ggplot2_acop2015.pdf (906.4 KB)
ACOP2015shinytutorial1.rmd (1.5 KB)
ACOP2015shinytutorial2.rmd (2.6 KB)
100715 ACoP_v2.pdf (8.2 MB)
ACOP2015SM.zip (48.9 KB)
: http://simulx.webpopix.org/<a class=“attachment”