Vennrender.R 1.52 KB
Newer Older
fsoubes's avatar
fsoubes committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
### Author: Franck Soubès
### Bioinformatics Master Degree - University of Bordeaux, France
### Link: https://github.com/fsoubes/MA_Trix_App
### Where: GET-TRiX's facility
### Application: MATRiX is a shiny application for Microarray Analysis on Transcriptomic impact of Xenobiotics
### Licence: GPL-3.0


#########################################
######## Venn part                      #
#########################################


output$myVenn <- renderPlot({
  validate(
    need(csvf(), 'You need to import data to visualize this plot!') %next%
      need(
        length(user_cont()) > 0,
        'You need to  select your p-value and then some groups!'
      )
  )
  
  req(Vennplot())
  
  Vennplot()
  
},  height = plotHeight)

observe({
  validate(need(csvf(), 'You need to import data to visualize this plot!'))
  
  output$savevenn <- downloadHandler(filename <- function() {
    paste0(basename(tools::file_path_sans_ext(projectname())),
           '_venn_diagram.',
           input$formven,
           sep = '')
  },
  content <- function(file) {
    if (input$formven == "pdf")
      
      pdf(file,
          width = 12.5,
          height = 12,
          pointsize = 12)
    
    else if (input$formven == "png")
      png(
        file,
        width = 1250,
        height = 1200,
        units = "px",
        pointsize = 12,
        res = 100
      )
    else
      cairo_ps(
        filename = file,
        width = 11,
        height = 11,
        pointsize = 12
      )
    
    
    grid.draw(Vennplot())
    dev.off()
  })
  
})