+ - 0:00:00
Notes for current slide
Notes for next slide

Building Shiny Apps: With Great Power Comes Great Responsibility

CSP 2018

Jessica Minnier, PhD
Oregon Health & Science University
Twitter: @datapointier
Slides available at http://bit.ly/shiny-csp18

February 16, 2018

1 / 53

This talk:

1. Motivation & Uses

2. Considerations & Challenges

3. Responsibilities

4. Tips on Development

2 / 53

Why Shiny?

3 / 53

Motivation

Too many spreadsheets!

4 / 53

Motivation

"Can you make me this plot? Ok now this plot? Wait one more plot..."

5 / 53

Motivation

Too many plots!

6 / 53

Enter, Shiny!

7 / 53

My motivation

(First step) Help collaborator: app to display one data set

  • Explore, visualize, share data
  • Generate hypotheses

(Now) Help everyone: general app for uploading/analyzing data sets

  • Implement existing R tools to analyze data
  • Explore, visualize, share data
  • Generate hypotheses
8 / 53

Motivation For All:

Distribute your hard work!

9 / 53

Collaborator: "How can I share my data?"

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

10 / 53

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

http://qvalue.princeton.edu/

11 / 53

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

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

12 / 53

Everyone: Teach! (learnr)

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

13 / 53

Shiny basics

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

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)
15 / 53

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)
16 / 53

An example: START

Shiny Transcriptome Analysis Resource Tool
Github: [https://github.com/jminnier/STARTapp](https://github.com/jminnier/STARTapp)
DATA = RNA-seq gene expression

17 / 53

Very quick tour

18 / 53

Very quick tour

19 / 53

Data distributions, interactive

start_boxplot

20 / 53

Analysis results, interactive

start_volcano

21 / 53

Data exploration, interactive

start_scatter

22 / 53

Considerations

23 / 53

Who is your audience?

Example: START app

  • likely biologists
  • may not be used to coding or large data sets

24 / 53

Challenges: User

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

Interactive search boxes/filtering + Reactive visualization

25 / 53

Challenges, Input/Ouput Data

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

26 / 53

Challenges, Input/Ouput Data

  • Input data ~ multiple formats: Special input formats

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

27 / 53

Challenges, Input/Ouput Data

  • Input data ~ multiple formats: Special input formats

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

28 / 53

Challenges, Analysis

Many possible ways to analyze data:

  • RNA-seq data has many analysis pipelines (edgeR, DESeq2, limma)
  • Complex study designs
    • repeated measures
    • multiple pairwise comparisons vs overall group comparisons
  • How to allow for so many possibilities?
29 / 53

Challenges, Analysis

Many possible ways to analyze data:

  • RNA-seq data has many analysis pipelines (edgeR, DESeq2, limma)
  • Complex study designs
    • repeated measures
    • multiple pairwise comparisons vs overall group comparisons
  • How to allow for so many possibilities?

Balance flexibility/simplicity/CORRECTness

  • Too many options high likelihood of incorrect use of analysis tools
29 / 53

Challenges, Analysis

Many possible ways to analyze data:

  • Restrict analyses performed
  • Allow for uploading of analysis results

30 / 53

Challenges, Analysis

Look at the data! (QA/QC)

31 / 53

Challenges, Analysis: QA/QC

Present QA plots up front

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

32 / 53

Challenges, Analysis: QA/QC

Does this data look "weird"?

33 / 53

Responsibilities

How do we avoid "data fishing"?

(Food for thought)

34 / 53

Responsibilities

- Are resulting analyses correct?

- Are we encouraging "torturing the data until it speaks"?

- Misuse of p-values?

35 / 53

Responsibilities: Visual inference

Plots = statistics

-- Di Cook's keynote at rstudio::conf 2018

Solution?: Rorschach image tests

Generate null data sets and null plots using permutation and simulation

Can you pick out your data from a line up?

R package nullabor

36 / 53

Visual inference: Apophenia

http://visiphilia.org/2014/11/03/nullabor

37 / 53

Too many heatmaps?

38 / 53

Room for misuse, possible solutions:

Documentation

- Use instructions and data inputs wisely.

- Provide examples of when advanced analyses are needed.

- Provide examples of statistical write ups based on app's results.

Analysis

- Avoid too many hypothesis tests.

- Avoid p-values (Bayesian posterior probabilities?).

- With collaborators: stay involved!

39 / 53

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!

40 / 53

Instructions, Please

  • Extremely difficult.
  • 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!

41 / 53

Instructions

Tauno Metsalu and Jaak Vilo: "Clustvis"

42 / 53

Instructions

Tauno Metsalu and Jaak Vilo: "Clustvis"

43 / 53

But Does It work?

44 / 53

Debugging Tips

Debugging is notoriously a pain here

45 / 53

Thanks, stack trace:

46 / 53

Did you update a package?

47 / 53

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

48 / 53

New methods are useful

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

But, doesn't show why something broke.

49 / 53

Final Tips

Put on your Software Development Hat!

  • Test it first
    • Unit testing can save you so much headache (packages: testthat, shinytest)
    • 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
    • Newer tools: future and promises packages for async programming
50 / 53

Have fun!

homebrewR by David Stephens

52 / 53

Thank you! Go forth and shiny!


Contact: @ datapointier, email: minnier-[at]-ohsu.edu

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

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

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

Slides created via the R package xaringan by Yihui Xie with the Rladies theme by Alison Hill.

53 / 53

This talk:

1. Motivation & Uses

2. Considerations & Challenges

3. Responsibilities

4. Tips on Development

2 / 53
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow