server.R 98.5 KB
Newer Older
stevenn's avatar
stevenn committed
1
shinyServer(function(input, output,session) {
svolant's avatar
svolant committed
2
3
4

  hide(id = "loading-content", anim = TRUE, animType = "fade",time=1.5)
  hide(id = "loading-content-bar", anim = TRUE, animType = "fade",time=1.5)
5
6
7
8
9
  #####################################################
  ##
  ##                    LOAD FILES
  ##
  #####################################################
stevenn's avatar
stevenn committed
10
  
11
12
  
  
stevenn's avatar
stevenn committed
13
14
  ## Create base for contrast
  rand = floor(runif(1,0,1e9))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
15
  namesfile = tempfile(pattern = "BaseContrast", tmpdir = tempdir(), fileext = "")
stevenn's avatar
stevenn committed
16
  file.create(namesfile,showWarnings=FALSE)
17
  target = NULL
18
  
svolant's avatar
svolant committed
19
20
21
22
23
  
  ## JSON name for masque
  curdir  = getwd()
  json_name = tempfile(pattern = "file", tmpdir = paste(curdir,"www","masque","todo",sep= .Platform$file.sep),  fileext = ".json")
  
svolant's avatar
svolant committed
24
25
26
  ## Pass for MASQUE
  pass = gsub("file","",basename(file_path_sans_ext(json_name)))
  
svolant's avatar
svolant committed
27
  ## Popup messages
svolant's avatar
svolant committed
28
  observe(if(input$AddRegScatter) info("By adding the regression line, you will lose interactivity."))
29
  
30
  ## Reactive target
svolant's avatar
svolant committed
31
32
33
  values <- reactiveValues(TargetWorking = target,labeled=NULL,fastq_names_only=NULL,R1fastQ=NULL,R2fastQ=NULL,
                           json_name=json_name,num=0,pass=pass,login_email = NULL,is.valid =NULL,
                           biom_masque = NULL,tree_masque=NULL)
34
  
stevenn's avatar
stevenn committed
35
  ## Counts file
stevenn's avatar
stevenn committed
36
  dataInputCounts <-reactive({ 
37
    
svolant's avatar
svolant committed
38
    data = NULL
stevenn's avatar
stevenn committed
39
    inFile <- input$fileCounts
40
    
stevenn's avatar
stevenn committed
41
    if (is.null(inFile)) return(NULL)
42
43
    
    
svolant's avatar
svolant committed
44
45
46
47
48
49
    try(read.csv(inFile$datapath,sep=input$sepcount,header=TRUE,check.names=FALSE)->data,silent=T)

    if(!is.null(data)){
      colnames(data) = gsub("-",".",colnames(data))
      ## Rownames
      if(!TRUE%in%duplicated(data[,1])) rownames(data)=data[,1];data=data[,-1]
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
50
      try(round(data, 0)->data, silent=T)
svolant's avatar
svolant committed
51
    }
stevenn's avatar
stevenn committed
52
53
54
    return(as.data.frame(data))
  })
  
55
56
  
  
stevenn's avatar
stevenn committed
57
58
  ## Taxo File
  dataInputTaxo <-reactive({ 
stevenn's avatar
stevenn committed
59
    
stevenn's avatar
stevenn committed
60
    inFile <- input$fileTaxo
stevenn's avatar
stevenn committed
61
    
stevenn's avatar
stevenn committed
62
    if (is.null(inFile)) return(NULL)
63
    
Stevenn Volant's avatar
Stevenn Volant committed
64
65
    if(input$TypeTaxo=="Table") 
    {
svolant's avatar
svolant committed
66
67
      try(read.csv(inFile$datapath,sep=input$septaxo,header=TRUE)->data,silent=T)
    
Stevenn Volant's avatar
Stevenn Volant committed
68
      ## Rownames
svolant's avatar
svolant committed
69
70
71
72
73
74
75
76
77
      if(!is.null(data))
      {
        if(!TRUE%in%duplicated(data[,1])){ 
          DataNames=data[,1]
          colNames=colnames(data)[-1]
          data=as.matrix(data[,-1])
          rownames(data)=DataNames
          colnames(data) = colNames
        }
78
      }
Stevenn Volant's avatar
Stevenn Volant committed
79
    }
stevenn's avatar
stevenn committed
80
    
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
81
82
    if(input$TypeTaxo=="RDP") 
    {
Stevenn Volant's avatar
Stevenn Volant committed
83
      data = read_rdp(inFile$datapath,input$RDP_th)
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
84
    }
stevenn's avatar
stevenn committed
85
86
87
    
    ## Add NA
    data=as.matrix(data)
Stevenn Volant's avatar
Stevenn Volant committed
88
    indNa = which(data=="")
stevenn's avatar
stevenn committed
89
90
    data[indNa]=NA
    
stevenn's avatar
stevenn committed
91
    return(as.data.frame(data))
stevenn's avatar
stevenn committed
92
  })
93
94
  
  
stevenn's avatar
stevenn committed
95
96
  ## BIOM File
  dataInputBiom <-reactive({ 
stevenn's avatar
stevenn committed
97
    
svolant's avatar
svolant committed
98
    data = NULL
stevenn's avatar
stevenn committed
99
    inFile <- input$fileBiom
svolant's avatar
svolant committed
100
101
102
103
104

    if (!is.null(inFile) && is.null(values$biom_masque)) {
      try(read_biom(inFile$datapath)->data,silent=T)
      }
    if (!is.null(values$biom_masque) && file.exists(values$biom_masque)) try(read_biom(values$biom_masque)->data,silent=T)
stevenn's avatar
stevenn committed
105
    
stevenn's avatar
stevenn committed
106
    return(data)
stevenn's avatar
stevenn committed
107
  })
108
  
svolant's avatar
svolant committed
109
110
111
112
  
  observeEvent(input$fileBiom,{
    values$biom_masque=NULL;
  })
svolant's avatar
svolant committed
113

114
  
svolant's avatar
svolant committed
115
116
117
118
119
120
  ## Unifrac File (tree)
  dataInputTree <-reactive({ 
    
    data = NULL
    inFile <- input$fileTree
    
svolant's avatar
svolant committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    if (!is.null(inFile) && is.null(values$tree_masque)) {
      try(read.tree(inFile$datapath)->data, silent=T)
      CheckTree = CheckTreeFile(data)
      data = CheckTree$tree
      try(readLines(inFile$datapath)->treeseq, silent=T)
      return(list(data=data, Error=CheckTree$Error, Warning=CheckTree$Warning, treeseq=treeseq))
    }
    
    if (!is.null(values$tree_masque) && file.exists(values$tree_masque)) {
      try(read.tree(values$tree_masque)->data, silent=T)
      CheckTree = CheckTreeFile(data)
      data = CheckTree$tree
      try(readLines(values$tree_masque)->treeseq, silent=T)
      return(list(data=data, Error=CheckTree$Error, Warning=CheckTree$Warning, treeseq=treeseq))
    }

  })
  
  
  observeEvent(input$fileTree,{
    values$tree_masque=NULL;
svolant's avatar
svolant committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  })
  
  
  # Infobox Tree (Unifrac)
  output$InfoTreePhylo_box <- renderInfoBox({
    input$fileTree
    tree_tmp = isolate(dataInputTree())
    tree = tree_tmp$data
    
    res = infoBox(h6(strong("Phylogenetic tree")), subtitle = h6(strong("Load the phylogenetic tree (optional)")) ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("upload"))
    if(!is.null(tree)){
      if(!is.null(isolate(input$fileTree))){
        res = infoBox(h6(strong("Phylogenetic tree")), subtitle = h6("The phylogenetic has been loaded") ,color = "green",width=NULL,fill=TRUE, icon = icon("thumbs-o-up"))
        if(!is.null(tree_tmp$Warning)){      
          res = infoBox(h6(strong("Phylogenetic tree")), subtitle = h6(tree_tmp$Warning) ,color = "orange",width=NULL,fill=TRUE, icon = icon("warning"))
        }
        if(!is.null(tree_tmp$Error)){      
          res = infoBox(h6(strong("Phylogenetic tree")), subtitle = h6(tree_tmp$Error),color = "red",width=NULL,fill=TRUE, icon = icon("thumbs-o-down"))
        }
      }
    } 
    return(res)
  })
165

166
  
stevenn's avatar
stevenn committed
167
168
  ## Input data
  dataInput <-reactive({ 
stevenn's avatar
stevenn committed
169
    
stevenn's avatar
stevenn committed
170
    data = NULL
Stevenn Volant's avatar
Stevenn Volant committed
171
172
    check = NULL
    percent = NULL
svolant's avatar
svolant committed
173
174
    Taxo = NULL
    Counts = NULL
svolant's avatar
svolant committed
175
176
    inputData = NULL
    
stevenn's avatar
stevenn committed
177
    if(input$FileFormat=="fileCounts")
stevenn's avatar
stevenn committed
178
    {
stevenn's avatar
stevenn committed
179
      Counts = dataInputCounts()
svolant's avatar
svolant committed
180
181
182
      if(!input$NoTaxoFile) Taxo = dataInputTaxo()
      if(!is.null(Counts) && input$NoTaxoFile) {Taxo = data.frame(rownames(Counts),row.names = rownames(Counts));names(Taxo)=NA}
      
Stevenn Volant's avatar
Stevenn Volant committed
183
184
      if(!is.null(Counts) && !is.null(Taxo))
      { 
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
185
        tmp = GetDataFromCT(Counts,Taxo, ifelse(input$TypeTable=="MGS" && input$FileFormat!="fileBiom", TRUE, FALSE))
Stevenn Volant's avatar
Stevenn Volant committed
186
187
188
189
        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
190
191
    }
    
stevenn's avatar
stevenn committed
192
    if(input$FileFormat=="fileBiom")
stevenn's avatar
stevenn committed
193
    {
stevenn's avatar
stevenn committed
194
      tmpBIOM = dataInputBiom()
Stevenn Volant's avatar
Stevenn Volant committed
195
196
197
198
199
200
201
      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
202
203
    }
    
svolant's avatar
svolant committed
204
205
206
207
208
209
210
211
212
213
214
#     if(input$FileFormat=="fileRData")
#     {
#       inFile <- input$fileRData
#       load(inFile)
#       if(!is.null(inputData)){
#         data = inputData$data
#         check = inputData$check
#         percent = inputData$percent
#       }
#     }
    
Stevenn Volant's avatar
Stevenn Volant committed
215
    return(list(data=data,check=check,percent=percent))
stevenn's avatar
stevenn committed
216
217
218
  })
  
  
219
220
221
222
223
224
225
  ## Size factor file (optional)
  dataSizeFactors <-reactive({ 
    
    inFile <- input$fileSizeFactors
    
    if (is.null(inFile)) return(NULL)
    
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
226
    data = read.csv(inFile$datapath,sep=input$sepsize,header=TRUE)
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
    return(as.data.frame(data))
  })
  
  
  ## Size factor file (optional)
  SizeFactors_fromFile <-reactive({ 
    
    Error = NULL
    Check = TRUE
    
    data = dataSizeFactors()
    normFactors = dataMergeCounts()$normFactors
    
    if(!is.null(data)){
      ## Check the format
      
      tmp = as.numeric(data)
      names(tmp) = colnames(data)
      
      if(length(tmp)!=length(normFactors)){Error = "The number of samples is not the same than in the target file, size factors will be estimated"; Check = FALSE}
      if(!identical(names(tmp),names(normFactors))){Error = "The names are not the same or in the same order than in the target file, size factors will be estimated"; Check = FALSE}
248
      
249
250
251
252
253
254
255
256
257
258
259
      if(Check) normFactors = tmp
    }
    
    return(list(Check = Check,Error = Error,normFactors=normFactors))
  })
  
  
  
  
  
  
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
260
  ## Merge counts data
261
  dataMergeCounts <-reactive({
Stevenn Volant's avatar
Stevenn Volant committed
262
    input$RunDESeq
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
263
264
265
    
    counts = NULL
    CheckTarget = FALSE
266
    normFactors = NULL
Stevenn Volant's avatar
Stevenn Volant committed
267
    CT_noNorm = NULL
268
    CT_Norm = NULL
269
    ChTM = NULL
270
    data = isolate(dataInput()$data)
271
272
    target = isolate(values$TargetWorking)
    labeled= isolate(values$labeled)
273
    taxo = isolate(input$TaxoSelect)
274
    withProgress(
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
275
276
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && !is.null(taxo) && taxo!="..." && !is.null(target)) 
    {
svolant's avatar
svolant committed
277
      design = GetDesign(isolate(input),target)
278
279
      ChTM = CheckTargetModel(input,target,labeled,data$counts)$Error
      if(!is.null(design) && is.null(ChTM))
280
      {
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
        tmp = isolate(GetCountsMerge(input,data,taxo,target,design))
        counts = tmp$counts
        ## Filtering the counts
        if(isolate(input$AddFilter) && !is.null(isolate(input$SliderThSamp)) && !is.null(isolate(input$SliderThAb)))
        {
          ind.filter =Filtered_feature(counts,isolate(input$SliderThSamp),isolate(input$SliderThAb))$ind
          counts = counts[-ind.filter,]
        }
        CheckTarget = tmp$CheckTarget
        #target = tmp$target
        #labeled = tmp$labeled
        normFactors = tmp$normFactors
        ## OTU table, norm and no norm
        CT_noNorm = tmp$CT_noNorm
        CT_Norm = tmp$CT_Norm
296
      }
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
297
    }
298
    ,message="Merging the counts ...")
299
    return(list(counts=counts,CheckTarget=CheckTarget,normFactors=normFactors,CT_noNorm=CT_noNorm, CT_Norm=CT_Norm))
300
    #return(list(counts=counts,target=target,labeled=labeled,normFactors=normFactors,CT_noNorm=CT_noNorm))
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
301
  })
302
303
  
  
Stevenn Volant's avatar
Stevenn Volant committed
304
305
306
307
308
309
310
  # Infobox Error counts
  output$InfoErrorCounts <- renderInfoBox({
    
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
    cond = (!is.null(data$counts) && nrow(data$counts)>0)
311
    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
312
313
314
    
    if(cond)
    {
315
316
317
      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
318
319
320
321
    }
    
    return(res)
  })
322
  
Stevenn Volant's avatar
Stevenn Volant committed
323
324
325
326
327
328
329
  # Infobox Error counts
  output$InfoErrorTaxo <- renderInfoBox({
    
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
    cond = (!is.null(data$taxo) && nrow(data$taxo)>0)
svolant's avatar
svolant committed
330
    res = infoBox(h6(strong("Taxonomy table")), subtitle = h6("Load the taxonomy table") ,color = "light-blue",width=NULL,fill=TRUE, icon = icon("upload"))
Stevenn Volant's avatar
Stevenn Volant committed
331
332
333
334
335
336
337
338
    
    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)
    }
    
svolant's avatar
svolant committed
339
    if(input$NoTaxoFile && input$FileFormat=="fileCounts") res = infoBox(h6(strong("Taxonomy table")), subtitle = h6("No taxonomy table has been uploaded, the analysis can only be done at the OTU/gene level"), icon = icon("warning"),color = "orange",width=NULL,fill=TRUE)
Stevenn Volant's avatar
Stevenn Volant committed
340
341
    return(res)
  })
342
343
  
  
Stevenn Volant's avatar
Stevenn Volant committed
344
345
346
347
348
349
350
351
  # 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"))
svolant's avatar
svolant committed
352

Stevenn Volant's avatar
Stevenn Volant committed
353
354
355
356
357
358
359
360
361
362
    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
363
  
364
  
365
366
367
368
369
370
371
372
  ####### Filtering the counts (sliders)
  
  output$ThAb <- renderUI({
    input$AddFilter
    
    res = NULL
    counts = isolate(dataMergeCounts()$counts)
    tot = rowSums(counts)
373
    #save(counts,tot,file="testFilter.RData")
374
    withProgress({tmp = SelectThreshAb(counts,lambda=max(round(sum(counts)/nrow(counts)*0.05),min(tot)+1),graph=FALSE)},message="Loading...")
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
    
    res = sliderInput("SliderThAb","Threshold on the total abundance (in log)",min=0,max=round(max(log(tot+1)),1),value = log(tmp+1))
    return(res)
  })
  
  
  output$ThSamp <- renderUI({
    input$AddFilter
    
    res = NULL
    counts = isolate(dataMergeCounts()$counts)
    counts.bin = as.matrix(counts)
    counts.bin[which(counts>0)] = 1
    nbSampByFeat = rowSums(counts.bin)
    
    ## Default value
    val = round(max(nbSampByFeat)*0.2)
    
    res = sliderInput("SliderThSamp","Threshold on the minimal number of samples",min=0,max=max(nbSampByFeat),value = val)
    return(res)
  })
  
  
  ## Plot for the filtering step$
  
  # plot_filter(counts,th.samp,th.abund,type="Scatter")
  
402
  output$Plot_ThAb <- renderPlot({
403
404
405
406
407
408
    counts = dataMergeCounts()$counts
    ## output of plot_filter is ggplot class
    plot_filter(counts,input$SliderThSamp,input$SliderThAb,type="Abundance")
    
  })
    
409
  output$Plot_ThSamp <- renderPlot({
410
411
412
413
    counts = dataMergeCounts()$counts
    ## output of plot_filter is ggplot class
    plot_filter(counts,input$SliderThSamp,input$SliderThAb,type="Samples")
  })
414
  
415
416
417
418
419
  output$Plot_Scatter_Filter <- renderScatterD3({
    counts = dataMergeCounts()$counts
    ## output of plot_filter is ggplot class
    plot_filter(counts,input$SliderThSamp,input$SliderThAb,type="Scatter")
  })
420
421
422
423
424
  #####################################################
  ##
  ##                DYNAMIC MENU
  ##
  #####################################################
stevenn's avatar
stevenn committed
425
426
427
428
429
  
  
  
  output$dymMenu <- renderMenu({
    
Stevenn Volant's avatar
Stevenn Volant committed
430
431
432
    tmp = dataInput()
    data = tmp$data
    check = tmp$check
stevenn's avatar
stevenn committed
433
    
Stevenn Volant's avatar
Stevenn Volant committed
434
435
436
    ## 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
437
    {
svolant's avatar
svolant committed
438

svolant's avatar
svolant committed
439
      sidebarMenu(id = "side",
stevenn's avatar
stevenn committed
440
441
        menuItem("Statistical analysis",
                 menuSubItem("Run differential analysis",tabName="RunDiff"),
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
442
                 menuSubItem("Diagnostic plots",tabName="DiagPlotTab"),
stevenn's avatar
stevenn committed
443
                 menuSubItem("Tables",tabName="TableDiff"),
444
445
                 icon = icon("bar-chart-o"), tabName = "AnaStat"
        ),
446
447
448
        menuItem("Visualization",icon = icon("area-chart"),
                 menuSubItem("Global views",tabName="GlobVisu"),
                 menuSubItem("Comparison plots",tabName="CompPlot"),
Amine  GHOZLANE's avatar
Amine GHOZLANE committed
449
450
                 tabName = "Visu")
        #menuItem("Perspective plots", icon = icon("pie-chart"), tabName = "Krona")
stevenn's avatar
stevenn committed
451
      )
svolant's avatar
svolant committed
452
    } else{ sidebarMenu(id = "side",NULL)}
svolant's avatar
svolant committed
453

stevenn's avatar
stevenn committed
454
455
456
  })
  
  
457
  
stevenn's avatar
stevenn committed
458
459
460
461
462
463
464
  #####################################################
  ##
  ##                DATA TABLE
  ##
  #####################################################
  
  ## Counts Table
465
  output$DataCounts <- DT::renderDataTable(
Stevenn Volant's avatar
Stevenn Volant committed
466
    dataInput()$data$counts, 
stevenn's avatar
stevenn committed
467
    options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
468
                   pageLength = 10,scrollX=TRUE, processing=FALSE
stevenn's avatar
stevenn committed
469
470
    ))
  
471
  ## Counts Table
472
473
474
475
476
477
478
  output$DataVenn<- DT::renderDataTable(#{
    #SelContrast = input$ContrastList_table_FC
    #resDiff = ResDiffAnal()
    #BaseContrast = read.table(namesfile,header=TRUE)
    GetData_venn(input,input$ContrastList_table_FC,read.table(namesfile,header=TRUE),ResDiffAnal())$df.tot,
  #}
   options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
479
                    pageLength = 10,scrollX=TRUE, processing=FALSE
480
  ))
481
482
  
  
stevenn's avatar
stevenn committed
483
  ## Taxonomy table
484
  output$DataTaxo <- DT::renderDataTable(
Stevenn Volant's avatar
Stevenn Volant committed
485
    dataInput()$data$taxo, 
stevenn's avatar
stevenn committed
486
    options = list(lengthMenu = list(c(10, 50, -1), c('10', '50', 'All')),
svolant's avatar
svolant committed
487
                   pageLength = 10,scrollX=TRUE, processing=FALSE
stevenn's avatar
stevenn committed
488
    ))
489
  
stevenn's avatar
stevenn committed
490
  
stevenn's avatar
stevenn committed
491
  ## Tab box for data visualisation
stevenn's avatar
stevenn committed
492
  output$TabBoxData <- renderUI({
493
    tree = dataInputTree()$data
Stevenn Volant's avatar
Stevenn Volant committed
494
    data=dataInput()$data
495
496
497
498
499
500
501
502
503
504
505
    if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0 && !is.null(tree))
    {
      tabBox(width = NULL, selected = "Count table",
             tabPanel("Count table",DT::dataTableOutput("DataCounts")),
             tabPanel("Taxonomy",DT::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)),
             tabPanel("Phylogeny", PhyloTreeMetaROutput('PhyloTreeMetaR'))
      )
    }
    else if(!is.null(data$counts) && !is.null(data$taxo) && nrow(data$counts)>0 && nrow(data$taxo)>0)
stevenn's avatar
stevenn committed
506
    {
507
      tabBox(width = NULL, selected = "Count table",
508
509
             tabPanel("Count table",DT::dataTableOutput("DataCounts")),
             tabPanel("Taxonomy",DT::dataTableOutput("DataTaxo")),
svolant's avatar
svolant committed
510
511
             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
512
      )
stevenn's avatar
stevenn committed
513
    }
stevenn's avatar
stevenn committed
514
    
stevenn's avatar
stevenn committed
515
  })
516
  
517
518
519
520
  output$PhyloTreeMetaR <- renderPhyloTreeMetaR({
    PhyloTreeMetaR(dataInputTree()$treeseq,NULL)
  })
  
svolant's avatar
svolant committed
521
522
523
524
525
526
527
  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
528
      taxo = rbind(taxo,rep(NA,ncol(taxo)))
529
530
531
532
533
534
535
536
537
538
539
540
541
542
      #tmpPercent = round(apply(is.na(taxo),2,table)["FALSE",]/(nrow(taxo)-1)*100,2)
      
      tmp = apply(is.na(taxo),2,table)
      
      if (class(tmp) == "list") {
        tmp2 = sapply(tmp, function (x) {if (! "FALSE" %in% names(x)) {x["FALSE"] = 0} ; return(x["FALSE"])})
      }
      else
      {
        tmp2 = tmp["FALSE",]
      }
      
      tmpPercent = round(tmp2/(nrow(taxo)-1)*100,2)
      
543
      
svolant's avatar
svolant committed
544
      df <- data.frame(Label = colnames(taxo),Value = tmpPercent)
545
      
svolant's avatar
svolant committed
546
      res = gvisGauge(df,options=list(min=0, max=100, greenFrom=80,
547
548
                                      greenTo=100, yellowFrom=60, yellowTo=80,
                                      redFrom=0, redTo=60, width=1200, height=300))
svolant's avatar
svolant committed
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
    }
    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
573
574
575
576
577
  #####################################################
  ##
  ##                TARGET FILE
  ##
  #####################################################
stevenn's avatar
stevenn committed
578
  
579
  
stevenn's avatar
stevenn committed
580
  ## Load target file
581
  observe({ 
stevenn's avatar
stevenn committed
582
583
    
    inFile <- input$fileTarget
Stevenn Volant's avatar
Stevenn Volant committed
584
    counts = dataInput()$data$counts
svolant's avatar
svolant committed
585
    labeled = 0
svolant's avatar
svolant committed
586
    data = NULL
587
    
stevenn's avatar
stevenn committed
588
589
    if (is.null(inFile)) return(NULL)
    
svolant's avatar
svolant committed
590
591
    ## Read the data
    try(read.csv(inFile$datapath,sep=input$septarget,header=TRUE)->data,silent=TRUE)
stevenn's avatar
stevenn committed
592
    
svolant's avatar
svolant committed
593
594
595
596
597
598
    if(!is.null(data))
    {
      data = as.data.frame(data)
      names = colnames(data)
      
      ## Change the rownames
svolant's avatar
svolant committed
599
      if(!TRUE%in%duplicated(data[,1])) rownames(data)=gsub(pattern = "-",replacement = ".",as.character(data[,1]))
svolant's avatar
svolant committed
600
601
602
603
604
      
      ## Keep only the row which are in the count table
      ind = which(rownames(data)%in%colnames(counts))
      data = as.data.frame(data[ind,])
      colnames(data) = names
svolant's avatar
svolant committed
605
606
      
      
svolant's avatar
svolant committed
607
608
609
610
611
612
613
614
615
      ## Replace "-" by "."
      if(ncol(data)>1 && nrow(data)>1){
        ind_num = which(sapply(as.data.frame(data[,-1]),is.numeric)) + 1
        if(length(ind_num)>0){
          data_tmp =cbind( as.data.frame(apply(as.data.frame(data[,-ind_num]),2,gsub,pattern = "-",replacement = ".")),data[,ind_num])
          colnames(data_tmp) = c(colnames(data)[-ind_num],colnames(data)[ind_num])
          data = data_tmp
        }
        if(length(ind_num)==0){data = as.data.frame(apply(data,2,gsub,pattern = "-",replacement = "."))}
616
      }
svolant's avatar
svolant committed
617
      
618
619
620
      values$TargetWorking = as.data.frame(data)
#       ind_sel = Target_selection()
#       if(length(ind))
svolant's avatar
svolant committed
621
622
623
624
625
626
627
628
629
630
631
      # target = as.data.frame(apply(target,2,gsub,pattern = "-",replacement = "."))
      
      #ord = order(rownames(data))
      #data = data[ord,]
      ### A SUPPRIMER 
      #rownames(data) <- colnames(counts)
      
      # Percent annotated
      #     print(ind)
      #     print(colnames(counts))
      #     print(rownames(data))
632
      values$labeled = length(ind)/length(colnames(counts))*100.0
svolant's avatar
svolant committed
633
    }
634
    
635
636
637
638
    # return(list(target = target, labeled=labeled))
  })
  
  
svolant's avatar
svolant committed
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
  # ## Select a folder (for MASQUE)
  # observeEvent(
  #   ignoreNULL = TRUE,
  #   eventExpr = {
  #     input$directory
  #   },
  #   handlerExpr = {
  #     # if (input$directory > 0) {
  #       # condition prevents handler execution on initial app launch
  #       
  #       # launch the directory selection dialog with initial path read from the widget
  #       path = choose.dir(default = readDirectoryInput(session, 'directory'))
  #       
  #       # update the widget value
  #       updateDirectoryInput(session, 'directory', value = path)
  #     # }
  #   }
  # )
  
  
  #############################################################
  ##
  ##                        MASQUE
  ##
  #############################################################
664
  ## Select a folder (for MASQUE)
svolant's avatar
svolant committed
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
  shinyDirChoose(input, 'dir', roots = c(home = '~'),filetypes = c('', 'fastq','gz','fgz'))
  dir <- reactive(input$dir)
  
  output$dirSel <- renderText({ 
    home <- normalizePath("~")
    path_glob = file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
  })
  
  path <- reactive({
    
    home <- normalizePath("~")
    # file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep),"*.pdf")
    
   file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep),"*.f*q*")
  })
  
  
  
  
  # observeEvent(input$submit,{
  #   values$fastq_names_only = NULL
  #   tmp = tempdir()
  #   pathTo = paste(tmp,"Masque_files",sep=.Platform$file.sep)
  # 
  #   if (dir.exists(pathTo))
  #     {
  #       file.remove(list.files(pathTo,full.names =TRUE))
  #     } else dir.create(pathTo)
  # 
  #   file.copy(from=Sys.glob(path()), to=paste(tmp,"Masque_files",sep= .Platform$file.sep))
  # })
  # 
  
  observeEvent(input$submit,{
    CMP = CheckMasque(input, values)
    Error = CMP$Error
svolant's avatar
json    
svolant committed
701
702
    values$num = 1
    isJSONalreadyExist = file.exists(paste(curdir,"www","masque","doing",basename(json_name),sep= .Platform$file.sep))
svolant's avatar
svolant committed
703
    
svolant's avatar
json    
svolant committed
704
    if(is.null(Error) && !isJSONalreadyExist)
svolant's avatar
svolant committed
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
    {
      tmp = tempdir()
      home <- normalizePath("~")
      path_glob = file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
    
    
      ## Paired-end
      if(input$PairedOrNot=="y"){
        cmp = 0
        nfiles = length(values$R1fastQ)+length(values$R2fastQ)
        
        withProgress(message = 'Uploading files...', value = 0, {
          pathToR1 = paste(tmp,"Masque_files_R1",sep=.Platform$file.sep)
          pathToR2 = paste(tmp,"Masque_files_R2",sep=.Platform$file.sep)
          
          if(dir.exists(pathToR1)){file.remove(list.files(pathToR1,full.names =TRUE))} else dir.create(pathToR1)
          if(dir.exists(pathToR2)){file.remove(list.files(pathToR2,full.names =TRUE))} else dir.create(pathToR2)
        
        for(i in values$R1fastQ){file.copy(from=paste(path_glob,i,sep=.Platform$file.sep), to=paste(tmp,"Masque_files_R1",sep= .Platform$file.sep));cmp = cmp +1;incProgress(cmp/nfiles, detail = "Forward fastq files...")}
        for(i in values$R2fastQ){file.copy(from=paste(path_glob,i,sep=.Platform$file.sep), to=paste(tmp,"Masque_files_R2",sep= .Platform$file.sep));cmp = cmp +1;incProgress(cmp/nfiles, detail = "Reverse fastq files...")}
        })
726
        
svolant's avatar
svolant committed
727
      } else{
728
        
svolant's avatar
svolant committed
729
730
731
732
733
734
735
736
737
738
739
        cmp = 0
        nfiles = length(values$fastq_names_only)
        
        withProgress(message = 'Uploading files...', value = 0, {
            
          pathTo = paste(tmp,"Masque_files",sep=.Platform$file.sep)
          
          if(dir.exists(pathTo)){file.remove(list.files(pathTo,full.names =TRUE))} else dir.create(pathTo)
          
          for(i in values$fastq_names_only){file.copy(from=paste(path_glob,i,sep=.Platform$file.sep), to=paste(tmp,"Masque_files",sep= .Platform$file.sep));cmp = cmp +1;incProgress(cmp/nfiles)}
        })
740
      }
svolant's avatar
svolant committed
741
742
      
      ## Create JSON file
svolant's avatar
svolant committed
743
744
745
      withProgress(message = 'Creating JSON file...',{CreateJSON(input,values)})
      if(file.exists(values$json_name)) values$num = 1
      info("Your data have been submitted. You will receive an e-mail once the computation over.\nThis can take few hours")
svolant's avatar
svolant committed
746
747
    }
    
svolant's avatar
svolant committed
748
  },priority = 1)
svolant's avatar
svolant committed
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
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
812
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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
  
  
  
  ## FastQ list
  output$FastQList_out <- renderUI({
    input$LoadFiles
    NullBox = h3(strong("0 FastQ file detected"),style="color:red;  text-align: center")
    res = NullBox
    
    home <- normalizePath("~")
    path_glob = file.path(home, paste(unlist(isolate(dir()$path[-1])), collapse = .Platform$file.sep))
              
    fastq_names = Sys.glob(isolate(path()))
    
    if(length(fastq_names)>0 && input$LoadFiles>0)
    {
      if(is.null(values$fastq_names_only) || length(values$fastq_names_only)==0) values$fastq_names_only = gsub(pattern = path_glob,x = fastq_names,replacement = "")
      # res = box(title="Select your FastQ files",width = 6, status = "primary",
      #                 selectInput("FastQList",label = "List of the fastq files in the selected directory",values$fastq_names_only,multiple =TRUE,selectize=FALSE,size = 6),
      #            actionButton("RemoveFastQbut",'Remove file(s)',icon=icon("remove"))
      # )
      res =list(
                selectInput("FastQList",label = "List of the fastq files in the selected directory",values$fastq_names_only,multiple =TRUE,selectize=FALSE,size = 6),
                actionButton("RemoveFastQbut",'Remove file(s)',icon=icon("remove"))
      )
      
    } else res = NullBox
    
    return(res)
    
  })
  
  
  observeEvent(input$LoadFiles,{
    values$fastq_names_only = NULL
  })


  ## Remove FastQ function
  RemoveFastQ <-eventReactive(input$RemoveFastQbut,{
    
    if(length(input$FastQList)>0)
    {
      ind = which(values$fastq_names_only%in% input$FastQList)
      values$fastq_names_only = values$fastq_names_only[-ind]
      updateSelectInput(session, "FastQList","List of the fastq files in the selected directory",values$fastq_names_only)
    }
  })
  
  
  
  
  
  ## Remove FastQ
  observeEvent(input$RemoveFastQbut,{  
    
    RemoveFastQ()
    if(input$MatchFiles_button>=1) MatchFiles()
    
  },priority=1)
  
  
  
  ## Update R1 and R2 lists
  MatchFiles <-reactive({
    
    if(length(values$fastq_names_only)>0 && input$PairedOrNot=='y')
    {
      indR1 = grep(input$R1files,values$fastq_names_only)
      indR2 = grep(input$R2files,values$fastq_names_only)
      
      ## If some are R1 and R2, removed from both list
      b12 = intersect(indR1,indR2)
      if(length(b12)>0) {indR1 = indR1[-which(indR1%in%b12)]; indR2 = indR2[-which(indR2%in%b12)]}
      
      
      if(length(indR1)>0 && length(indR2)>0){
        
        values$R1fastQ = values$fastq_names_only[indR1]
        values$R2fastQ = values$fastq_names_only[indR2]
        
        ## If some are only R1 or R2
        tmpR1 = gsub(input$R1files,x=values$R1fastQ,""); tmpR2 = gsub(input$R2files,x=values$R2fastQ,"")
        values$R1fastQ = values$R1fastQ[tmpR1%in%tmpR2];values$R2fastQ = values$R2fastQ[tmpR2%in%tmpR1]

        ## Update the files lists
        updateSelectInput(session, "R1filesList","",values$R1fastQ); updateSelectInput(session, "R2filesList","",values$R2fastQ)
      } else{updateSelectInput(session, "R1filesList","","");updateSelectInput(session, "R2filesList","","")}
    } else{updateSelectInput(session, "R1filesList","","");updateSelectInput(session, "R2filesList","","")}
  })
  
  
  observeEvent(input$MatchFiles_button,{  
    
    MatchFiles()
    
  },priority=1)
  
  
  
  ## Remove FastQ function directly from R1, R2
  RemoveFastQ_R1R2 <-eventReactive(input$RemoveFastQbut_R1R2,{
    
    if(length(input$R1filesList)>0)
    {
      ind = which(values$R1fastQ%in% input$R1filesList)
      values$R1fastQ = values$R1fastQ[-ind]
      updateSelectInput(session, "R1filesList","",values$R1fastQ)
    }
    
    if(length(input$R2filesList)>0)
    {
      ind = which(values$R2fastQ%in% input$R2filesList)
      values$R2fastQ = values$R2fastQ[-ind]
      updateSelectInput(session, "R2filesList","",values$R2fastQ)
864
    }
svolant's avatar
svolant committed
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
    
    
  })
  
  ## Remove FastQ from R1, R2
  observeEvent(input$RemoveFastQbut_R1R2,{  
    
    RemoveFastQ_R1R2()
    
  },priority=1)
  
  
  # observe({
  #   CMP = CheckMasque(input, values)
  #   toggleState("submit",condition = is.null(CMP$Error))
  # })
  
  observe({
    toggleState("box-match",condition = (input$PairedOrNot=="y"))
  })
  
  

  output$InfoMasque<- renderUI({
    input$submit
    
    CMP = isolate(CheckMasque(input, values))
   
    if(!is.null(CMP$Error) && input$submit>0) {
      box(title = "Error", status = "danger",width = 12,
svolant's avatar
svolant committed
895
          HTML(CMP$Error)
svolant's avatar
svolant committed
896
897
898
899
900
901
902
903
904
905
906
907
      )
    } else return(NULL)

  })
  
  output$InfoMasqueHowTo<- renderUI({
    input$submit
    
    CMP = isolate(CheckMasque(input, values))
    
    if(!is.null(CMP$HowTo) && input$submit>0) {
      box(title = "How To", status = "success",width = 12,
svolant's avatar
svolant committed
908
          HTML(CMP$HowTo)
svolant's avatar
svolant committed
909
910
911
912
      )
    } else return(NULL)
    
  })
svolant's avatar
svolant committed
913
914
915
916
917
918

  ## plot gauge
  output$gaugeMasque <-renderGauge({
    input$submit
    
    res = NULL;
svolant's avatar
json    
svolant committed
919
    num = round(as.numeric(values$num),1)
svolant's avatar
svolant committed
920
921
922
    
    CMP = isolate(CheckMasque(input, values))
    Error = CMP$Error
svolant's avatar
json    
svolant committed
923
    if(is.null(Error) || num>1) res = gauge(min(num,100), 0,100,symbol = '%',label= "Progress...")
svolant's avatar
svolant committed
924
925
926
927
928
929

    return(res)
  })
  
  
  ## Timer for the gauge
svolant's avatar
svolant committed
930
  Timer <- reactiveTimer(20000)
svolant's avatar
svolant committed
931
932
933
934
935
  
  ## Check masque progress
  observe({

      Timer()
svolant's avatar
json    
svolant committed
936
       # values$num = isolate(values$num)*5
svolant's avatar
svolant committed
937
      progress_file = paste(curdir,"www","masque","doing",paste(basename(file_path_sans_ext(json_name)),"_progress",".txt",sep=""),sep= .Platform$file.sep)
svolant's avatar
svolant committed
938
939
940
941
942
943
944
945
946
947
948
      if(file.exists(progress_file))
      {
        pf = read_lines(progress_file)
        pf = as.numeric(pf)
        if(!is.na(pf)){
          pf = min(pf,100); pf = max(pf,0)
          if(isolate(values$num)<pf) {values$num = pf}
        }
      }
    
  })
svolant's avatar
svolant committed
949
  
svolant's avatar
svolant committed
950
  
svolant's avatar
svolant committed
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
  observe({
    toggleState("checkMail",condition = isValidEmail(input$to))
  })

  
  output$pass_Arg <- renderUI({
    
    pass = toupper(gsub(" ","",input$password))
    passOK = identical(pass,toupper(values$pass))
    
    if(!is.null(input$password) && input$password!="" && !passOK){ 
      removeCssClass(class = 'pwdGREEN', selector = '#password')
      addCssClass(class = 'pwdRED', selector = '#password')
    }
    
    if(!is.null(input$password) && input$password!="" && passOK){  
      removeCssClass(class = 'pwdRED', selector = '#password')
      addCssClass(class = 'pwdGREEN', selector = '#password')
    }
    if(is.null(input$password) || input$password==""){    
      removeCssClass(class = 'pwdRED', selector = '#password')
      removeCssClass(class = 'pwdGREEN', selector = '#password')
    }
svolant's avatar
svolant committed
974
    
svolant's avatar
svolant committed
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
  })
  
  
  textMASQUE <- reactive({
    
    samp = SamplesMasque(input,values)
    home <- normalizePath("~")
    path_glob = file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
    
    
    text = paste("<b>Type of data:</b>",input$DataTypeMasque,"<br /> <br /> ",
                 "<b>Paired-end sequencing:</b>",input$PairedOrNot)
    text = paste(text,"<br /> <br /> ","<b>Number of samples:</b>",length(samp$samples))
    text = paste(text,"<br /> <br /> ","<b>Removed samples:</b>",length(samp$samples_removed))
    text = paste(text,"<br /> <br /> ","<b>Working directory:</b>",path_glob)
    
    if(isValidEmail(input$to)) text = paste(text,"<br /> <br /> ","<b>Email:</b>",input$to)
    
    if(input$HostName!="") text = paste(text,"<br /> <br /> ","<b>Host:</b>",input$HostName)
    if(input$primer && input$PairedOrNot=="n") {text = paste(text,"<br /> <br /> ","<b>Primer:</b>",input$primerSingle)}
    if(input$primer && input$PairedOrNot=="y") {text = paste(text,"<br /> <br /> ","<b>Primer forward:</b>",input$R1primer,
                                                             "<br /> <br /> ","<b>Primer reverse:</b>",input$R2primer)}
    
    return(text)
  })
  
For faster browsing, not all history is shown. View entire blame