## ----style, echo = FALSE, results = 'asis'-------------------------------------------------------- BiocStyle::markdown() options(width=100, max.print=1000) knitr::opts_chunk$set( eval=as.logical(Sys.getenv("KNITR_EVAL", "TRUE")), cache=as.logical(Sys.getenv("KNITR_CACHE", "TRUE"))) ## ----setup, echo=FALSE, messages=FALSE, warnings=FALSE-------------------------------------------- suppressPackageStartupMessages({ library(shiny) library(RNAseqData.HNRNPC.bam.chr14) library(Homo.sapiens) library(Gviz) }) ## ----shiny-ui, eval=FALSE------------------------------------------------------------------------- # library(shiny) # library(RNAseqData.HNRNPC.bam.chr14) # library(Homo.sapiens) # # ## Get all SYMBOLs on chr14 # symbols <- keys(Homo.sapiens, keytype="SYMBOL") # map <- select(Homo.sapiens, symbols, "TXCHROM", "SYMBOL") # symchoices <- sort(unique(map$SYMBOL[map$TXCHROM %in% "chr14"])) # # ## Possible BAM files # bamchoices <- basename(RNAseqData.HNRNPC.bam.chr14_BAMFILES) # # ## Define the user interface # shinyUI(fluidPage( # # ## Application title # titlePanel("BAMSpector: Reads Supporting Gene Models"), # # sidebarLayout( # sidebarPanel( # ## input gene symbol (fancy: select from available) # selectInput("symbol", "Gene Symbol", symchoices), # # ## input path to BAM file # selectInput("bam", "BAM File", bamchoices, multiple=TRUE)), # # ## Show a plot of the generated distribution # mainPanel(plotOutput("tracksPlot"))) # )) ## ----shiny-server, eval=FALSE--------------------------------------------------------------------- # ## load required libraries # library(shiny) # library(RNAseqData.HNRNPC.bam.chr14) # library(Homo.sapiens) # library(Gviz) # # ## where are the BAM files? # dirname <- unique(dirname(RNAseqData.HNRNPC.bam.chr14_BAMFILES)) # # ## What are the ranges of each gene? # ranges <- genes(Homo.sapiens, columns="SYMBOL") # ranges$SYMBOL <- unlist(ranges$SYMBOL) # # ## Create a representation of each gene region # genes <- GeneRegionTrack(TxDb.Hsapiens.UCSC.hg19.knownGene, # chromosome="chr14") # # shinyServer(function(input, output) { # # output$tracksPlot <- renderPlot({ # if (length(input$bam) > 0) { # ## coverage on each BAM file # bam <- file.path(dirname, input$bam) # coverage <- Map(DataTrack, # range = bam, name = bam, # MoreArgs=list(type = 'histogram', # window = -1, genome = 'hg19', # chromosome = 'chr14')) # } else { # coverage <- list() # } # # ## Select the correct range # range <- ranges[match(input$symbol, ranges$SYMBOL)] # # ## plot the GeneRegionTrack and coverage # plotTracks(c(list(genes), coverage), # from = start(range), to=end(range), # chr='chr14', windowSize = 30) # }) # }) ## ----shiny-launch, eval=FALSE--------------------------------------------------------------------- # shiny::runApp()