-
Notifications
You must be signed in to change notification settings - Fork 17
/
app.R
1371 lines (1282 loc) · 66.5 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
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
664
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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
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
864
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
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
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
####### Install R packages automatically #########
source("install_R_packages.R")
######## Load R packages ###############
library(devtools)
require(usethis)
library(shiny)
library(servr)
library(ggplot2)
library(pheatmap)
library(M3C)
library(RUVSeq)
library(scales)
library(dtwclust)
library(dplyr)
library(DESeq2)
library(ggcorrplot)
library(tibble)
library(ReactomePA)
library(org.Hs.eg.db)
library(org.Mm.eg.db)
library(AnnotationDbi)
library(EnhancedVolcano)
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(TxDb.Mmusculus.UCSC.mm10.knownGene)
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(TxDb.Mmusculus.UCSC.mm9.knownGene)
library(clusterProfiler)
library(cowplot)
library(scater)
library(MAST)
library(Seurat)
library(shinycssloaders)
library(shinyWidgets)
library(hdf5r)
library(enrichR)
#########################
#### Setup enrichR
setEnrichrSite("Enrichr")
websiteLive <- TRUE
dbs <- listEnrichrDbs()
dbs = "KEGG_2016"
################
options(shiny.maxRequestSize=10000*1024^2)
ui <- fluidPage(
tags$head(includeHTML(("GoogleAnalytics.html"))),
setBackgroundColor(
color = c("#F7FBFF", "#2171B5"),
gradient = "linear",
direction = "bottom"
),
titlePanel(h1("Computational Suite For Bioinformaticians and Biologists",style="font-size:20px;color:DarkBlue;font-weight: bold;"),windowTitle = "Computational Suite For Bioinformaticians and Biologists"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Slider for the number of Dataset ----
selectInput("Module",
label = "Module",
choices = c("Normalization", "Basic Stats", "Visualization", "Differential Expression", "Correlation Profiles", "Functional and Pathway Enrichment", "ChIP-ATAC Seq Analysis", "Single Cell RNASeq Analysis"),
selected = "Visualization"),
conditionalPanel(
condition = "input.Module == 'Normalization' || input.Module == 'Visualization' || input.Module == 'Basic Stats' || input.Module == 'Correlation Profiles'",
fileInput("File",
label = "Upload Expression File (Accepted Format: tab delimited text)",
accept = c("text", "text", ".txt"))),
conditionalPanel(
condition = "input.Module == 'Functional and Pathway Enrichment'",
fileInput("GeneList_FP",
label = "Upload a Gene List (Accepted Format: .txt)",
accept = c("text", "text", ".txt"))),
conditionalPanel(
condition = "input.Module == 'Differential Expression'",
fileInput("Counts",
label = "Upload Counts File (Accepted Format: tab delimited text)",
accept = c("text", "text", ".txt"))),
conditionalPanel(
condition = "input.Module == 'Normalization'",
selectInput("Norm",
label = "Choose Normalization",
choices = c("upper quantile", "median", "full", "log2", "zScore", "none"),
selected = "upper quantile")),
conditionalPanel(
condition = "input.Module == 'Differential Expression'",
selectInput("Controls",
label = "Select Control Samples",
choices = NULL,
selected = NULL,
multiple = TRUE)),
conditionalPanel(
condition = "input.Module == 'Differential Expression'",
selectInput("Treatments",
label = "Select Treatment Samples",
choices = NULL,
selected = NULL,
multiple = TRUE)),
conditionalPanel(
condition = "input.Module == 'Differential Expression'",
numericInput("DEFilterLog",
label = "Log2 Fold Change Cutoff",
value = 0.5)),
conditionalPanel(
condition = "input.Module == 'Differential Expression'",
numericInput("DEFilterFDR",
label = "False Discovery Rate (FDR) Cutoff",
value = 0.1)),
conditionalPanel(
condition = "input.Module == 'Correlation Profiles'",
selectInput("Correlation",
label = "Get Correlation among",
choices = c("Genes","Samples"),
selected = "Samples",
multiple = FALSE)),
conditionalPanel(
condition = "input.Module == 'Correlation Profiles' && input.Correlation == 'Genes'",
fileInput("GeneList",
label = "Upload Gene List",
accept = c("text", "text", ".txt"))),
conditionalPanel(
condition = "input.Module == 'Correlation Profiles'",
selectInput("CorrelationMethod",
label = "Select Correlation Method",
choices = c("pearson", "kendall", "spearman"),
selected = "pearson")),
conditionalPanel(
condition = "input.Module == 'Normalization' || input.Module == 'Visualization' || input.Module == 'Differential Expression'",
selectInput("PlotType",
label = "Visualization",
choices = c("pca", "tsne", "heatmap"),
selected = "pca")),
conditionalPanel(
condition = "input.PlotType == 'tsne'",
sliderInput("perplexity",
label = "Choose a perplexity value (If number of samples <= 50 : recommended value 10",
min = 2,
max = 30,
value = 10)),
conditionalPanel(
condition = "input.PlotType == 'tsne'",
fileInput("GroupFile",
label = "Upload a Sample Group File",
accept = c("text", "text", ".txt"))),
conditionalPanel(
condition = "input.PlotType == 'heatmap'",
selectInput("Cluster",
label = "Perform Clustering on",
choices = c("Rows", "Columns", "Rows and Columns", "None"),
selected = "Rows and Columns")),
conditionalPanel(
condition = "input.PlotType == 'heatmap'",
selectInput("Scaling",
label = "Perform Scaling on",
choices = c("row", "column", "none"),
selected = "row")),
conditionalPanel(
condition = "input.PlotType == 'Functional and Pathway Enrichment'",
selectInput("SpeciesUse",
label = "Choose Species",
choices = c("human", "mouse"),
selected = "human")),
conditionalPanel(
condition = "input.Module == 'Functional and Pathway Enrichment'",
selectInput("Species",
label = "Choose Species",
choices = c("human", "mouse"),
selected = "human")),
conditionalPanel(
condition = "input.Module == 'ChIP-ATAC Seq Analysis'",
fileInput("PeakFile",
label = "Upload Peak File (Peak file in .narrowPeak, .broadPeak or .bed and in .gz format are accepted",
accept = c(".narrowPeak", ".broadPeak", ".bed", ".narrowPeak.gz", ".broadPeak.gz", ".bed.gz"))),
conditionalPanel(
condition = "input.Module == 'ChIP-ATAC Seq Analysis'",
selectInput("SpeciesChIP",
label = "Choose Species and genome version",
choices = c("human (hg19)", "human (hg38)", "mouse (mm10)", "mouse (mm9)"),
selected = "human (hg19)")),
conditionalPanel(
condition = "input.Module == 'ChIP-ATAC Seq Analysis'",
selectInput("PlotChIP",
label = "Select Analysis for Peaks",
choices = c("Coverage Plot (Visualize coverage of peaks across chromosomes)", "Average Profile of peaks binding to TSS regions", "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)"),
selected = "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)")),
conditionalPanel(
condition = "input.Module == 'ChIP-ATAC Seq Analysis' && input.PlotChIP == 'Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)'",
selectInput("PlotAnnotation",
label = "Select Visualization",
choices = c("Peak genomic annotation", "Functional enrichemnt"),
selected = "Peak genomic annotation")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis'",
selectInput("scInput",
label = "Select Data Input Type",
choices = c("Raw Counts Matrix", "H5", "Seurat Object"),
selected = "Raw Counts Matrix")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix'",
fileInput("scCounts",
label = "Upload Counts File (Accepted Format: tab delimited text)",
accept = ".txt")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'H5'",
fileInput("scH5",
label = "Upload H5 output from Cellranger or other toolkits (Accepted Format: H5)",
accept = ".h5")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Seurat Object'",
fileInput("scRobj",
label = "Upload .rds file",
accept = ".rds")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
selectInput("Species_singlecell",
label = "Select Species",
choices = c("human", "mouse"),
selected = "human")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
numericInput("scMinCells",
label = "Input Minimum number of cells to express all genes",
value = 3,
min = 0,
max = 200000),
verbatimTextOutput("3")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
numericInput("scMinFeatures",
label = "Input Minimum number of features all cells should express",
value = 100,
min = 0,
max = 30000),
verbatimTextOutput("100")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
selectInput("scNormalization",
label = "Select Normalization Method",
choices = c("LogNormalize", "SCTransform"),
selected = "LogNormalize")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
selectInput("scReduction",
label = "Select Dimension Reduction",
choices = c("umap", "tsne"),
selected = "umap")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
selectInput("scDETest",
label = "Select Differential Expression Test (Please see: some of these tests increase run time significantly)",
choices = c("wilcox", "bimod", "roc", "t", "negbinom", "poisson", "LR", "MAST", "DESeq2"),
selected = "wilcox")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
selectInput("scCellCycle",
label = "Regress Cell Cycle Effect",
choices = c("Yes", "No"),
selected = "Yes")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
numericInput("VarFeatures",
label = "Input Number of Variable Features to use",
value = 2000,
min = 100,
max = 10000),
verbatimTextOutput("2000")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
numericInput("scDims",
label = "Input Number of Dimensions to use",
value = 10,
min = 1,
max = 100),
verbatimTextOutput("10")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
numericInput("scRes",
label = "Input resolution for clustering",
value = 0.5,
min = 0,
max = 10),
verbatimTextOutput("0.5")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5' || input.scInput == 'Seurat Object'",
selectInput("scVisualization",
label = "Select Single Cell Visualization",
choices = c("Gene Expression Plot", "Dimension Reduction Plot", "Violin Plot", "DotPlot", "QC Metrics Plot", "Cell Cycle Phase", "Top10 Markers Heatmap"),
selected = "Dimension Reduction Plot")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Seurat Object'",
selectInput("MarkerCalculate",
label = "Find Differential Markers per Cluster (Please set to TRUE if interested in Markers Heatmap)",
choices = c("TRUE", "FALSE"),
selected = "FALSE")),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5' || input.scInput == 'Seurat Object' && input.scVisualization == 'Dimension Reduction Plot' || input.scVisualization == 'Gene Expression Plot' || input.scVisualization == 'Violin Plot' || input.scVisualization == 'DotPlot'",
selectInput("ColorCells",
label = "Color/Group Cells By",
choices = NULL,
selected = NULL)),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5' || input.scInput == 'Seurat Object' && input.scVisualization == 'Gene Expression Plot' || input.scVisualization == 'Violin Plot' || input.scVisualization == 'DotPlot'",
selectInput("scGene",
label = "Select Genes",
choices = NULL,
selectize = TRUE,
selected = NULL,
multiple = TRUE)),
conditionalPanel(
condition = "input.Module == 'Single Cell RNASeq Analysis' && input.scInput == 'Raw Counts Matrix' || input.scInput == 'H5'",
downloadButton('scRNAObjectDownload', 'Download scRNA-Seq Seurat v3.0 Object'))
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("About", fluidRow(
p(strong("Computational Suite for Bioinformaticians and Biologists (CSBB)"), "is a RShiny application developed with an intention to empower researchers from wet and dry lab to perform downstream Bioinformatics analysis. CSBB powered by RShiny is packed with 8 modules", strong("Visualization, Normalization, Basic Stats, Differential Expression, Correlation Profiles, Function/Pathway Enrichment, ChIP/ATAC Seq and Single Cell RNA-Seq analysis."), " These modules are designed in order to help researchers design a hypothesis or answer research questions with little or no expertise in Bioinformatics. CSBB is also available as a command line application and has Next generation sequencing data processing capabilities. New modules and functionalities will be added periodically.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("CSBB RShiny is avaibale on", a("GitHub", href = "https://github.com/praneet1988/CSBB-Shiny", target = "_blank"), ", if interested in hosting on your own servers.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Single Cell Transcriptomics Analysis Using CSBB-Shiny Tutorial Video"), a("YouTube", href = "https://youtu.be/s8Q4o1e-f1E", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("Please post issues, suggestions and improvements using", a("Issues/suggestions", href = "https://github.com/praneet1988/CSBB-Shiny", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("To use CSBB command line application please access", a("CSBB CMD", href = "https://github.com/praneet1988/Computational-Suite-For-Bioinformaticians-and-Biologists", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("If using CSBB RShiny in your research please cite the GitHub page", a("Cite", href = "https://github.com/praneet1988/CSBB-Shiny", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("Developed and maintained by Praneet Chaturvedi. To view other tools and contributions please visit", a("GitHub", href = "https://github.com/praneet1988/", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px")), imageOutput('Pipeline')),
tabPanel("Result Window", downloadButton('downloadResult', 'Download Results'), shinycssloaders::withSpinner(DT::dataTableOutput("result"), size = 3)),
tabPanel("Visualization Window", downloadButton('downloadPlot', 'Save Plot'), shinycssloaders::withSpinner(plotOutput("Plot"), size = 3)),
tabPanel("Getting Started", fluidRow(
p(strong("CSBB"), "is easy to use and is packed with some very powerful modules to help you analyze your data. Results generated from the modules are loaded on the Result window whereas the Visualization plots are displyed on Visualization windows. Now let's see what each module helps with and what are the options users can explore.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Tutorial Video"), a("YouTube", href = "https://youtu.be/c0P7TMu_IyY", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Single Cell Transcriptomics Analysis Using CSBB-Shiny Tutorial Video"), a("YouTube", href = "https://youtu.be/s8Q4o1e-f1E", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Normalization module"), "can help users perform normalization on their data using following methods: upper quantile, median, full, log2 and zScore. Normalized data can also visualized using Principal component analysis (pca), t-stochastic neighbor embedding (tSNE) and heatmap. For tSNE visualization a group file is required. Group file should provide group name for each sample in the data. PCA is linear dimension reduction technique and tSNE is non-linear dimension reduction technique.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Visualization module"), "lets user visualize their data using pca, tSNE and heatmap", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Basic Stats module"), "is very helpful for estimating mean, median, standard deviation, median adjusted deviation, sum, min and max expression per gene in the expression matrix.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Differential Expression module"), "helps user perform differential expression analysis on raw counts of genes across samples using RUVSeq. Please cite RUVSeq if using Differential Expression module in your research using", a("Cite", href = "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4404308/", target = "_blank"), ". Differentially expressed (DE) genes are reported in result tab and results can be filtered using logFC and FDR filters. Users can visualize their data based on DE genes using pca, tSNE, heatmap, volcano plots and perform functional/pathway enrichemnt on DE genes", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Correlation Profiles module"), "is developed to help users analyze Correlation among the samples in the data or see how a gene set is correlated based on the expression across samples", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Functional/Pathway Enrichment module"), "is designed to compute and visualize top enriched functions and pathways based on user provided gene list. ReactomePA R package is used to perform and visualize enrichment. Please cite ReactomePA when using the module in your research", a("Cite", href = "https://pubs.rsc.org/en/content/articlelanding/2016/MB/C5MB00663E#!divAbstract", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("ChIP-ATAC Seq Analysis module"), "is designed to perform downstream analysis with peaks like obtaining coverage plot across chromosomes, quantifying profile of peaks binding to transcription start site (TSS) and performing peak annotation. TSS is defined as +- 3kb regions of flanking sequences of the TSS sites. ChIPseeker package in R is used for performing downsream analysis on peaks. Please cite ChIPseeker when using this module.", a("Cite", href = "https://academic.oup.com/bioinformatics/article/31/14/2382/255379", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Single Cell RNASeq Analysis module"), "is designed to perform single cell RNA-Seq analysis. CSBB-Shiny uses Seurat", a("Cite", href = "https://www.nature.com/articles/nbt.4096", target = "_blank"), "which has been one of most cited and widely used analysis toolkit for analyzing single cell RNA-Seq data. The purpose of providing a module for analyzing scRNA data is to enable users with feasible and powerful front-end to seurat. Please check Seurat Vignettes to undertand the steps behind analyzing the analysis framework. In CSBB-Shiny a default filtering on number of RNA features and percentage mitochondrial expression is used. The filter is set to 95th quantile for filtering cells. Please check out the video tutorial to undertand the specifics and parameters. Users can input raw counts matrix, H5 output from cellranger or a processed Seurat v3.0 object. Please cite Seurat when using this module for your research or grants. Please see that CSBB allows users to download R Objects after processing and the object name is set seurat.object.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p("Please access sample files for each module using", a("Sample Files", href = "https://github.com/praneet1988/CSBB-Shiny", target = "_blank"), style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"))),
tabPanel("What's New in CSBB Shiny", fluidRow(
p(strong("Version 1.5 Log:"), "Added new features to Single Cell Analysis Module like option to use it as a cell browser. Upload your own processed data using Seurat (v[>3.0]) in rds format to generate visualization plots, get markers, download plots etc. CSBB Shiny will be updated periodically. Stay Tuned.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Version 1.4 Log:"), "Added new features to Single Cell Analysis Module like option to regress cell-cycle effect, choose between LogNormalize or SCTransform, choose from multiple differential test for marker prediction, generate QC plot and lastly generate dimension plot with cell cycle phase. Users can input raw counts, H5 output from cellranger or a processed R object. CSBB-Shiny uses Seurat (a powerful scRNA-Seq analysis toolkit) to help users analyze scRNA-Seq datasets. CSBB Shiny will be updated periodically. Stay Tuned.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Version 1.3 Log:"), "Presenting Single cell RNA-Seq analysis module for analyzing scRNA-Seq datasets. Users can input raw counts, H5 output from cellranger or a processed R object. CSBB-Shiny uses Seurat (a powerful scRNA-Seq analysis toolkit) to help users analyze scRNA-Seq datasets. CSBB Shiny will be updated periodically. Stay Tuned.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Version 1.2 Log:"), "Dusted off some bugs in ChIP-ATAC Seq Analysis Module, thereby enhancing user experience. Bugs removed include: plots not being saved or not being refereshed. Removed the option to create tag density heatmap. Replaced pie chart with bar plot for visualizing peak region enrichment. CSBB Shiny will be updated periodically. Stay Tuned.", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Version 1.1 Log:"), "Brushed off some known bugs which entered the system and added new Module ChIP-ATAC Seq Analysis for users. CSBB Shiny will be updated periodically. Some known bugs kicked out include result files and plots file naming, threshold changes, text changes", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px"),
p(strong("Version 1.0 Log:"), "CSBB powered by Shiny has 6 modules and is built with an idea to empower researchers in performing bioinformatics analysis with little or no bioinformatics expertise", style="text-align:justify;color:black;background-color:white;padding:20px;border-radius:10px;font-size:15px")))
)
)
)
)
server <- function(input, output, session) {
output$Pipeline <- renderImage({
list(src = 'www/CSBB.png',
contentType = 'image/png',
width = 1200,
height = 1200,
alt = "This is alternate text")
}, deleteFile = F)
observe({
if(input$Module == "Differential Expression"){
inFile <- input$Counts
if (is.null(inFile))
return(NULL)
data <- as.matrix(read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=TRUE))
samples <- colnames(data)
samples <- data.frame(samples)
samples <- samples$samples
updateSelectInput(session, "Controls",
label = "Select Control Samples",
choices = samples)
}
})
observe({
if(input$Module == "Differential Expression"){
inFile <- input$Counts
if (is.null(inFile))
return(NULL)
data <- as.matrix(read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=TRUE))
samples <- colnames(data)
samples <- data.frame(samples)
samples <- samples$samples
updateSelectInput(session, "Treatments",
label = "Select Treatment Samples",
choices = samples)
}
})
observe({
if(input$Module == "Differential Expression"){
updateSelectInput(session, "PlotType",
label = "Visualization",
choices = c("pca", "tsne", "heatmap", "Functional and Pathway Enrichment", "Volcano Plots"),
selected = "heatmap")
}
})
scData <- reactive({
if(input$Module == "Single Cell RNASeq Analysis"){
if(input$scInput == "Raw Counts Matrix"){
inFile <- input$scCounts
if (is.null(inFile))
return(NULL)
data <- c()
data <- readSparseCounts(inFile$datapath, sep = "\t", row.names = TRUE, col.names = TRUE)
return(data)
}
else if(input$scInput == "H5"){
inFile <- input$scH5
if (is.null(inFile))
return(NULL)
data <- c()
data <- Read10X_h5(inFile$datapath, use.names = TRUE, unique.features = TRUE)
return(data)
}
else if(input$scInput == "Seurat Object"){
inFile <- input$scRobj
if (is.null(inFile))
return(NULL)
seurat.object = readRDS(inFile$datapath)
return(seurat.object)
}
}
})
observe({
if(input$Module == "Single Cell RNASeq Analysis"){
if(input$scInput == "Raw Counts Matrix"){
inFile <- input$scCounts
if (is.null(inFile))
return(NULL)
data <- c()
data <- scData()
genes <- rownames(data)
genes <- data.frame(genes)
genes <- genes$genes
updateSelectizeInput(session, "scGene",
label = "Select Genes",
choices = genes, server = TRUE)
}
else if(input$scInput == "H5"){
inFile <- input$scH5
if (is.null(inFile))
return(NULL)
data <- c()
data <- scData()
genes <- rownames(data)
genes <- data.frame(genes)
genes <- genes$genes
updateSelectizeInput(session, "scGene",
label = "Select Genes",
choices = genes, server = TRUE)
}
else if(input$scInput == "Seurat Object"){
inFile <- input$scRobj
if (is.null(inFile))
return(NULL)
seurat.object = scData()
DefaultAssay(seurat.object) = "RNA"
genes <- rownames(seurat.object)
genes <- data.frame(genes)
genes <- genes$genes
updateSelectizeInput(session, "scGene",
label = "Select Genes",
choices = genes, server = TRUE)
updateSelectInput(session, "ColorCells",
label = "Color Cells By",
choices = colnames([email protected]))
}
}
})
NormalizationData <- reactive({
if(input$Module == "Normalization"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
if(input$Norm == "upper quantile"){
source("app_bin/UQ_Norm.r", local = TRUE)
return(UData)
}
else if(input$Norm == "median"){
source("app_bin/Median_Norm.r", local = TRUE)
return(UData)
}
else if(input$Norm == "full"){
source("app_bin/Full_Norm.r", local = TRUE)
return(UData)
}
else if(input$Norm == "none"){
source("app_bin/No_Norm.r", local = TRUE)
return(UData)
}
else if(input$Norm == "log2"){
source("app_bin/log2_Norm.r", local = TRUE)
return(UData)
}
else if(input$Norm == "zScore"){
source("app_bin/Zscore_Norm.r", local = TRUE)
return(UData)
}
}
})
BasicStatsData <- reactive({
if(input$Module == "Basic Stats"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
source("app_bin/BasicStats.r", local = TRUE)
return(output)
}
})
VisualizationData <- reactive({
if(input$Module == "Visualization"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
data <- read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=F)
return(data)
}
})
DEData <- reactive({
if(input$Module == "Differential Expression"){
inFile <- input$Counts
if (is.null(inFile))
return(NULL)
data <- as.matrix(read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=TRUE))
data <- data.frame(data)
samplelist <- c(input$Controls, input$Treatments)
data_temp <- data[,samplelist]
data_temp <- as.matrix(data_temp)
lengthcontrol <- length(input$Controls)
lengthtreatment <- length(input$Treatments)
if((lengthcontrol == 1)&(lengthtreatment == 1)){
source("app_bin/RUVseq_NoReps.r", local = TRUE, echo=FALSE)
DEresult_filter <- DEresult %>% rownames_to_column('gene') %>% filter(logFC >= input$DEFilterLog | logFC <= -1*(input$DEFilterLog), FDR <= input$DEFilterFDR) %>% column_to_rownames('gene')
if(is.null(DEresult_filter))
return(NULL)
return(DEresult_filter)
}
else if((lengthcontrol > 1)&(lengthtreatment >= 1)){
cutoff <- round((lengthcontrol + lengthtreatment)/2)
source("app_bin/RUVseq_replicates.r", local = TRUE, echo=FALSE)
DEresult_filter <- DEresult %>% rownames_to_column('gene') %>% filter(logFC >= input$DEFilterLog | logFC <= -1*(input$DEFilterLog), FDR <= input$DEFilterFDR) %>% column_to_rownames('gene')
if(is.null(DEresult_filter))
return(NULL)
return(DEresult_filter)
}
else if((lengthcontrol >= 1)&(lengthtreatment > 1)){
cutoff <- round((lengthcontrol + lengthtreatment)/2)
source("app_bin/RUVseq_replicates.r", local = TRUE, echo=FALSE)
DEresult_filter <- DEresult %>% rownames_to_column('gene') %>% filter(logFC >= input$DEFilterLog | logFC <= -1*(input$DEFilterLog), FDR <= input$DEFilterFDR) %>% column_to_rownames('gene')
if(is.null(DEresult_filter))
return(NULL)
return(DEresult_filter)
}
else if((lengthcontrol == 0)&(lengthtreatment == 0)){
return(NULL)
}
}
})
CorrelationData <- reactive({
if(input$Module == "Correlation Profiles"){
if(input$Correlation == "Samples"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
data <- as.matrix(read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=F))
cormat <- cor(data, method=input$CorrelationMethod, use = "na.or.complete")
return(cormat)
}
else if(input$Correlation == "Genes"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
data <- as.matrix(read.table(inFile$datapath, sep="\t", header=T, row.names=1, check.names=F))
Genes_List <- input$GeneList
if (is.null(Genes_List))
return(NULL)
GenesUpload <- as.matrix(read.table(Genes_List$datapath, sep="\n", header=F))
GenesUpload <- data.frame(GenesUpload)
GenesUpload <- unique(GenesUpload$V1)
datause <- subset(data, rownames(data) %in% GenesUpload)
datause <- t(datause)
cormat <- cor(datause, method=input$CorrelationMethod, use = "na.or.complete")
return(cormat)
}
}
})
FPEnrichmentData <- reactive({
if(input$Module == "Functional and Pathway Enrichment"){
if(input$Species == "human"){
inFile <- input$GeneList_FP
if (is.null(inFile))
return(NULL)
GenesUpload <- as.matrix(read.table(inFile$datapath, sep="\n", header=F))
GenesUpload <- data.frame(GenesUpload)
GenesUpload <- unique(GenesUpload$V1)
#genes_ids <- mapIds(org.Hs.eg.db, as.character(GenesUpload), 'ENTREZID', 'SYMBOL')
enrichemnt <- enrichr(GenesUpload, dbs)
return(enrichemnt)
}
else if(input$Species == "mouse"){
inFile <- input$GeneList_FP
if (is.null(inFile))
return(NULL)
GenesUpload <- as.matrix(read.table(inFile$datapath, sep="\n", header=F))
GenesUpload <- data.frame(GenesUpload)
GenesUpload <- unique(GenesUpload$V1)
#genes_ids <- mapIds(org.Mm.eg.db, as.character(GenesUpload), 'ENTREZID', 'SYMBOL')
enrichemnt <- enrichr(GenesUpload, dbs)
return(enrichemnt)
}
}
})
CHIPData <- reactive({
if(input$Module == "ChIP-ATAC Seq Analysis"){
if(input$SpeciesChIP == "human (hg19)"){
if((input$PlotChIP == "Coverage Plot (Visualize coverage of peaks across chromosomes)")|(input$PlotChIP == "Average Profile of peaks binding to TSS regions")){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
return(peak)
}
else if(input$PlotChIP == "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)"){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
txdb = TxDb.Hsapiens.UCSC.hg19.knownGene
if(input$PlotAnnotation == "Peak genomic annotation"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Hs.eg.db")
return(peakAnno)
}
else if(input$PlotAnnotation == "Functional enrichemnt"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Hs.eg.db")
pathway <- enrichPathway(as.data.frame(peakAnno)$geneId, pvalueCutoff = 0.05, readable=T, organism = "human")
return(pathway)
}
}
}
else if(input$SpeciesChIP == "human (hg38)"){
if((input$PlotChIP == "Coverage Plot (Visualize coverage of peaks across chromosomes)")|(input$PlotChIP == "Average Profile of peaks binding to TSS regions")){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
return(peak)
}
else if(input$PlotChIP == "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)"){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
txdb = TxDb.Hsapiens.UCSC.hg38.knownGene
if(input$PlotAnnotation == "Peak genomic annotation"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Hs.eg.db")
return(peakAnno)
}
else if(input$PlotAnnotation == "Functional enrichemnt"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Hs.eg.db")
pathway <- enrichPathway(as.data.frame(peakAnno)$geneId, pvalueCutoff = 0.05, readable=T, organism = "human")
return(pathway)
}
}
}
else if(input$SpeciesChIP == "mouse (mm10)"){
if((input$PlotChIP == "Coverage Plot (Visualize coverage of peaks across chromosomes)")|(input$PlotChIP == "Average Profile of peaks binding to TSS regions")){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
return(peak)
}
else if(input$PlotChIP == "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)"){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
txdb = TxDb.Mmusculus.UCSC.mm10.knownGene
if(input$PlotAnnotation == "Peak genomic annotation"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Mm.eg.db")
return(peakAnno)
}
else if(input$PlotAnnotation == "Functional enrichemnt"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Mm.eg.db")
pathway <- enrichPathway(as.data.frame(peakAnno)$geneId, pvalueCutoff = 0.05, readable=T, organism = "mouse")
return(pathway)
}
}
}
else if(input$SpeciesChIP == "mouse (mm9)"){
if((input$PlotChIP == "Coverage Plot (Visualize coverage of peaks across chromosomes)")|(input$PlotChIP == "Average Profile of peaks binding to TSS regions")){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
return(peak)
}
else if(input$PlotChIP == "Peak Annotation (finding closest genes, postion of Peaks wrt TSS etc.)"){
inFile <- input$PeakFile
if (is.null(inFile))
return(NULL)
peak <- readPeakFile(inFile$datapath)
txdb = TxDb.Mmusculus.UCSC.mm9.knownGene
if(input$PlotAnnotation == "Peak genomic annotation"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Mm.eg.db")
return(peakAnno)
}
else if(input$PlotAnnotation == "Functional enrichemnt"){
peakAnno <- annotatePeak(peak, tssRegion=c(-3000, 3000), TxDb=txdb, annoDb="org.Mm.eg.db")
pathway <- enrichPathway(as.data.frame(peakAnno)$geneId, pvalueCutoff = 0.05, readable=T, organism = "mouse")
return(pathway)
}
}
}
}
})
SingleCell <- reactive({
if(input$Module == "Single Cell RNASeq Analysis"){
if((input$scInput == "Raw Counts Matrix")||(input$scInput == "H5")){
data <- c()
data <- scData()
if(is.null(data))
return(NULL)
seurat.object <- CreateSeuratObject(counts = data, project = "scAnalysis", min.cells = input$scMinCells, min.features = input$scMinFeatures)
if(input$Species_singlecell == "human"){
seurat.object[["percent.mt"]] <- PercentageFeatureSet(seurat.object, pattern = "^MT-")
cc.genes <- readLines(con = "data/CellCycle_Human.txt")
}
else if(input$Species_singlecell == "mouse"){
seurat.object[["percent.mt"]] <- PercentageFeatureSet(seurat.object, pattern = "^mt-")
cc.genes <- readLines(con = "data/CellCycle_Mouse.txt")
}
nFeature_RNA_cutoff <- quantile([email protected]$nFeature_RNA, .95)
nFeature_RNA_cutoff <- data.frame(nFeature_RNA_cutoff)
percentMT_cutoff <- quantile([email protected]$percent.mt, .95)
percentMT_cutoff <- data.frame(percentMT_cutoff)
if(percentMT_cutoff$percentMT_cutoff == 0){
seurat.object <- subset(seurat.object, subset = nFeature_RNA > 0 & nFeature_RNA < nFeature_RNA_cutoff$nFeature_RNA_cutoff & percent.mt < 1)
}
else if(percentMT_cutoff$percentMT_cutoff > 0){
seurat.object <- subset(seurat.object, subset = nFeature_RNA > 0 & nFeature_RNA < nFeature_RNA_cutoff$nFeature_RNA_cutoff & percent.mt < percentMT_cutoff$percentMT_cutoff)
}
if(input$scNormalization == 'LogNormalize'){
seurat.object <- NormalizeData(seurat.object)
seurat.object <- FindVariableFeatures(seurat.object, selection.method = "vst", nfeatures = input$VarFeatures)
if(input$scCellCycle == "Yes"){
s.genes <- cc.genes[1:43]
g2m.genes <- cc.genes[44:97]
seurat.object <- CellCycleScoring(object = seurat.object, s.features = s.genes, g2m.features = g2m.genes, set.ident = FALSE)
seurat.object <- ScaleData(seurat.object, vars.to.regress = c("percent.mt", "CC.Difference"))
}
else if(input$scCellCycle == "No"){
seurat.object <- ScaleData(seurat.object, vars.to.regress = "percent.mt")
}
seurat.object <- RunPCA(seurat.object)
seurat.object <- FindNeighbors(seurat.object, dims = 1:input$scDims)
seurat.object <- FindClusters(seurat.object, resolution = input$scRes)
if(input$scReduction == "umap"){
seurat.object <- RunUMAP(seurat.object, dims = 1:input$scDims)
}
else if(input$scReduction == "tsne"){
seurat.object <- RunTSNE(seurat.object, dims = 1:input$scDims)
}
return(seurat.object)
}
else if(input$scNormalization == 'SCTransform'){
if(input$scCellCycle == "Yes"){
s.genes <- cc.genes[1:43]
g2m.genes <- cc.genes[44:97]
seurat.object <- SCTransform(seurat.object, variable.features.n = input$VarFeatures)
seurat.object <- CellCycleScoring(object = seurat.object, s.features = s.genes, g2m.features = g2m.genes, set.ident = FALSE)
seurat.object <- SCTransform(seurat.object, vars.to.regress = c("percent.mt", "CC.Difference"), variable.features.n = input$VarFeatures)
}
else if(input$scCellCycle == "No"){
seurat.object <- SCTransform(seurat.object, vars.to.regress = "percent.mt", variable.features.n = input$VarFeatures)
}
seurat.object <- RunPCA(seurat.object)
seurat.object <- FindNeighbors(seurat.object, dims = 1:input$scDims)
seurat.object <- FindClusters(seurat.object, resolution = input$scRes)
if(input$scReduction == "umap"){
seurat.object <- RunUMAP(seurat.object, dims = 1:input$scDims)
}
else if(input$scReduction == "tsne"){
seurat.object <- RunTSNE(seurat.object, dims = 1:input$scDims)
}
return(seurat.object)
}
}
else if(input$scInput == "Seurat Object"){
inFile <- input$scRobj
if(is.null(inFile))
return(NULL)
seurat.object = scData()
DefaultAssay(seurat.object) = "RNA"
Idents(seurat.object) <- [email protected]$seurat_clusters
return(seurat.object)
}
}
})
observe({
if(input$Module == "Single Cell RNASeq Analysis"){
if(input$scInput == "Raw Counts Matrix"){
seurat.object = SingleCell()
if(is.null(seurat.object))
return(NULL)
updateSelectInput(session, "ColorCells",
label = "Color Cells By",
choices = colnames([email protected]))
}
else if(input$scInput == "H5"){
seurat.object = SingleCell()
if(is.null(seurat.object))
return(NULL)
updateSelectInput(session, "ColorCells",
label = "Color Cells By",
choices = colnames([email protected]))
}
}
})
SingleCellMarkers <- reactive({
seurat.object <- SingleCell()
if(is.null(seurat.object))
return(NULL)
if((input$scInput == "Seurat Object") && (input$MarkerCalculate == 'TRUE')) {
markers_clusters <- FindAllMarkers(seurat.object, max.cells.per.ident = 100, min.pct = 0.25)
return(markers_clusters)
}
if((input$scInput == "Seurat Object") && (input$MarkerCalculate == 'FALSE')) {
markers_clusters = NULL
return(markers_clusters)
}
if((input$scInput == "Raw Counts Matrix")||(input$scInput == "H5")) {
markers_clusters <- FindAllMarkers(seurat.object, test.use = input$scDETest, min.pct = 0.25)
return(markers_clusters)
}
})
PCAplot <- reactive({
inFile <- input$File
if (is.null(inFile))
return(NULL)
data <- c()
if(input$Module == "Normalization"){
data <- as.matrix(NormalizationData())
}
else if(input$Module == "Visualization"){
data <- as.matrix(VisualizationData())
}
data <- data[apply(data[,-1], 1, function(x) !all(x==0)),]
data.t <- t(data)
pca <- prcomp(data.t, center=T, scale. = T)
pc1 <- round(pca$sdev[1]^2/sum(pca$sdev^2)*100,2)
pc2 <- round(pca$sdev[2]^2/sum(pca$sdev^2)*100,2)
PC1_use <- paste0("PC1", "(", pc1, "%)")
PC2_use <- paste0("PC2", "(", pc2, "%)")
Samples_temp <- rownames(data.t)
Samples <- factor(Samples_temp)
scores <- data.frame(Samples_temp, pca$x[,1:3])
MIN_X <- min(scores$PC1)
Max_X <- max(scores$PC1)
header <- "Principal Component Analysis"
qplot(x=PC1, y=PC2, data=scores, colour=Samples, xlim=c(MIN_X-75,Max_X+75)) + xlab(PC1_use) + ylab(PC2_use) + geom_point(shape=1) + geom_text(aes(label=Samples_temp), hjust=0, vjust=0) + scale_size_area() + theme(axis.text = element_text(size = 14),axis.line.x = element_line(colour = "black"),axis.line.y = element_line(colour = "black"),legend.key = element_rect(fill = "white"),legend.background = element_rect(fill = "white"),panel.grid.major = element_line(),panel.grid.minor = element_blank(),panel.background = element_rect(fill = "white")) + ggtitle(header) + guides(colour = guide_legend(ncol = 1, override.aes = list(size = 5)))
})
TSNEplot <- reactive({
inFile <- input$File
if (is.null(inFile))
return(NULL)
inGroupFile <- input$GroupFile
if (is.null(inGroupFile))
return(NULL)
data <- c()
if(input$Module == "Normalization"){
data <- as.matrix(NormalizationData())
}
else if(input$Module == "Visualization"){
data <- as.matrix(VisualizationData())
}
Group <- as.matrix(read.table(inGroupFile$datapath, header=T, sep="\t", row.names=1, check.names=F))
Group <- data.frame(Group)
GroupUse <- as.factor(Group$group)
tsne(data, labels=GroupUse, perplex=input$perplexity) + xlab("tSNE_1") + ylab("tSNE_2") + guides(colour = guide_legend(ncol = 1, override.aes = list(size = 5)))
})
HEATMAPplot <- reactive({
inFile <- input$File
if (is.null(inFile))
return(NULL)
data <- c()
if(input$Module == "Normalization"){
data <- as.matrix(NormalizationData())
}
else if(input$Module == "Visualization"){
data <- as.matrix(VisualizationData())
}
data <- data[apply(data, MARGIN = 1, FUN = function(x) sd(x) != 0),]
if(input$Cluster == "Rows"){
pheatmap(data, scale=input$Scaling, cluster_rows=TRUE, cluster_cols=FALSE, main="Heatmap", border_color = "NA")
}
else if(input$Cluster == "Columns"){
pheatmap(data, scale=input$Scaling, cluster_rows=FALSE, cluster_cols=TRUE, main="Heatmap", border_color = "NA")
}
else if(input$Cluster == "Rows and Columns"){
pheatmap(data, scale=input$Scaling, cluster_rows=TRUE, cluster_cols=TRUE, main="Heatmap", border_color = "NA")
}
else if(input$Cluster == "None"){
pheatmap(data, scale=input$Scaling, cluster_rows=FALSE, cluster_cols=FALSE, main="Heatmap", border_color = "NA")
}
})
CorrelationPlot <- reactive({
if(input$Correlation == "Samples"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
titleuse <- paste0("Displaying Correlation Plot of ", input$Correlation)
data <- CorrelationData()
ggcorrplot(data, hc.order = TRUE, outline.color = "white", ggtheme = ggplot2::theme_gray, colors = c("#6D9EC1", "white", "#E46726"), legend.title = "Correlation") + labs(title = titleuse)
}
else if(input$Correlation == "Genes"){
inFile <- input$File
if (is.null(inFile))
return(NULL)
Genes_List <- input$GeneList
if (is.null(Genes_List))
return(NULL)
titleuse <- paste0("Displaying Correlation Plot of ", input$Correlation)
data <- CorrelationData()
ggcorrplot(data, hc.order = TRUE, outline.color = "white", ggtheme = ggplot2::theme_gray, colors = c("#6D9EC1", "white", "#E46726"), legend.title = "Correlation") + labs(title = titleuse)