-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
3465 lines (2667 loc) · 153 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
#LoadPackage
library(tidyverse)
library(shiny)
library(rsconnect)
library(plotly)
library(shinythemes)
library(ggpubr)
library(DT)
library(flextable)
library(shinydashboard)
library(shinyWidgets)
library(data.table)
library(ggsci)
library(rmarkdown)
library(RColorBrewer)
library(randomcoloR)
library(ComplexHeatmap)
library(genekitr)
library(PhenoExam)
library(ggrepel)
library(ggh4x)
library(VennDiagram)
library(rstatix)
library(Hmisc)
library(pheatmap)
library(AnnotationDbi)
library(clusterProfiler)
library("org.Hs.eg.db")
library(shinycssloaders)
#Load data
#Data
#AstraZeneca PheWAS Portal
az_gene_binary_raw <- fread("Data/AZ_Gene-level_Binary_1e-08.csv")
az_gene_continuous_raw <- fread("Data/AZ_Gene-level_Continuous_1e-08.csv")
az_var_binary_raw <- fread("Data/AZ_Variant-level_Binary_1e-08_gnomAD_clinvar.csv")
az_var_continuous_raw <- fread("Data/AZ_Variant-level_Continuous_1e-08_gnomAD_clinvar.csv")
#FinnGen
finngen_raw <- fread("Data/Finngen11_Result_5e-8_SmallestPvalueGene_gnomAD_clinvar.csv")
#GWAS Catalog
gwas_raw <- fread("Data/gwas_catalog_v1.0.2-associations_e112_r2024-07-08.tsv")
gwas_raw <- gwas_raw %>% filter(PVALUE_MLOG > abs(log10(5e-8)))
gtex_raw <- fread("Data/GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_median_tpm.gct")
#EFO MAP
efo_raw <- fread("Data/trait_mappings.txt")
#gnomAD GWAS Catalog
gnomad_raw <- fread("Data/gnomAD_GWAS.csv")
#Clinvar
clinvar_raw <- fread("Data/clinvar_extracted_data.txt.gz")
example <- fread("Data/ExampleGeneList.csv")
#############################
#function
plot_exception <-function(
...,
sep=" ",
type=c("message","warning","cat","print"),
color="auto",
console=TRUE,
size = 6){
type=match.arg(type)
txt = paste(...,collapse=sep)
if(console){
if(type == "message") message(txt)
if(type == "warning") warning(txt)
if(type == "cat") cat(txt)
if(type == "print") print(txt)
}
if(color =="auto") color <- if(type == "cat") "black" else "red"
if(txt == "warning") txt <- paste("warning:",txt)
print(ggplot2::ggplot() +
ggplot2::geom_text(ggplot2::aes(x=0,y=0,label=txt),color=color,size=size) +
ggplot2::theme_void())
invisible(NULL)
}
plotly_exception <- function(
...,
sep = " ",
type = c("message", "warning", "cat", "print"),
color = "auto",
console = TRUE,
size = 6
) {
# Match argument for type
type <- match.arg(type)
# Combine the inputs into a single text string
txt <- paste(..., collapse = sep)
# Print the message to the console if console = TRUE
if (console) {
switch(type,
message = message(txt),
warning = warning(txt),
cat = cat(txt, "\n"),
print = print(txt)
)
}
# Set color automatically based on type if color is "auto"
if (color == "auto") {
color <- if (type == "cat") "black" else "blue"
}
# Modify the warning text if necessary
if (type == "warning") txt <- paste("warning:", txt)
# Create the ggplot object
p <- ggplot2::ggplot() +
ggplot2::geom_text(ggplot2::aes(x = 0, y = 0, label = txt), color = color, size = size) +
ggplot2::theme_void()
# Convert ggplot to plotly and print the plot
p_interactive <- plotly::ggplotly(p)
print(p_interactive)
#invisible(NULL) # Return NULL invisibly
}
infoBtn <- function(id) {
actionButton(id,
label = "",
icon = icon("question"),
style = "info",
size = "extra-small",
class='btn action-button btn-info btn-xs shiny-bound-input'
)
}
#Define ui
ui <- navbarPage(inverse = TRUE,
h4(strong("GeneSetPheno")),
#theme = shinytheme("spacelab"),
theme = shinytheme("cosmo"),
id = "panels_main",
tabPanel(h4(icon("home")),
fluidPage(
br(),
br(),
fluidRow(
column(12,
verbatimTextOutput("sessioninfo"),
fileInput("file1", strong("Upload Gene Set of Interest CSV File"), accept = ".csv",width = "1000px"),
actionButton("RunAnalysis",strong("Run Gene Set Analysis"), icon = icon("play")),
# br(),
# br(),
downloadButton(outputId = "report",label = strong("Generate report")),
downloadButton("downloadData", strong("Download Example Input File"))
),
align = "center"
),
br(),
br(),
p(strong("About"),style = "font-size: 17pt"),
p(style="text-align: justify;","TThis web application integrates data from public databases such as the ",
a(strong("AstraZeneca PheWAS Portal, "),style = "color:#337ab7", href = "https://azphewas.com"),
a(strong("FinnGen, "),style = "color:#337ab7", href = "https://r11.finngen.fi"),
a(strong("GWAS Catalog, "),style = "color:#337ab7", href = "https://www.ebi.ac.uk/gwas"),
a(strong("Human Phenotype Ontology, "),style = "color:#337ab7", href = "https://hpo.jax.org"),
a(strong("gnomAD, "),style = "color:#337ab7", href = "https://gnomad.broadinstitute.org"),
a(strong("ClinVar, "),style = "color:#337ab7", href = "https://www.ncbi.nlm.nih.gov/clinvar/"),
"and ",
a(strong("GTEx, "),style = "color:#337ab7", href = "https://gtexportal.org/home/"),
"to generate visual summaries of gene, genetic variant, phenotype, and association information.",
style = "font-size: 13pt"),
br(),
br(),
img(src='IntroMindMap.png', align = "center", height="80%", width="80%"),
br(),
br(),
p(strong("Data Sources"),style = "font-size: 13pt"),
p(style="text-align: justify;",
a(strong("AstraZeneca PheWAS Portal: "),style = "color:#337ab7", href = "https://azphewas.com"), "Gene-phenotype associations, the largest and most comprehensive exome-wide genotype-phenotype dataset, rare-variant genetic association data. Provides both gene and variant-level phenome-wide association statistics (PheWAS) using the exome sequences of the UK Biobank participants and considered ~17K binary and ~1.4K quantitative phenotypes.
",
br(),
a(strong("FinnGen: "),style = "color:#337ab7", href = "https://r11.finngen.fi"), "The FinnGen research project is an academic industrial collaboration aiming to identify genotype-phenotype correlations in the Finnish founder population designed to develop the potential of these resources to serve medicine initiate and enrich drug discovery programs.",
br(),
a(strong("GWAS Catalog: "),style = "color:#337ab7", href = "https://www.ebi.ac.uk/gwas"), "The NHGRI-EBI Catalog of human genome-wide association studies.",
br(),
a(strong("Human Phenotype Ontology (HPO): "),style = "color:#337ab7", href = "https://hpo.jax.org"), "A standardized vocabulary of phenotypic abnormalities encountered in human disease.",
br(),
a(strong("gnomAD: "),style = "color:#337ab7", href = "https://gnomad.broadinstitute.org"), "Provides information on human genetic variation in healthy individuals across a diverse range of genetic ancestry groups.",
br(),
a(strong("ClinVar: "),style = "color:#337ab7", href = "https://www.ncbi.nlm.nih.gov/clinvar/"), "Report the relationships among human variations and phenotypes, with supporting evidence.",
br(),
a(strong("Genotype-Tissue Expression (GTEx): "),style = "color:#337ab7", href = "https://gtexportal.org/home/"), "A data resource and tissue bank established to study the relationships between variants and gene expression across several tissue types and different people.",
br(),
style = "font-size: 10pt"),
br(),
br(),
div(p(strong("This was developed by Jiru Han with input from Melanie Bahlo and other "), a("Bahlo Lab members", href = "https://www.wehi.edu.au/people/melanie-bahlo/372/melanie-bahlo-lab-team")),
p(strong("For any queries or suggestions, please contact Jiru Han: [email protected]")),
style="text-align: right;")
)
),
#Gene Summary
tabPanel(h4(strong("Gene Summary")),
fluidPage(
br(),
p(strong("Gene Summary"),style = "font-size: 15pt"),
p("This module enables the extraction of comprehensive gene set information, including Entrez, Ensembl, and Uniprot IDs, genomic locations, gene function summaries, gene sequences, transcript counts, gene biotypes, and additional details. Additionally, it summarizes significant gene-phenotype associations from databases such as AZPheWAS, GWAS Catalog, and FinnGen, identifying the number of associated genes and presenting the results in both summary tables and figures.",style = "font-size: 14pt"),
br(),
actionButton("ViewGeneInfo",strong("Generate Gene Summary")),
br(),
hr(),
mainPanel(tabsetPanel(
tabPanel(strong("Gene Info"),
br(),
p("Detailed gene set information",style = "font-size: 14pt"),
style = "background: white",
fluidRow(
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p1_dt1")),
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p1_plot1"))
)))),
tabPanel(strong("Summary Table of Significant Gene–Phenotype Associations"),
br(),
p("A table summarizing significant gene-phenotype associations from multiple databases",style = "font-size: 14pt"),
style = "background: white",
fluidRow(
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(uiOutput("p1_dt2"))
)))),
tabPanel(strong("Summary Plot of Significant Gene–Phenotype Associations"),
br(),
p("A summary plot visualizing these associations for the gene sets",style = "font-size: 14pt"),
fluidRow(
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p1_plot2",width = "100%"))
))))
))
)
),
#Gene-Phenotype Associations
tabPanel(h4(strong("Gene-Phenotype Association")),
fluidPage(
br(),
p(strong("Gene-Phenotype Association"),style = "font-size: 15pt"),
p("This module in GeneSetPheno provides a detailed summary of gene-phenotype associations. Significant associations from AZPheWAS, GWAS Catalog, and FinnGen databases are summarized for the gene set. This information is presented in an interactive table and figure, offering comprehensive details for each gene, including all associated phenotypes, phenotype categories, and variants.",style = "font-size: 14pt"),
actionButton("ViewGenePhenotypeAsso",strong("Generate Gene-Phenotype Associations")),
br(),
hr(),
mainPanel(tabsetPanel(
tabPanel(strong("Summary Plot of Significant Gene–Phenotype Associations"),
br(),
p("A summary plot that displays significant gene–phenotype associations for the gene sets. Users can easily access detailed information about each gene’s phenotype associations across databases, such as phenotype categories, by hovering over a gene or database.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p2_plot1"))
)))),
tabPanel(strong("Summary Table of Significant Gene–Phenotype Associations"),
br(),
p("A table that displays significant gene–phenotype associations for the gene sets. Users can access all relevant phenotype categories, phenotypes, and variants across multiple databases for each gene, offering a clear and comprehensive overview of significant gene–phenotype associations.",style = "font-size: 14pt"),
fluidRow(
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p2_dt1"))
))))
))
)
),
#Variant-Phenotype Associations
tabPanel(h4(strong("Variant-Phenotype Association")),
fluidPage(
br(),
p(strong("Variant-Phenotype Association"),style = "font-size: 15pt"),
p("This module focuses on four key components: a summary table of variant-phenotype associations, AZPheWAS, GWAS Catalog, and Finngen, with the aim of displaying significant associations between genetic variants and various phenotypes from different databases.",style = "font-size: 14pt"),
br(),
hr(),
mainPanel(tabsetPanel(
tabPanel(strong("Summary Table of Significant Variant–Phenotype Associations"),
br(),
p("The summary table provides a comprehensive overview of variant associations from various databases, including details like the gene list group, gene symbol, variant, rsID, allele frequency in gnomAD, link-outs to the gnomAD browser, and clinical significance from ClinVar. It also consolidates significant phenotype data from AZPheWAS, GWAS Catalog, and Finngen, along with additional information on phenotype categories.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewVarTable",strong("Generate Variant-Phenotype Associations Table"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p3_dt1"))
)))
),
tabPanel(strong("AstraZeneca PheWAS Portal"),
style = "background: white",
tabsetPanel(
tabPanel(strong("Phenotypic Profile Clustering"),
br(),
p("Phenotypic profile clustering is performed by grouping genes according to their associations with upper-level phenotype categories. For each category, significant variant-phenotype associations for each gene are assessed, followed by hierarchical clustering. This analysis highlights genes with similar phenotype associations. The x-axis represents genes, and the y-axis represents phenotype categories. The color indicates whether there is a significant association of each gene across phenotype categories: red represents a significant association, while white represents no significant association.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewAZCluster",strong("View Phenotypic Profile Clustering"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot1"))
)))
),
tabPanel(strong("Phenotype Distribution Overview"),
br(),
p("The phenotype distribution overview section visualizes phenotype association patterns across different gene set groups. It aggregates all phenotypes associated with each gene list within each phenotype category, either by counting unique phenotypes or calculating the proportions of genes.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
actionButton("ViewAZVar",strong("View Phenotype Distribution"), icon = icon("play"))
),
fluidRow(column(12,
shinycssloaders::withSpinner(plotlyOutput("p3_plot2")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p3_plot3"))
)))
),
tabPanel(strong("Variant-Phenotype Gene Effect"),
br(),
p("The mean effect of each gene across various phenotype categories is calculated by averaging the odds ratios or absolute effect sizes from all significant variant-phenotype associations within each gene, for both binary and continuous phenotypes. This reflects the estimated overall effect of each gene within each phenotype category.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewAZEffect",strong("View Variant-Phenotype Gene Effect"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot_add1")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p3_dt2"))
)))
)
) #Close inner tabsetPanel
),
tabPanel(strong("GWAS Catalog"),
style = "background: white",
tabsetPanel(
tabPanel(strong("Phenotypic Profile Clustering"),
br(),
p("Phenotypic profile clustering is performed by grouping genes according to their associations with upper-level phenotype categories. For each category, significant variant-phenotype associations for each gene are assessed, followed by hierarchical clustering. This analysis highlights genes with similar phenotype associations. The x-axis represents genes, and the y-axis represents phenotype categories. The color indicates whether there is a significant association of each gene across phenotype categories: red represents a significant association, while white represents no significant association.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewGWASCatalogCluster",strong("View Phenotypic Profile Clustering"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot6"))
)))
),
tabPanel(strong("Phenotype Distribution Overview"),
br(),
p("The phenotype distribution overview section visualizes phenotype association patterns across different gene set groups. It aggregates all phenotypes associated with each gene list within each phenotype category, either by counting unique phenotypes or calculating the proportions of genes.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewGWASCatalogPheno",strong("View Phenotype Distribution"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p3_plot7")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p3_plot8"))
)))
)
) #Close inner tabsetPanel
),
tabPanel(strong("FinnGen"),
style = "background: white",
tabsetPanel(
tabPanel(strong("Phenotypic Profile Clustering"),
br(),
p("Phenotypic profile clustering is performed by grouping genes according to their associations with upper-level phenotype categories. For each category, significant variant-phenotype associations for each gene are assessed, followed by hierarchical clustering. This analysis highlights genes with similar phenotype associations. The x-axis represents genes, and the y-axis represents phenotype categories. The color indicates whether there is a significant association of each gene across phenotype categories: red represents a significant association, while white represents no significant association.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewFinnGenCluster",strong("View Phenotypic Profile Clustering"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot9")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot10"))
)))
),
tabPanel(strong("Phenotype Distribution Overview"),
br(),
p("The phenotype distribution overview section visualizes phenotype association patterns across different gene set groups. It aggregates all phenotypes associated with each gene list within each phenotype category, either by counting unique phenotypes or calculating the proportions of genes.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewFinnGenPheno",strong("View Phenotype Distribution"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p3_plot11")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p3_plot12"))
)))
),
tabPanel(strong("Variant-Phenotype Gene Effect"),
br(),
p("The mean effect of each gene across various phenotype categories is calculated by averaging the odds ratios or absolute effect sizes from all significant variant-phenotype associations within each gene, for both binary and continuous phenotypes. This reflects the estimated overall effect of each gene within each phenotype category.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewFinnGenEffect",strong("View Variant-Phenotype Gene Effect"), icon = icon("play"))
),
fluidRow(column(12,
br(),
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p3_plot_add2")),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p3_dt3"))
)))
)
) #Close inner tabsetPanel
)
))
)
),
#HPO Phenotype
tabPanel(h4(strong("HPO Phenotype")),
fluidPage(
br(),
p(strong("HPO Phenotype"),style = "font-size: 15pt"),
p("This module enables visualization of phenotype enrichment results and comparative phenotype analysis of different gene sets using the HPO resource.",style = "font-size: 14pt"),
br(),
hr(),
mainPanel(tabsetPanel(
tabPanel(strong("Phenotype Enrichment Visualization"),
br(),
p("Phenotype enrichment analysis on the gene set. The results display the top enriched terms for the gene set in a plot.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
selectInput('GeneListGroup', label = 'Select Group', choices = 'No choices here yet'),
actionButton("ViewHPOPlot",strong("Phenotype Enrichment Visualization"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p4_plot1"))
)))),
tabPanel(strong("Phenotype Enrichment Summary Table"),
br(),
p("Phenotype enrichment analysis on the gene set. The results display the top enriched terms for the gene set in a summary table.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
selectInput('GeneListGroupTab', label = 'Select Group', choices = 'No choices here yet'),
actionButton("ViewHPOTab",strong("View Phenotype Enrichment Summary Table"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(DT::dataTableOutput("p4_dt1"))
)))),
tabPanel(strong("Comparator Phenotype analysis"),
br(),
p("This generates an interactive graph displaying the relevant phenotypic terms for each gene set, highlighting unique and shared phenotypes, differentiated by color.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
selectInput('Group1', label = 'Select Group1', choices = 'No choices here yet'),
selectInput('Group2', label = 'Select Group2', choices = 'No choices here yet'),
actionButton("ViewHPOCompar",strong("Comparator Phenotype Analysis - Gene Set"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p4_plot2"))
))))
))
)
),
#GTEx Analysis
tabPanel(h4(strong("GTEx Analysis")),
fluidPage(
br(),
p(strong("Genotype-Tissue Expression (GTEx) Analysis"),style = "font-size: 15pt"),
p("This module enables the exploration of tissue-specific gene expression within a gene set using GTEx resources. For this analysis, tissue-specific gene expression data from the GTEx V8 release was downloaded, focusing on the median transcripts per million (TPM) for each gene across various tissues.",style = "font-size: 14pt"),
br(),
hr(),
mainPanel(tabsetPanel(
tabPanel(strong("Gene Set Tissue Expression Distribution"),
br(),
p("This feature generates an interactive boxplot that visualizes the distribution of median tissue TPM across GTEx tissues, categorized by gene set groups and distinguished by tissue class through color-coding.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewGTExBoxplot",strong("View Expression Distribution"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotlyOutput("p5_plot1"))
)))),
tabPanel(strong("Gene Set Tissue-Specific Expression Comparison"),
br(),
p("The comparison of gene sets to detect significant differences in gene expression across tissue types. For each tissue type, t-tests were conducted using the rstatix R package to compare gene expression between gene set groups.",style = "font-size: 14pt"),
style = "background: white",
fluidRow(column(12,
br(),
actionButton("ViewGTExCompar",strong("View Gene Set Expression Comparison"), icon = icon("play"))
),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p5_plot2"))
)))),
tabPanel(strong("Gene Expression Clustering"),
br(),
p("Clustering of gene expression is conducted by grouping genes based on their expression levels across various tissues. This analysis allows for the identification of genes with similar expression patterns, as well as those exhibiting unique tissue-specific patterns.",style = "font-size: 14pt"),
fluidRow(column(12,
br(),
actionButton("ViewGTExCluster",strong("View Gene Expression Clustering"), icon = icon("play"))),
fluidRow(column(12,
br(),
hr(),
shinycssloaders::withSpinner(plotOutput("p5_plot3"))
))))
))
)
)
)
# Define server logic to summarize and view selected dataset ----
server <- function(input, output,session) {
#Gene raw data
gene_raw <- eventReactive(input$RunAnalysis,{
file <- input$file1
ext <- tools::file_ext(file$datapath)
req(file)
validate(need(ext == "csv", "Please upload a csv file"))
data <- read.csv(file$datapath)
data <- data %>%
arrange(Group,Gene)
data
})
#Filter the AZ, GWAS Catalog, and FinnGen data
p1_dt1_tab <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
gene_info_id <- gene_raw$Gene
gene_info <- genInfo(gene_info_id, org = "hs", unique = TRUE)
colnames(gene_info)[1] <- "Gene"
gene_info <- gene_info %>%
full_join(gene_raw) %>%
dplyr::select(Group,Gene,gene_name,chr,start,end, width,strand,symbol,hgnc_id, entrezid,ensembl,uniprot,summary,
gc_content,gene_biotype,transcript_count,omim)
gene_info
})
#AstraZeneca PheWAS Portal
az_gene_binary_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
az_gene_binary_flt <- az_gene_binary_raw %>%
filter(Gene %in% gene_raw$Gene)
az_gene_binary_flt
})
az_gene_continuous_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
az_gene_continuous_flt <- az_gene_continuous_raw %>%
filter(Gene %in% gene_raw$Gene)
az_gene_continuous_flt
})
az_var_binary_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
az_var_binary_flt <- az_var_binary_raw %>%
filter(Gene %in% gene_raw$Gene)
az_var_binary_flt
})
az_var_continuous_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
az_var_continuous_flt <- az_var_continuous_raw %>%
filter(Gene %in% gene_raw$Gene)
az_var_continuous_flt
})
#GWAS Catalog
gwas_raw_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
gwas_raw_flt <- gwas_raw %>%
mutate(Gene=MAPPED_GENE) %>%
separate_rows(Gene, sep = " - ",convert = TRUE) %>%
filter(Gene %in% gene_raw$Gene)
gwas_raw_flt
})
#FinnGen
finngen_raw_flt <- eventReactive(input$RunAnalysis,{
gene_raw <- gene_raw()
finngen_raw_flt <- finngen_raw %>%
mutate(Gene_multi=Gene) %>%
separate_rows(Gene, sep = ",",convert = TRUE) %>%
filter(Gene %in% gene_raw$Gene)
finngen_raw_flt
})