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.78 KB
Newer Older
dmattek's avatar
Mod:    
dmattek committed
1
2
3
4
5
6
7
8
9
10
11
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")
  )
}


dmattek's avatar
Mod:    
dmattek committed
12
13
14
15
16
17
18

# Params:
# in.data - data prepared with data4clDistPlot f-n
# in.cols - table with 1st column as cluster number, 2nd column colour assignments
#           prepared with getClColHier
# in.fname - file name for plot download
modClDistPlot = function(input, output, session, in.data, in.cols = NULL, in.fname = 'clDist.pdf') {
dmattek's avatar
Mod:    
dmattek committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  
  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)) +
dmattek's avatar
Mod:    
dmattek committed
33
34
35
36
37
38
39
40
41
42
      geom_bar(aes(fill = as.factor(cl)), stat = 'identity', position = 'fill')
    
    if(is.null(in.cols))
      p.out = p.out + scale_fill_discrete(name = "Cluster no.")
    else
      p.out = p.out + scale_fill_manual(name = "Cluster no.", 
                                        values = in.cols()$cl.col)
    
    
    p.out = p.out + 
dmattek's avatar
Mod:    
dmattek committed
43
44
45
46
47
48
49
50
51
      scale_y_continuous(labels = percent) +
      ylab("percentage of cells\n") +  
      xlab("") +  
      myGgplotTheme
    
    return(p.out)
    
  }
  
dmattek's avatar
Mod:    
dmattek committed
52
  #  display bar plot
dmattek's avatar
Mod:    
dmattek committed
53
54
55
56
57
58
59
60
61
62
63
64
  output$outPlotClDist <- renderPlot({
    locBut = input$butPlotClDist
    
    if (locBut == 0) {
      cat(file = stderr(), 'outPlotClDist: Go button not pressed\n')
      
      return(NULL)
    }
    
    plotClDist()
  })
  
dmattek's avatar
Mod:    
dmattek committed
65
  # bar Plot - download pdf
dmattek's avatar
Mod:    
dmattek committed
66
67
68
  callModule(downPlot, "downPlotClDist", in.fname, plotClDist, TRUE)
  
}