In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

clDistPlot.R 1.37 KB
Newer Older
dmattek's avatar
Mod:    
dmattek 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
modClDistPlotUI =  function(id, label = "Plot Fractions WIthin Clusters") {
  ns <- NS(id)
  
  tagList(
    actionButton(ns('butPlotClDist'), 'Plot!'),
    plotOutput(ns('outPlotClDist'), height = '800px', width = 'auto'),
    downPlotUI(ns('downPlotClDist'), "Download PDF")
  )
}


modClDistPlot = function(input, output, session, in.data, in.fname = 'clDist.pdf') {
  
  ns <- session$ns
 
  # Barplot with distribution of clusters across conditions
  plotClDist = function() {
    cat(file = stderr(), 'plotClDist: in\n')
    
    loc.dt = in.data()
    if (is.null(loc.dt)) {
      cat(file = stderr(), 'plotClDist: dt is NULL\n')
      return(NULL)
    }
    
    p.out = ggplot(loc.dt, aes(x = group, y = nCells)) +
      geom_bar(aes(fill = as.factor(cl)), stat = 'identity', position = 'fill') +
      scale_y_continuous(labels = percent) +
      ylab("percentage of cells\n") +  
      xlab("") +  
      scale_fill_discrete(name = "Cluster no.") +
      myGgplotTheme
    
    return(p.out)
    
  }
  
  #  Hierarchical - display bar plot
  output$outPlotClDist <- renderPlot({
    locBut = input$butPlotClDist
    
    if (locBut == 0) {
      cat(file = stderr(), 'outPlotClDist: Go button not pressed\n')
      
      return(NULL)
    }
    
    plotClDist()
  })
  
  # Hierarchical - Bar Plot - download pdf
  callModule(downPlot, "downPlotClDist", in.fname, plotClDist, TRUE)
  
}