server.R 48.8 KB
Newer Older
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
1
if (!require("Rcpp")){
2
3
  install.packages("Rcpp")
}
Stevenn Volant's avatar
Stevenn Volant committed
4

5
6
7
8
if(!require(shinydashboard)){
  install.packages('shinydashboard')
  library(shinydashboard)
}
Stevenn Volant's avatar
Stevenn Volant committed
9

10
11
12
if(!require(rjson)){
  install.packages('rjson')
}
Stevenn Volant's avatar
Stevenn Volant committed
13

14
15
if(!require(devtools)){
  install.packages('devtools')
stevenn's avatar
stevenn committed
16
}
17
18

#library(plotly)
Stevenn Volant's avatar
Stevenn Volant committed
19

stevenn's avatar
stevenn committed
20
21
22
23
if (!require(psych)) {
  install.packages('psych')
  library(psych)
}
Stevenn Volant's avatar
Stevenn Volant committed
24

stevenn's avatar
stevenn committed
25
26
27
28
if (!require(ggplot2)) {
  install.packages('ggplot2')
  library(ggplot2)
}
Stevenn Volant's avatar
Stevenn Volant committed
29

stevenn's avatar
stevenn committed
30
31
32
33
if (!require(vegan)) {
  install.packages('vegan')
  library(vegan)
}
Stevenn Volant's avatar
Stevenn Volant committed
34

stevenn's avatar
stevenn committed
35
36
37
38
if (!require(dendextend)) {
  install.packages('dendextend')
  library(dendextend)
}
Stevenn Volant's avatar
Stevenn Volant committed
39

stevenn's avatar
stevenn committed
40
41
42
43
if (!require(circlize)) {
  install.packages('circlize')
  library(circlize)
}
Stevenn Volant's avatar
Stevenn Volant committed
44

Amine  GHOZLANE's avatar
Amine GHOZLANE committed
45
46
47
48
if (!require(d3heatmap)) {
  install.packages('d3heatmap')
  library(d3heatmap)
}
Stevenn Volant's avatar
Stevenn Volant committed
49

stevenn's avatar
stevenn committed
50
51
52
53
if (!require(biom)) {
  install.packages('biom')
  library(biom)
}
Stevenn Volant's avatar
Stevenn Volant committed
54

55
56
if (!require(devtools)) {
  install.packages('devtools')
svolant's avatar
svolant committed
57
58
59
60
61
62
  library(devtools)
}

if (!require(scatterD3)) {
  install.packages('scatterD3')
  library(scatterD3)
63
}
Stevenn Volant's avatar
Stevenn Volant committed
64

65
66
67
if (!require(rNVD3)) {
  library(devtools)
  install_github('rNVD3', 'ramnathv')
68
  library(rNVD3)
69
}
Stevenn Volant's avatar
Stevenn Volant committed
70

Stevenn Volant's avatar
Stevenn Volant committed
71
if (!require(genefilter)) {
72
73
  source("https://bioconductor.org/biocLite.R")
  biocLite("genefilter")
Stevenn Volant's avatar
Stevenn Volant committed
74
75
  library(genefilter)
}
svolant's avatar
svolant committed
76
77
78
79
80
81

if (!require(googleVis)) {
  install.packages('googleVis')
  library(googleVis)
}

svolant's avatar
svolant committed
82
library(shinyjs)
svolant's avatar
svolant committed
83

84
85
# Allow to upload 50M files
options(shiny.maxRequestSize=50*1024^2) 
stevenn's avatar
stevenn committed
86
87
88
89
90
source("internal.R")

renderDataTable <- DT::renderDataTable
dataTableOutput <- DT::dataTableOutput

stevenn's avatar
stevenn committed
91
shinyServer(function(input, output,session) {
stevenn's avatar
stevenn committed
92
93
94
95
  
  
#####################################################
##
stevenn's avatar
stevenn committed
96
##                    LOAD FILES
stevenn's avatar
stevenn committed
97
98
##
#####################################################
stevenn's avatar
stevenn committed
99
  
stevenn's avatar
stevenn committed
100
101
  ## Create base for contrast
  rand = floor(runif(1,0,1e9))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
102
  namesfile = tempfile(pattern = "BaseContrast", tmpdir = tempdir(), fileext = "")
stevenn's avatar
stevenn committed
103
  file.create(namesfile,showWarnings=FALSE)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
104

svolant's avatar
svolant committed
105
  ## Popup messages
svolant's avatar
svolant committed
106
  observe(if(input$AddRegScatter) info("By adding the regression line, you will lose interactivity."))
stevenn's avatar
stevenn committed
107

stevenn's avatar
stevenn committed
108
  ## Counts file
stevenn's avatar
stevenn committed
109
110
111
112
113
  dataInputCounts <-reactive({ 
    
    inFile <- input$fileCounts
  
    if (is.null(inFile)) return(NULL)
Stevenn Volant's avatar
Stevenn Volant committed
114

stevenn's avatar
stevenn committed
115
    data = read.csv(inFile$datapath,sep="\t",header=TRUE)
stevenn's avatar
stevenn committed
116
117

    ## Rownames
Stevenn Volant's avatar
Stevenn Volant committed
118
119
    if(!TRUE%in%duplicated(data[,1])) rownames(data)=data[,1];data=data[,-1]

stevenn's avatar
stevenn committed
120
121
122
123
124
    return(as.data.frame(data))
  })
  


stevenn's avatar
stevenn committed
125
126
  ## Taxo File
  dataInputTaxo <-reactive({ 
stevenn's avatar
stevenn committed
127
    
stevenn's avatar
stevenn committed
128
    inFile <- input$fileTaxo
stevenn's avatar
stevenn committed
129
    
stevenn's avatar
stevenn committed
130
    if (is.null(inFile)) return(NULL)
stevenn's avatar
stevenn committed
131
    
Stevenn Volant's avatar
Stevenn Volant committed
132
133
134
    if(input$TypeTaxo=="Table") 
    {
      data = read.csv(inFile$datapath,sep="\t",header=TRUE)
svolant's avatar
svolant committed
135
      
Stevenn Volant's avatar
Stevenn Volant committed
136
      ## Rownames
svolant's avatar
svolant committed
137
138
139
140
141
142
143
      if(!TRUE%in%duplicated(data[,1])){ 
        DataNames=data[,1]
        colNames=colnames(data)[-1]
        data=as.matrix(data[,-1])
        rownames(data)=DataNames
        colnames(data) = colNames
        }
Stevenn Volant's avatar
Stevenn Volant committed
144
    }
stevenn's avatar
stevenn committed
145
    
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
146
147
    if(input$TypeTaxo=="RDP") 
    {
Stevenn Volant's avatar
Stevenn Volant committed
148
      data = read_rdp(inFile$datapath,input$RDP_th)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
149
    }
stevenn's avatar
stevenn committed
150
151
152
    
    ## Add NA
    data=as.matrix(data)
Stevenn Volant's avatar
Stevenn Volant committed
153
    indNa = which(data=="")
stevenn's avatar
stevenn committed
154
155
    data[indNa]=NA
    
stevenn's avatar
stevenn committed
156
    return(as.data.frame(data))
stevenn's avatar
stevenn committed
157
158
159
  })


stevenn's avatar
stevenn committed
160
161
  ## BIOM File
  dataInputBiom <-reactive({ 
stevenn's avatar
stevenn committed
162
    
stevenn's avatar
stevenn committed
163
    inFile <- input$fileBiom
stevenn's avatar
stevenn committed
164
    
stevenn's avatar
stevenn committed
165
    if (is.null(inFile)) return(NULL)
stevenn's avatar
stevenn committed
166
    data = read_biom(inFile$datapath)
stevenn's avatar
stevenn committed
167
    
stevenn's avatar
stevenn committed
168
    return(data)
stevenn's avatar
stevenn committed
169
170
171
  })


stevenn's avatar
stevenn committed
172
173
174

  ## Input data
  dataInput <-reactive({ 
stevenn's avatar
stevenn committed
175
    
stevenn's avatar
stevenn committed
176
    data = NULL
Stevenn Volant's avatar
Stevenn Volant committed
177
178
    check = NULL
    percent = NULL
stevenn's avatar
stevenn committed
179
    
stevenn's avatar
stevenn committed
180
    if(input$FileFormat=="fileCounts")
stevenn's avatar
stevenn committed
181
    {
stevenn's avatar
stevenn committed
182
183
      Counts = dataInputCounts()
      Taxo = dataInputTaxo()
Stevenn Volant's avatar
Stevenn Volant committed
184
185
186
187
188
189
190
      if(!is.null(Counts) && !is.null(Taxo))
      { 
        tmp = GetDataFromCT(Counts,Taxo)
        data = list(counts=tmp$counts,taxo=tmp$taxo)
        check = list(CheckCounts=tmp$CheckCounts,CheckTaxo=tmp$CheckTaxo,CheckPercent=tmp$CheckPercent)
        percent = tmp$Percent
      }    
stevenn's avatar
stevenn committed
191
192
    }
    
stevenn's avatar
stevenn committed
193
    if(input$FileFormat=="fileBiom")
stevenn's avatar
stevenn committed
194
    {
stevenn's avatar
stevenn committed
195
      tmpBIOM = dataInputBiom()
Stevenn Volant's avatar
Stevenn Volant committed
196
197
198
199
200
201
202
      if(!is.null(tmpBIOM))
      {
        tmp = GetDataFromBIOM(tmpBIOM)
        data = list(counts=tmp$counts,taxo=tmp$taxo)
        check = list(CheckCounts=tmp$CheckCounts,CheckTaxo=tmp$CheckTaxo,CheckPercent=tmp$CheckPercent)
        percent = tmp$Percent
      }
stevenn's avatar
stevenn committed
203
204
    }
    
Stevenn Volant's avatar
Stevenn Volant committed
205
    return(list(data=data,check=check,percent=percent))
stevenn's avatar
stevenn committed
206
207
208
  })
  
  
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
209
210
211

  ## Merge counts data
  dataMergeCounts <-reactive({ 
Stevenn Volant's avatar
Stevenn Volant committed
212
    input$RunDESeq
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
213
214
215
    
    counts = NULL
    CheckTarget = FALSE
216
    normFactors = NULL
Stevenn Volant's avatar
Stevenn Volant committed
217
    CT_noNorm = NULL
218
    #labeled= NULL
Stevenn Volant's avatar
Stevenn Volant committed
219
    data = dataInput()$data
220
    target = isolate(dataInputTarget()$target)
221
    taxo = isolate(input$TaxoSelect)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
222
223
224
225
    
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && !is.null(taxo) && taxo!="..." && !is.null(target)) 
    {
      design = GetDesign(input)
226
      tmp = isolate(GetCountsMerge(input,data,taxo,target,design))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
227
228
      counts = tmp$counts
      CheckTarget = tmp$CheckTarget
229
230
      #target = tmp$target
      #labeled = tmp$labeled
231
      normFactors = tmp$normFactors
Stevenn Volant's avatar
Stevenn Volant committed
232
      CT_noNorm = tmp$CT_noNorm
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
233
    }
Stevenn Volant's avatar
Stevenn Volant committed
234
    return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors,CT_noNorm=CT_noNorm))
235
    #return(list(counts=counts,target=target,labeled=labeled,normFactors=normFactors,CT_noNorm=CT_noNorm))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
236
237
238
  })


Stevenn Volant's avatar
Stevenn Volant committed
239
240
241
242
243
244
245
  # Infobox Error counts
  output$InfoErrorCounts <- renderInfoBox({
    
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
    cond = (!is.null(data$counts) && nrow(data$counts)>0)
246
    res =infoBox(h6(strong("Count table")), subtitle = h6("Load the count table") ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("upload"))
Stevenn Volant's avatar
Stevenn Volant committed
247
248
249
    
    if(cond)
    {
250
251
252
      if(!is.null(check$CheckCounts$Warning)) res = infoBox(h6(strong("Count table")), subtitle = h6(check$CheckCounts$Warning), icon = icon("warning"),color = "orange",width=NULL,fill=TRUE)
      if(!is.null(check$CheckCounts$Error)) res = infoBox(h6(strong("Count table")), subtitle = h6(check$CheckCounts$Error), icon = icon("thumbs-o-down"),color = "red",width=NULL,fill=TRUE)
      if(is.null(check$CheckCounts$Error) && is.null(check$CheckCounts$Warning)) res = infoBox(h6(strong("Count table")), subtitle = h6(paste("Format of the count table seems to be OK")), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
Stevenn Volant's avatar
Stevenn Volant committed
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    }
    
    return(res)
  })

  # Infobox Error counts
  output$InfoErrorTaxo <- renderInfoBox({
    
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
    cond = (!is.null(data$taxo) && nrow(data$taxo)>0)
    res =infoBox(h6(strong("Taxonomy table")), subtitle = h6("Load the taxonomy table") ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("upload"))
    
    if(cond)
    {
      if(!is.null(check$CheckTaxo$Warning)) res = infoBox(h6(strong("Taxonomy table")), subtitle = h6(check$CheckTaxo$Warning), icon = icon("warning"),color = "orange",width=NULL,fill=TRUE)
      if(!is.null(check$CheckTaxo$Error)) res = infoBox(h6(strong("Taxonomy table")), subtitle = h6(check$CheckTaxo$Error), icon = icon("thumbs-o-down"),color = "red",width=NULL,fill=TRUE)
      if(is.null(check$CheckTaxo$Error) && is.null(check$CheckTaxo$Warning)) res = infoBox(h6(strong("Taxonomy table")), subtitle = h6(paste("Format of the taxonomy table seems to be OK")), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
    }
    
    return(res)
  })


  # Infobox Error counts
  output$valueErrorPercent <- renderInfoBox({
    
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
    cond = (!is.null(data$counts) && nrow(data$counts)>0 && !is.null(data$taxo) && nrow(data$taxo)>0)
    res = valueBox(paste0(0, "%"),h6(strong("Annotated features")), color = "light-blue",width=NULL,icon = icon("list"))
    
    if(cond)
    {
      percent = round(100*tmp$percent,2)
      if(percent==0) res = valueBox(paste0(percent, "%"),h6(strong("Annotated features")), color = "red",width=NULL,icon = icon("list"))  
      if(percent!=0) res = valueBox(paste0(percent, "%"),h6(strong("Annotated features")), color = "green",width=NULL,icon = icon("list"))  
      
    }
    
    return(res)
  })


stevenn's avatar
stevenn committed
299
  
stevenn's avatar
stevenn committed
300
301
302
303
304
#####################################################
##
##                DYNAMIC MENU
##
#####################################################
stevenn's avatar
stevenn committed
305
306
307
308
309
  
  
  
  output$dymMenu <- renderMenu({
    
Stevenn Volant's avatar
Stevenn Volant committed
310
311
312
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
stevenn's avatar
stevenn committed
313
    
Stevenn Volant's avatar
Stevenn Volant committed
314
315
316
317
    ## Check error in the counts and taxonomy table 
    CheckOK = (is.null(check$CheckCounts$Error) && is.null(check$CheckTaxo$Error)  && is.null(check$CheckPercent))

    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && CheckOK)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
318
    {
stevenn's avatar
stevenn committed
319
      sidebarMenu(
stevenn's avatar
stevenn committed
320
321
        menuItem("Statistical analysis",
                 menuSubItem("Run differential analysis",tabName="RunDiff"),
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
322
                 menuSubItem("Diagnostic plots",tabName="DiagPlotTab"),
stevenn's avatar
stevenn committed
323
                 menuSubItem("Tables",tabName="TableDiff"),
324
325
326
                 icon = icon("bar-chart-o"), tabName = "AnaStat"
        ),
        menuItem("Visualization",icon = icon("area-chart"), tabName = "Visu"),
Stevenn Volant's avatar
Stevenn Volant committed
327
        menuItem("Perspective plots", icon = icon("pie-chart"), tabName = "Krona")
stevenn's avatar
stevenn committed
328

stevenn's avatar
stevenn committed
329
      )
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
330
     }
Stevenn Volant's avatar
Stevenn Volant committed
331
    else{
332
      sidebarMenu()
Stevenn Volant's avatar
Stevenn Volant committed
333
334
    }
    
stevenn's avatar
stevenn committed
335
336
337
338
339
340
341
342
343
344
345
346
  })
  
  

  #####################################################
  ##
  ##                DATA TABLE
  ##
  #####################################################
  
  ## Counts Table
  output$DataCounts <- renderDataTable(
Stevenn Volant's avatar
Stevenn Volant committed
347
    dataInput()$data$counts, 
stevenn's avatar
stevenn committed
348
349
350
351
352
353
    options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
                   pageLength = 10,scrollX=TRUE
    ))
  
  ## Taxonomy table
  output$DataTaxo <- renderDataTable(
Stevenn Volant's avatar
Stevenn Volant committed
354
    dataInput()$data$taxo, 
stevenn's avatar
stevenn committed
355
356
357
358
359
    options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
                   pageLength = 10,scrollX=TRUE
    ))

  
stevenn's avatar
stevenn committed
360
  ## Tab box for data visualisation
stevenn's avatar
stevenn committed
361
362
  output$TabBoxData <- renderUI({
    
Stevenn Volant's avatar
Stevenn Volant committed
363
    data=dataInput()$data
stevenn's avatar
stevenn committed
364
365
366
    
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
    {
367
368
      tabBox(width = NULL, selected = "Count table",
             tabPanel("Count table",dataTableOutput("DataCounts")),
svolant's avatar
svolant committed
369
370
371
             tabPanel("Taxonomy",dataTableOutput("DataTaxo")),
             tabPanel("Summary",h5(strong("Percentage of annotation")),htmlOutput("SummaryView"),
                      br(),h5(strong("Number of features by level:")),plotOutput("SummaryViewBarplot",width = 1200,height=500))
stevenn's avatar
stevenn committed
372
      )
stevenn's avatar
stevenn committed
373
    }
stevenn's avatar
stevenn committed
374
    
stevenn's avatar
stevenn committed
375
  })
stevenn's avatar
stevenn committed
376

svolant's avatar
svolant committed
377
378
379
380
381
382
383
  output$SummaryView <- renderGvis({
    data = dataInput()$data
    taxo = data$taxo
    counts = data$counts
    res = NULL
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
    {
svolant's avatar
svolant committed
384
      taxo = rbind(taxo,rep(NA,ncol(taxo)))
svolant's avatar
svolant committed
385
      tmpPercent = round(apply(is.na(taxo),2,table)["FALSE",]/nrow(counts)*100,2)
svolant's avatar
svolant committed
386

387
      #print(tmpPercent)
svolant's avatar
svolant committed
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
      df <- data.frame(Label = colnames(taxo),Value = tmpPercent)
    
      res = gvisGauge(df,options=list(min=0, max=100, greenFrom=80,
                                    greenTo=100, yellowFrom=60, yellowTo=80,
                                    redFrom=0, redTo=60, width=1200, height=300))
    }
    return(res)
  })
  
  
  output$SummaryViewBarplot <- renderPlot({
    data = dataInput()$data
    taxo = data$taxo
    counts = data$counts
    res = NULL
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
    {
      colors=rep(c("#1f77b4","#aec7e8","#ff7f0e","#ffbb78", "#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b",
                   "#c49c94","#e377c2","#f7b6d2","#7f7f7f", "#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"),ceiling(ncol(taxo)/20))
      tmp = apply(taxo,2,unique)
      nbfeatures = as.numeric(lapply(tmp,length)) -as.numeric(lapply(lapply(tmp,is.na),any))
      df <- data.frame(Label = colnames(taxo),Count = nbfeatures)
      df$Label = factor(df$Label,levels =colnames(taxo) )
      res = ggplot(df,aes(x=Label,y=Count,fill=Label))+geom_bar(stat="identity")
      res = res + theme_bw() + xlab("Taxonomy") + scale_fill_manual(values=colors) + guides(fill=FALSE)
    }
    return(res)
  })
  
stevenn's avatar
stevenn committed
417
418
419
420
421
  #####################################################
  ##
  ##                TARGET FILE
  ##
  #####################################################
stevenn's avatar
stevenn committed
422
  
stevenn's avatar
stevenn committed
423
424
425
426
427

  ## Load target file
  dataInputTarget <-reactive({ 
    
    inFile <- input$fileTarget
Stevenn Volant's avatar
Stevenn Volant committed
428
    counts = dataInput()$data$counts
429
430
    
    
stevenn's avatar
stevenn committed
431
432
433
434
    if (is.null(inFile)) return(NULL)
    
    
    data = read.csv(inFile$datapath,sep="\t",header=TRUE)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
435
    rownames(data) <- as.character(data[, 1])
436
    ind = which(rownames(data)%in%colnames(counts))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
437
438
439
440
    #ord = order(rownames(data))
    #data = data[ord,]
    ### A SUPPRIMER 
    #rownames(data) <- colnames(counts)
441
442
    
    # Percent annotated
443
444
445
#     print(ind)
#     print(colnames(counts))
#     print(rownames(data))
446
447
448
    labeled = length(ind)/length(colnames(counts))*100.0
    
    return(list(target=data[ind,], labeled=labeled))
stevenn's avatar
stevenn committed
449
450
451
452
453
454
455
  })



  ## Interest Variables
  output$SelectInterestVar <- renderUI({
        
456
    target=dataInputTarget()$target
stevenn's avatar
stevenn committed
457
458
459
460
    
    if(!is.null(target)) 
    {
      namesTarget = colnames(target)[2:ncol(target)]
Stevenn Volant's avatar
Stevenn Volant committed
461
      selectInput("InterestVar",h6(strong("Select the variables")),namesTarget,selected=namesTarget,multiple=TRUE)
stevenn's avatar
stevenn committed
462
    }
stevenn's avatar
stevenn committed
463
  
stevenn's avatar
stevenn committed
464
  })
stevenn's avatar
stevenn committed
465

stevenn's avatar
stevenn committed
466
467
468
469

  ## Interactions
  output$SelectInteraction2 <- renderUI({
        
470
    target = dataInputTarget()$target
stevenn's avatar
stevenn committed
471
472
473
474
475
476

    if(!is.null(target)) 
    {
      Interac = GetInteraction2(target)
      selectInput("Interaction2",h6(strong("Add interactions")),Interac,selected=NULL,multiple=TRUE)
    }
stevenn's avatar
stevenn committed
477
    
stevenn's avatar
stevenn committed
478
479
480
481
482
  })


  ## Reference radio buttons
  output$RefSelect <- renderUI({
stevenn's avatar
stevenn committed
483
    
484
    target = dataInputTarget()$target
stevenn's avatar
stevenn committed
485
486
    RB=list()
    if(!is.null(target)) 
stevenn's avatar
stevenn committed
487
    {
stevenn's avatar
stevenn committed
488
489
490
491
492
493
494
495
496
497
      InterVar = input$InterestVar
      if(length(InterVar)>0)
      {
        names = paste0("Ref",InterVar)
          for(i in 1:length(names))
          {
            val = unique(target[,InterVar[i]])
            RB[[i]] = selectInput(names[i],paste("Reference for",InterVar[i]),as.vector(val))
          }
      }
stevenn's avatar
stevenn committed
498
    }
stevenn's avatar
stevenn committed
499
    return(RB)
stevenn's avatar
stevenn committed
500
    
stevenn's avatar
stevenn committed
501
502
503
  })


stevenn's avatar
stevenn committed
504
505
  # Infobox design
  output$RowTarget <- renderInfoBox({
506
507
508
509
    #target = dataInputTarget()
    #labeled = dataMergeCounts()$labeled
    labeled = dataInputTarget()$labeled
    if(!is.null(labeled)) 
stevenn's avatar
stevenn committed
510
511
    {
      #### Ajout fontion check target
512
513
514
515
      #infoBox(h6(strong("Target file")), subtitle = h6("Your target file is OK"), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
      labeled = round(labeled,2)
      if(labeled>0) res = valueBox(paste0(labeled, "%"),h6(strong("Labeled features")), color = "green",width=NULL,icon = icon("list"))
      else res = valueBox(paste0(labeled, "%"),h6(strong("Labeled features")), color = "red",width=NULL,icon = icon("list"))  
stevenn's avatar
stevenn committed
516
    }
517
518
519
520
521
    #else infoBox(h6(strong("Target file")), subtitle = h6("Label of the target file must correspond to count table column names") ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("warning"))
    else res = valueBox(paste0(0, "%"),h6(strong("Labeled features")), color = "light-blue",width=NULL,icon = icon("list"))
    return(res)
  }
  )
stevenn's avatar
stevenn committed
522
523
524
525




Amine  GHOZLANE's avatar
Amine GHOZLANE committed
526
  ## target table
stevenn's avatar
stevenn committed
527
  output$DataTarget <- renderDataTable(
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
528
  dataInputTarget()$target,
stevenn's avatar
stevenn committed
529
530
531
532
  options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
                 pageLength = 10,scrollX=TRUE
  ))

Amine  GHOZLANE's avatar
Amine GHOZLANE committed
533
534
  ## Counts table for the selected taxonomy level
  output$CountsMerge <- renderDataTable(
535
    round(counts(ResDiffAnal()$dds,normalized=TRUE)),
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
536
537
538
539
540
    options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
                   pageLength = 10,scrollX=TRUE
    ))


Stevenn Volant's avatar
Stevenn Volant committed
541
  ## Box for merged counts
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
542
543
544
545
546
547
548
  output$BoxCountsMerge <- renderUI({
    
    counts = dataMergeCounts()$counts
    taxo = input$TaxoSelect
    
    if(!is.null(counts) && taxo != "...")
    {
549
      box(title=paste("Count table (",taxo,")",sep=""),width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = TRUE,
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
550
551
552
553
554
555
556
557
558
559
          dataTableOutput("CountsMerge"),
          downloadButton('ExportCounts', 'Export normalised counts'),
          downloadButton('ExportRelative', 'Export relative abundance')
      )  
    }
    
  })

  ## Export in .csv
  output$ExportCounts <- downloadHandler(
Stevenn Volant's avatar
Stevenn Volant committed
560
561
    filename = function() { 'NormCounts.csv' },
    content = function(file){write.csv(dataMergeCounts()$counts, file)}
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
562
  )
stevenn's avatar
stevenn committed
563
564
565
566

  ## Export in .csv
  output$ExportRelative <- downloadHandler(
    filename = function() { 'RelativeAb.csv' },
Stevenn Volant's avatar
Stevenn Volant committed
567
    content = function(file){write.csv(dataMergeCounts()$counts/colSums(dataMergeCounts()$counts), file)}
stevenn's avatar
stevenn committed
568
  )
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
569
570


stevenn's avatar
stevenn committed
571
572
573
  ## Box for target visualisation
  output$BoxTarget <- renderUI({
    
574
    target = dataInputTarget()$target
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
575

stevenn's avatar
stevenn committed
576
577
578
579
580
581
582
583
584
585
    if(!is.null(target) &&  nrow(target)>0)
    {
      box(title="Target file overview",width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = TRUE,
          dataTableOutput("DataTarget")
      )  
    }
    
  })


stevenn's avatar
stevenn committed
586
587
588
589
590
591
592
593
594

#####################################################
##
##            DEFINE CONTRAST
##
#####################################################
  
  output$contrastMat <- renderUI({
    
stevenn's avatar
stevenn committed
595
596
597
598
    resDiff = ResDiffAnal()
    dds = resDiff$dds
    names = resultsNames(dds)

stevenn's avatar
stevenn committed
599
600
    Contrast=list()
    
601
    for(i in 1:length(names)){Contrast[[i]] = numericInput(names[i],names[i],0,step=1,min=-1,max=1)}
stevenn's avatar
stevenn committed
602
603
604
605
606
607
  
    return(Contrast)
    
  })


stevenn's avatar
stevenn committed
608
609
610
611
612
  output$ContrastOverview <- renderPrint({
    
    resDiff = ResDiffAnal()
    dds = resDiff$dds
    names = resultsNames(dds)
stevenn's avatar
stevenn committed
613
614
    
    cont = input$ContrastList
stevenn's avatar
stevenn committed
615
    filesize = file.info(namesfile)[,"size"]
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
616
    if(is.na(filesize)){filesize=0}
stevenn's avatar
stevenn committed
617
618
619
620
621
622
    if(filesize!=0)
    { 
      ContrastBase = read.table(namesfile,header=TRUE)
      ind = which(colnames(ContrastBase)%in%cont)
      div(HTML(PrintContrasts(names,sapply(ContrastBase[,ind],as.numeric),cont)))
    }
stevenn's avatar
stevenn committed
623
624
625
  })


stevenn's avatar
stevenn committed
626
627
628
629
630
631
  ## Add contrast function
  AddCont <-eventReactive(input$AddContrast,{
    
    resDiff = ResDiffAnal()
    dds = resDiff$dds
    names = resultsNames(dds)
Stevenn Volant's avatar
Stevenn Volant committed
632

stevenn's avatar
stevenn committed
633
    BaseContrast(input,names,namesfile)
Stevenn Volant's avatar
Stevenn Volant committed
634
635
636
    filesize = file.info(namesfile)[,"size"]
    if(is.na(filesize)){filesize=0}
    if(filesize!=0) tmp = read.table(namesfile,header=TRUE)
stevenn's avatar
stevenn committed
637
638
    Contrast = colnames(as.matrix(tmp))
    updateSelectInput(session, "ContrastList","Contrasts",Contrast)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
639
    updateSelectInput(session, "ContrastList_table","Contrasts",Contrast)
640
641
    updateSelectInput(session, "ContrastList_table_Visu","For which contrasts",Contrast)
    updateSelectInput(session, "ContrastList_table_FC","Contrasts (Min = 2)",Contrast)
stevenn's avatar
stevenn committed
642
  })
stevenn's avatar
stevenn committed
643

stevenn's avatar
stevenn committed
644
645
  ## Add contrast 
  observeEvent(input$AddContrast,{  
stevenn's avatar
stevenn committed
646
    
stevenn's avatar
stevenn committed
647
    AddCont()
stevenn's avatar
stevenn committed
648
    
Stevenn Volant's avatar
Stevenn Volant committed
649
  },priority=1)
stevenn's avatar
stevenn committed
650

651
652
653
654
655
656
657
658
659
660
661
662
663

  ## Add contrast function
  AddContEasy <-eventReactive(input$AddContrastEasy,{
    
    resDiff = ResDiffAnal()
    dds = resDiff$dds
    names = resultsNames(dds)
#     
#     BaseContrast(input,names,namesfile)
#     tmp = read.table(namesfile,header=TRUE)
#     Contrast = colnames(as.matrix(tmp))
    updateSelectInput(session, "ContrastList","Contrasts",Contrast)
    updateSelectInput(session, "ContrastList_table","Contrasts",Contrast)
664
665
    updateSelectInput(session, "ContrastList_table_Visu","For which contrasts",Contrast)
    updateSelectInput(session, "ContrastList_table_FC","Contrasts (Min = 2)",Contrast)
666
  })
stevenn's avatar
stevenn committed
667
  
668
669
670
671
672
673
674
675
676
677
678
679
680
  ## Add contrast 
  observeEvent(input$AddContrastEasy,{  
    
    AddContEasy()
    
  })


  AddContFromFile <-eventReactive(input$fileContrast,{ 
    
    res = ReadContrastFile()
    createdCont = NULL
    filesize = file.info(namesfile)[,"size"]
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
681
    if(is.na(filesize)){filesize=0}
682
683
684
685
686
687
688
    if(filesize!=0){ createdCont = read.table(namesfile,header=TRUE) }
      
    if(!is.null(res))
    { 
      if(!is.null(createdCont)) res = cbind(res,createdCont)
      updateSelectInput(session, "ContrastList","Contrasts",colnames(res))
      updateSelectInput(session, "ContrastList_table","Contrasts",colnames(res))
689
690
      updateSelectInput(session, "ContrastList_table_Visu","For which contrasts",colnames(res))
      updateSelectInput(session, "ContrastList_table_FC","Contrasts (Min = 2)",colnames(res))
691
692
693
694
695
696
697
      write.table(res,namesfile,row.names=FALSE)
    }
  })
 
 observeEvent(input$fileContrast,{ 
    
   AddContFromFile()
Stevenn Volant's avatar
Stevenn Volant committed
698
  },priority=1)
699
700


stevenn's avatar
stevenn committed
701
702
703
704
705
  ## Remove contrast function
  RemoveCont <-eventReactive(input$RemoveContrast,{
    
    ## get the size of the contrast base file
    filesize = file.info(namesfile)[,"size"]
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
706
    if(is.na(filesize)){filesize=0}
stevenn's avatar
stevenn committed
707
708
709
710
711
712
    if(filesize!=0)
    { 
      tmp = read.table(namesfile,header=TRUE)
      ind = which(colnames(tmp)%in%input$ContrastList)
      matKept = as.matrix(tmp[,-ind])
      ContrastKept = colnames(tmp)[-ind]
stevenn's avatar
stevenn committed
713
      
stevenn's avatar
stevenn committed
714
715
716
      if(ncol(matKept)>0) write.table(matKept,namesfile,row.names=FALSE,col.names = ContrastKept)
      else file.create(namesfile,showWarnings=FALSE)
      updateSelectInput(session, "ContrastList","Contrasts",ContrastKept)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
717
      updateSelectInput(session, "ContrastList_table","Contrasts",ContrastKept)
718
719
      updateSelectInput(session, "ContrastList_table_Visu","For which contrasts",ContrastKept)
      updateSelectInput(session, "ContrastList_table_FC","Contrasts (Min = 2)",ContrastKept)
stevenn's avatar
stevenn committed
720
    }
stevenn's avatar
stevenn committed
721
722
723
724
725
726
727
728
729
  })
  
  
  
  ## Remove contrast
  observeEvent(input$RemoveContrast,{  
    
    RemoveCont()
    
Stevenn Volant's avatar
Stevenn Volant committed
730
  },priority=1)
stevenn's avatar
stevenn committed
731

Stevenn Volant's avatar
Stevenn Volant committed
732
733
734
735
736
737
738
739
740
  ## Remove all contrasts
  RemoveAllCont <-eventReactive(input$RunDESeq,{
    
      file.create(namesfile,showWarnings=FALSE)
      updateSelectInput(session, "ContrastList","Contrasts",NULL)
      updateSelectInput(session, "ContrastList_table","Contrasts",NULL)
      updateSelectInput(session, "ContrastList_table_Visu","For which contrasts",NULL)
      updateSelectInput(session, "ContrastList_table_FC","Contrasts (Min = 2)",NULL)
  })
stevenn's avatar
stevenn committed
741

Stevenn Volant's avatar
Stevenn Volant committed
742
743
  ## Remove all contrast
  observeEvent(input$RunDESeq,{  
stevenn's avatar
stevenn committed
744
    
Stevenn Volant's avatar
Stevenn Volant committed
745
    RemoveAllCont()
stevenn's avatar
stevenn committed
746
    
Stevenn Volant's avatar
Stevenn Volant committed
747
748
749
750
  })

# Infobox Contrast
output$InfoContrast <- renderInfoBox({
751
  input$RunDESeq
Stevenn Volant's avatar
Stevenn Volant committed
752
753
754
  input$AddContrast
  input$RemoveContrast
  input$fileContrast
755
756
757
  resDiff = ResDiffAnal()
  res=NULL
  if(!is.null(resDiff)){
Stevenn Volant's avatar
Stevenn Volant committed
758
  
svolant's avatar
svolant committed
759
760
761
762
763
764
765
766
767
768
769
770
    res = infoBox("Contrasts", subtitle = h6("At least one contrast (non null) must be defined"), icon = icon("warning"),color = "light-blue",width=NULL,fill=TRUE)
    test = FALSE
    filesize = isolate(file.info(namesfile)[,"size"])
    
    if(is.na(filesize)){filesize=0}
    if(filesize!=0) 
    {
      tmp = read.table(namesfile,header=TRUE)
      if(any(as.vector(tmp)!=0)) test = TRUE
    }
    
    if(test) res = infoBox("Contrasts", subtitle = h6("Contrasts OK"), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
771
  }
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
    return(res)
  })


  
  output$contrastBox <- renderUI({
    
    resDiff = ResDiffAnal()
    int = input$Interaction2
    target = resDiff$target
    
    InterVar = input$InterestVar
    ModInterestAll = unique(target[,InterVar])
    test = c()
    for(i in 1:length(InterVar)){ test =c(test,input$Select1_contrast%in%target[,InterVar[i]]) }
    
    ModInterestCond = unique(target[,which(test)])
    #alltmp = c(InterVar,Interaction)
    
    if(!is.null(resDiff))
    { 
      box(title="Contrasts",width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = FALSE,
          fluidRow(
            column(width=3,selectInput("Select1_contrast",label=h6(strong("Compare")),ModInterestAll)),
            column(width=3,selectInput("Select2_contrast",label=h6(strong("To")),ModInterestCond)),
            if(length(int)>=1) column(width=3,selectInput("Select3_contrast",label=h6(strong("For")),c("All","WT","Delta"))),
            column(width=3,br(),br(),actionButton("AddContrastEasy","Add",icon = icon("plus")))
          )
      )
    }
    
  })


  output$contrastBoxAdvanced <- renderUI({
    
    resDiff = ResDiffAnal()
    
    if(!is.null(resDiff))
    { 
Stevenn Volant's avatar
Stevenn Volant committed
812
      box(title="Contrasts (advanced user)",width = NULL, status = "primary", solidHeader = TRUE,collapsible = TRUE,collapsed = FALSE,
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
          fluidRow(
            column(width=12,
                   fileInput('fileContrast', h6(strong('Select a file of contrasts')),width="60%")
            ),
            hr(),
            column(width=12,h6(strong("Define contrasts by yourself"))),
            column(width=6,textInput("ContrastName",label = NULL,value = "Contrast name")),
            column(width=6,actionButton("AddContrast","Add contrast",icon = icon("plus")))
          ),
          fluidRow(column(width=12,uiOutput("contrastMat")))
      )
    }
    
  })


  output$contrastDefined <- renderUI({
    resDiff = ResDiffAnal()
    
    if(!is.null(resDiff))
    { 
      box(title="Defined contrasts",width = NULL, status = "primary", solidHeader = TRUE,collapsible = FALSE,collapsed = FALSE,
          fluidRow(
            column(width=11,
                   selectInput("ContrastList","Contrasts","",multiple=TRUE,size=4,selectize=FALSE,width = '100%'),
                   fluidRow(
                      column(width=6,actionButton("RemoveContrast","Remove",icon = icon("remove"))),
                      column(width=6,downloadButton("exportContrast", "Export"))
                   ),
                   htmlOutput("ContrastOverview")
            )
            
          )
      )
stevenn's avatar
stevenn committed
847
    }
stevenn's avatar
stevenn committed
848
849
  })

stevenn's avatar
stevenn committed
850

851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
  ReadContrastFile <-reactive({ 
    
    inFile <- input$fileContrast
    
    if (is.null(inFile)) return(NULL)
    
    res = read.csv(inFile$datapath,sep=" ",header=TRUE)
    
    return(res)
  })
  

  output$exportContrast <- downloadHandler(
    filename <- function() {"Contrasts.txt"},
    content <- function(file) {
      file.copy(namesfile,file)
    }
  )



stevenn's avatar
stevenn committed
872
873
874
875
876
877
878
879
880
881
882

#####################################################
##
##                DESEQ2 run
##
#####################################################



  # Infobox Contrast
  output$InfoDESeq <- renderInfoBox({
883
      input$RunDESeq
884
885
886
887
888
      
      resDiff = ResDiffAnal()
      if(!is.null(resDiff)){
        infoBox(h6(strong("Statistical analysis")), subtitle = h6("Differential analysis is done !"), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
      }
stevenn's avatar
stevenn committed
889

stevenn's avatar
stevenn committed
890
891
    
  })
stevenn's avatar
stevenn committed
892
  
stevenn's avatar
stevenn committed
893

stevenn's avatar
stevenn committed
894
895
896
  ## Get the results from DESeq2
  ResDiffAnal <-eventReactive(input$RunDESeq,{
    
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
897
    counts = dataMergeCounts()$counts
Stevenn Volant's avatar
Stevenn Volant committed
898
    CT_noNorm = dataMergeCounts()$CT_noNorm
899
    normFactors = dataMergeCounts()$normFactors
900
901
    ## HEEEERRREE
    target = dataInputTarget()$target
902
    #print(target)
stevenn's avatar
stevenn committed
903
904
    design = GetDesign(input)
   
Stevenn Volant's avatar
Stevenn Volant committed
905
    Get_dds_object(input,counts,target,design,normFactors,CT_noNorm)
stevenn's avatar
stevenn committed
906
907
908

    
  })
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
909
910


stevenn's avatar
stevenn committed
911
  ## Run DESeq2 via RunDESeq button
912
  observeEvent(input$RunDESeq,{
Stevenn Volant's avatar
Stevenn Volant committed
913
    withProgress(message="Analysis in progress...",ResDiffAnal())
stevenn's avatar
stevenn committed
914
  })
stevenn's avatar
stevenn committed
915

stevenn's avatar
stevenn committed
916
  
stevenn's avatar
stevenn committed
917
918
919
920
921
#####################################################
##
##                Taxonomy
##
#####################################################
stevenn's avatar
stevenn committed
922
923
  
  
stevenn's avatar
stevenn committed
924
925
  # Infobox Contrast
  output$SelectTaxo <- renderUI({
stevenn's avatar
stevenn committed
926
    
Stevenn Volant's avatar
Stevenn Volant committed
927
    data = dataInput()$data
stevenn's avatar
stevenn committed
928
929
930
    if(!is.null(data$taxo) && nrow(data$taxo)>0)
    { 
      tmp = colnames(data$taxo)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
931
      selectInput("TaxoSelect",h6(strong("Select the taxonomy level")),c("...",tmp,"OTU"))
stevenn's avatar
stevenn committed
932
    }
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
933
    else selectInput("TaxoSelect",h6(strong("Select the taxonomy level")),c("..."))
stevenn's avatar
stevenn committed
934
935
936
937
938
939
940
941
942

  })
  


  
  # Infobox taxo
  output$InfoTaxo <- renderInfoBox({
  
Stevenn Volant's avatar
Stevenn Volant committed
943
    data = dataInput()$data
stevenn's avatar
stevenn committed
944
    taxo = input$TaxoSelect
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
945
946
    
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && !is.null(taxo) && taxo!="...") 
stevenn's avatar
stevenn committed
947
    {
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
948
949
950
      counts = dataMergeCounts()$counts
      nfeature = nrow(counts)
      infoBox(h6(strong("Taxonomy")), subtitle = h6(paste(taxo, ", nb features: ",nfeature,sep="")), icon = icon("thumbs-o-up"),color = "green",width=NULL,fill=TRUE)
stevenn's avatar
stevenn committed
951
    }
952
    else infoBox(h6(strong("Taxonomy")), subtitle = h6("Select the taxonomy for the analysis") ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("warning"))
stevenn's avatar
stevenn committed
953
954
955
956
957
958
959
960
961
962
963
964
  })



#####################################################
##
##                Diagnostic plots
##
#####################################################


  
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
965
  output$VarIntDiag <- renderUI({
stevenn's avatar
stevenn committed
966
    
967
    target=dataInputTarget()$target
stevenn's avatar
stevenn committed
968
    
969
970
971
972
973
    if(!is.null(target)) 
    {
      namesTarget = colnames(target)[2:ncol(target)]
      selectizeInput("VarInt",h6(strong("Select the variables of interest (max 2)")),namesTarget, selected = namesTarget[1],multiple = TRUE,options = list(maxItems = 2))
    }
stevenn's avatar
stevenn committed
974
975
976
977
978
    
  })
  
  
  output$PlotDiag <- renderPlot({
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
979
    input$RunDESeq
stevenn's avatar
stevenn committed
980
    
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
981
    resDiff = isolate(ResDiffAnal())
stevenn's avatar
stevenn committed
982
    Plot_diag(input,resDiff)
Stevenn Volant's avatar
Stevenn Volant committed
983
984
985
  },height = reactive(input$heightDiag))


stevenn's avatar
stevenn committed
986

Amine  GHOZLANE's avatar
Amine GHOZLANE committed
987
988
989
990
  output$PlotpcoaEigen <- renderPlot({
    
    resDiff = ResDiffAnal()
    Plot_diag_pcoaEigen(input,resDiff)
Stevenn Volant's avatar
Stevenn Volant committed
991
  },height = 400)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
992
993
994
995
996

  output$PlotEigen <- renderPlot({
    
    resDiff = ResDiffAnal()
    Plot_diag_Eigen(input,resDiff)
Stevenn Volant's avatar
Stevenn Volant committed
997
  },height =400)
stevenn's avatar
stevenn committed
998
999
1000

  SizeFactor_table <-reactive({ 
    res = ResDiffAnal()
For faster browsing, not all history is shown. View entire blame