server.R 1.13 KB
Newer Older
David Trudgian's avatar
David Trudgian committed
1
2
3
4
5
# This example implements a simple file browser for accessing results.

library(shiny)
library(shinyFiles)

6
7
8
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)

David Trudgian's avatar
David Trudgian committed
9
10
11
12
13
14
15
16
17
18
19
20
# Results are available in the directory specified by the outputDir environment
# variable, red by Sys.getenv

rootdir <- Sys.getenv('outputDir')

shinyServer(function(input, output, session) {

    # The backend for a simple file chooser, restricted to the
    # rootdir we obtained above.
    # See https://github.com/thomasp85/shinyFiles


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  observe({
      print(getwd());
      files <- list.files(path = rootdir, pattern = ".bed")
      cat("\nBed files found:\n\n")
     
      filenames <- as.list(paste0(rootdir, files));
      names(filenames) <- files;
      print(filenames)
      
      txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
      
      
      peakAnnoList <- lapply(filenames, annotatePeak, TxDb=txdb,
                             tssRegion=c(-3000, 3000), verbose=FALSE)
      
      output$plot1 <- renderPlot({
        
        plotAnnoBar(peakAnnoList)
      })
      output$plot2 <- renderPlot({
        
        plotDistToTSS(peakAnnoList)
      })
  })
David Trudgian's avatar
David Trudgian committed
45
})