START App
R Shiny Transcriptome Analysis Resource Tool


Jessica Minnier
email: minnier@ohsu.edu

Wednesday, December 7, 2016

https://github.com/jminnier/STARTapp
Slides available at http://bit.ly/rmeetup-start

Motivation

Spreadsheets =(

RNA-seq gene expression

rows =

  • 10-100k gene identifiers
    (or miRNAs, proteins, transcripts, exons, etc)

columns =

  • gene counts for each sample
  • normalized data
  • data normalized a different way
  • data normalized another way
  • fold changes between groups
  • p-values
  • adjusted p-values (q-values, FDR)

How to transform into heatmap(s)?



doi:10.1038/nature14546

Evolution

  • Started with Tableau
    • Tableau + R + Bioconductor = :-| (in 2013)
  • Realization (in 2013): Shiny can do this
  • Made one site with one data set
  • Created site for input data set

START

Shiny Transcriptome Analysis Resource Tool

with Jonathan Nelson, Jiri Sklenar, Anthony Barnes of
Knight Cardiovascular Institute (KCVI), OHSU



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

shinyapps.io: https://kcvi.shinyapps.io/START

development version: https://kcvi.shinyapps.io/START_devel

Bioinformatics publication: bioinformatics.btw624

Very quick tour

Very quick tour

Features

(first read Terms & Conditions if using shinyapps.io)

  • upload “raw” count data or analyzed data (with p-values, q-values, log fold changes)
  • boxplots, PCA plots, heatmaps
    • search by gene id
    • heatmaps of subsets of genes
    • filters based on significance/fold change
  • interactive plots with plotly and ggplotly()
    • fast rendering (previous versions used ggvis)
  • Bioconductor packages for analysis of data
  • Save data in various formats, save plots
    • save RData for easier upload
  • …still adding new features

Shiny features

Separate code by tabs -
ui.R

navbarPage(
    theme = "bootstrap.min.united.updated.css",
    #United theme from http://bootswatch.com/
    title = "START: Shiny Transcriptome Analysis Resource Tool",
    source("ui-tab-landing.R",local=TRUE)$value,
    ## =========================================================================== ##
    ## DOWNLOAD DATA TABS
    ## =========================================================================== ##
    source("ui-tab-inputdata.R",local=TRUE)$value,
    source("ui-tab-filterdata.R",local=TRUE)$value,
    ## =========================================================================== ##
    ## Visualization TABS
    ## =========================================================================== ##
    source("ui-tab-samplegroupplots.R",local=TRUE)$value,
    source("ui-tab-analysisres.R",local=TRUE)$value,
    source("ui-tab-dotplot.R",local=TRUE)$value,
    source("ui-tab-heatmap.R",local=TRUE)$value,
    source("ui-tab-help.R",local=TRUE)$value,
    source("ui-tab-news.R",local=TRUE)$value,
    source("ui-tab-terms.R",local=TRUE)$value
    #end definitions of tabs, now footer
)

Separate code by tabs -
server.R

shinyServer(function(input, output,session) {
  ## Server functions are divided by tab
  source("server-inputdata.R",local = TRUE)
  source("server-filterdata.R",local = TRUE)
  source("server-dotplot.R",local = TRUE)
  source("server-heatmap.R",local = TRUE)
  source("server-samplegroupplots.R",local=TRUE)
  source("server-analysisres.R",local = TRUE)
  source("server-data.R",local = TRUE)
})

Reactivity - input data

# after the data is uploaded or example data is selected, 
# analyze the data
analyzeDataReactive <- 
  eventReactive(
    input$upload_data,
    ignoreNULL = FALSE, {
      withProgress(message = "Analyzing RNA-seq data, please wait",{
        
        print("analysisCountDataReactive")
        
        ## ==================================================================================== ##
        ## Example data
        ## ==================================================================================== ##
        if(input$data_file_type=="examplecounts") {
          load('data/mousecounts_example_analysis_results.RData')
          load('data/mousecounts_example_analyzed.RData') #example_data_results for data_results_table
          return(list('group_names'=group_names,'sampledata'=sampledata,
                      "results"=results,"data_long"=data_long, "geneids"=geneids,
                      "data_results_table"=example_data_results))
        }
        
        ## ==================================================================================== ##
        ## Upload previously downloaded RData
        ## ==================================================================================== ##
        
        if(input$data_file_type=="previousrdata"){
          inRfile <- input$rdatafile
          load(inRfile$datapath,envir=environment())
          
          return(list('group_names'=group_names,'sampledata'=sampledata,
                      "results"=results,"data_long"=data_long, 
                      "geneids"=geneids,
                      "data_results_table"=data_results_table))
        }
        
        ## ==================================================================================== ##
        ## Else, continue on with uploading csv data
        ## ==================================================================================== ##
        
        alldata <- inputDataReactive()$data
        
        ## ==================================================================================== ##
        ## ANALYSIS CODE HERE
        ## ==================================================================================== ##
        
        
        print('analyze data: done')
        
        return(list('group_names'=group_names,'sampledata'=sampledata,
                    "results"=lmobj_res,"data_long"=data_long, "geneids"=geneids, 
                    "data_results_table"=data_results_table))
      })
    }
)

Reactive filter settings -
server side

#update list of groups
observe({
  print("server-heatmap-update")
  data_analyzed = analyzeDataReactive()
  tmpgroups = data_analyzed$group_names
  tmpdat = data_analyzed$results
  tmptests = unique(as.character(tmpdat$test))
  tmpdatlong = data_analyzed$data_long
  tmpynames = tmpdatlong%>%select(-unique_id,-sampleid,-group)%>%colnames()
  if("count"%in%tmpynames) tmpynames = tmpynames[-match("count",tmpynames)]
  
  updateRadioButtons(session,'heatmapvaluename', choices=sort(tmpynames,decreasing = TRUE))
  updateCheckboxGroupInput(session,'view_group_heatmap',
                           choices=tmpgroups, selected=tmpgroups)
  updateSelectizeInput(session,'sel_test_heatmap',
                       choices=tmptests, selected=NULL)
  updateSelectizeInput(session,"fold_change_groups",
                       choices=tmpgroups)
  
})

Much more code

github

Extensions to come

  • Proteomics
  • Methylation
  • Integration of different types of omics data
  • …? Open to ideas, and to code!

Thank you!

Slides available at http://bit.ly/rmeetup-start

Code for slides available at https://github.com/jminnier/rmeetup-shiny-START