Building Shiny Apps
Challenges and Responsibilities


Jessica Minnier
email: minnier@ohsu.edu
@datapointier

Saturday, January 27, 2018, Data/R Day Texas

Slides available at http://bit.ly/shiny-ddtx

Why Shiny?

Motivation

Spreadsheets =(

Motivation

“Can you make me this plot? Ok now this plot? Wait one more plot…”

Plot Monkey?

Enter Shiny

My history

  • Started with Tableau
  • Realization: Shiny can do this!
  • Made one site with one data set
  • Created general site for input data set

Motivation For All

Distribute your hard work!

Collaborator:
“How can I share my data?”

https://kcvi.shinyapps.io/START_HT/

Developer/Statistician/Data Scientist:
“How can I get people to use my new method/package?”

http://qvalue.princeton.edu/

Developer/Statistician/Data Scientist:
Look at this analysis I did!

https://gallery.shinyapps.io/TSupplyDemand/

Everyone: Teach Some things! (learnr)

https://minnier.shinyapps.io/ODSI_continuousData/

Shiny basics

# what you see, client side
ui <- fluidPage(
  
  
  
)
# computations here!
server <- function(input, output) {
  
  
  
  
}
# run the app!
shinyApp(ui = ui, server = server)

Shiny basics

# what you see, client side
ui <- fluidPage(
  # Title, panels
  plotOutput("myplot"), #from output$myplot
  selectInput("foo",choices=allthechoices)
)
# computations here!
server <- function(input, output) {
  
  
  
  
}
# run the app!
shinyApp(ui = ui, server = server)

Shiny basics

# what you see, client side
ui <- fluidPage(
  # Title, panels
  plotOutput("myplot"), #from output$myplot
  selectInput("foo",choices=allthechoices)
)
# computations here!
server <- function(input, output) {
  # reactive plots
  output$myplot <- renderPlot({ ggplot(yay) + geom_point() })
  # use input$foo here, maybe observe changes in UI
  observe({ dostuff(input$foo) })
}
# run the app!
shinyApp(ui = ui, server = server)

An example: START

Shiny Transcriptome Analysis Resource Tool

Github: https://github.com/jminnier/STARTapp

DATA = RNA-seq gene expression

Very quick tour

Very quick tour

Who is your audience?

Example: START app

  • likely biologists
  • some not used to coding or large data sets

Challenges: User

Data is larger than they are used to + Cannot query or share results easily

Interactive search boxes/filtering + Reactive visualization

Challenges, Input/Ouput Data

  • Input data ~ multiple formats: Special input formats
  • Interface with other software? Export special formats

Challenges, Input/Ouput Data

  • Input data ~ multiple formats: Special input formats

https://biit.cs.ut.ee/clustvis/

Challenges, Input/Ouput Data

  • Input data ~ multiple formats: Special input formats

https://biit.cs.ut.ee/clustvis/

Challenges, Analysis

Many possible ways to analyze data:

  • Restrict analyses performed
  • Allow for uploading of analysis results

Challenges, Analysis

QA/QC

Present QA plots up front

Challenges, Analysis

QA/QC

Present QA plots up front

https://github.com/joey711/shiny-phyloseq

Responsibilities, Food for thought:


  • Is resulting analysis correct?
  • Are we encouraging “data fishing”?
  • Misuse of p-values?
  • Solutions? Use instructions and data inputs wisely.
  • Other solutions? Avoid H0s, Bayesian posterior probabilities?

Landing page - Where am I?

  • Show what the app is for/can do
  • Point to instructions and guidelines

Bonus: Jasmine Dumas has a shinyLP package to help!

Instructions, Please

  • So hard.
  • Not just a vignette of a package (users may not be coders)
  • Written instructions vs. video demos
  • Gif instructions

No one will use it if they don’t know how to use it!

Instructions

Tauno Metsalu and Jaak Vilo: “Clustvis”

Instructions

Tauno Metsalu and Jaak Vilo: “Clustvis”

But Does It work?

Debugging Tips

Debugging is notoriously a pain here

Thanks, stack trace:

Did you update a package?

Good luck with that.

Old fashioned methods work best

Breakpoints and tracing:

  • browser() - I didn’t say it was fun
  • print() - every single function/observe statement gets a print

New methods are also nice

runApp(..., display.mode="showcase")

But, doesn’t show why something broke.

Random final tips:

  • Test it first
    • Unit testing can save you so much headache
    • Run tests on example data
    • Create .Md file of test plots
  • Security
    • Are users uploading sensitive data?
    • Security review of public apps vs commercial version
  • Speed: Why so slow?
    • Rprofiler in Rstudio
    • Reduce start up time

Be Creative!

papr by Lucy D’Agostino McGowan, Nick Strayer, Jeff Leek

Have fun!

homebrewR by David Stephens

Thank you! Go forth and shiny!


Contact: @ datapointier

Github: https://github.com/jminnier/STARTapp

Slides available at http://bit.ly/shiny-ddtx

Code for slides available at https://github.com/jminnier/presentation_austin_dataday2018