-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummary_statistics_section.R
More file actions
282 lines (207 loc) · 11.6 KB
/
summary_statistics_section.R
File metadata and controls
282 lines (207 loc) · 11.6 KB
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
sumStats <- list()
sumStats$id <- "sumstats"
sumStats$title <- "Summary Statistics"
sumStats$loadData<- function(){
#dataframe holding links for the other summary stats table
other_gwas_info <<- data.table(ID=c("aoo","gba_aoo","gba_mod","lrrk2","asian","META5","ad","als","latam","male","female","lbd"),
LINK=c("https://pubmed.ncbi.nlm.nih.gov/30957308/",
"https://pubmed.ncbi.nlm.nih.gov/31755958/",
"https://pubmed.ncbi.nlm.nih.gov/31755958/",
"https://pubmed.ncbi.nlm.nih.gov/31958187/",
"https://pubmed.ncbi.nlm.nih.gov/32310270/",
"https://pubmed.ncbi.nlm.nih.gov/31701892/",
"https://pubmed.ncbi.nlm.nih.gov/30617256/",
"https://pubmed.ncbi.nlm.nih.gov/29566793/",
"https://www.medrxiv.org/content/10.1101/2020.11.09.20227124v1",
"https://www.medrxiv.org/content/10.1101/2021.02.09.21250262v1",
"https://www.medrxiv.org/content/10.1101/2021.02.09.21250262v1",
"https://pubmed.ncbi.nlm.nih.gov/33589841/"),
SHORT_REF=c("Blauwendraat et al. 2019 Age of Onset",
"Blauwendraat et al. 2020 GBA Age of Onset",
"Blauwendraat et al. 2020 GBA Risk Modifier",
"Iwaki et al. 2020 LRRK2 Risk Modifier",
"Foo et al. 2020 Asian",
"Nalls et al. 2019 META5",
"Jansen et al. 2019 Alzheimer's Disease",
"Nicolas et al. 2018 Amyotrophic Lateral Sclerosis",
"Loesch et al. 2020 Latin America",
"Blauwendraat et al. 2021 Male Specific",
"Blauwendraat et al. 2021 Female Specific",
"Chia et al. 2021 Lewy Body Dementia"))
#other study summary statistics
aoo_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="AAO",colNames=TRUE,sep.names=" ")
aoo_stats$GWAS <<- "aoo"
gba_aoo_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="GBA_AAO",colNames=TRUE,sep.names=" ")
gba_aoo_stats$GWAS <<- "gba_aoo"
gba_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="GBA_mod",colNames=TRUE,sep.names=" ")
gba_stats$GWAS <<- "gba_mod"
lrrk2_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="LRRK2",colNames=TRUE,sep.names=" ")
lrrk2_stats$GWAS <<- "lrrk2"
asian_gwas_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="Asian_GWAS",colNames=TRUE,sep.names=" ")
asian_gwas_stats$GWAS <<- "asian"
meta5_gwas_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="META5",colNames=TRUE,sep.names=" ")
meta5_gwas_stats$GWAS <<- "META5"
ad_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="AD",colNames=TRUE,sep.names=" ")
ad_stats$GWAS <<- "ad"
als_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="ALS",colNames=TRUE,sep.names=" ")
als_stats$GWAS <<- "als"
latam_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="Latam_GWAS",colNames=TRUE,sep.names=" ")
latam_stats$GWAS <<- "latam"
male_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="Male_GWAS",colNames=TRUE,sep.names=" ")
male_stats$GWAS <<- "male"
female_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="Female_GWAS",colNames=TRUE,sep.names=" ")
female_stats$GWAS <<- "female"
lbd_stats <<- read.xlsx(xlsxFile="www/summarystats/other_sum_stats.xlsx",sheet="LBD",colNames=TRUE,sep.names=" ")
lbd_stats$GWAS <<- "lbd"
#each gwas is going to have a different set of other summary statistics to show
other_sum_stats_for_meta5_gwas <<- rbind(aoo_stats,gba_aoo_stats,gba_stats,lrrk2_stats,asian_gwas_stats,ad_stats,als_stats,latam_stats,male_stats,female_stats,lbd_stats)
other_sum_stats_for_prog_gwas <<- rbind(aoo_stats,gba_aoo_stats,gba_stats,lrrk2_stats,asian_gwas_stats,meta5_gwas_stats,ad_stats,als_stats,latam_stats,male_stats,female_stats,lbd_stats)
other_sum_stats_for_asian_gwas <<- rbind(aoo_stats,gba_aoo_stats,gba_stats,lrrk2_stats,meta5_gwas_stats,ad_stats,als_stats,latam_stats,male_stats,female_stats,lbd_stats)
freqs <<- fread("www/summarystats/risk_variant_pop_freqs.csv")
#ucsc links
UCSC_links <<- fread("www/summarystats/UCSC_links.csv")
#file containing special text for progression loci
locus_text <<- fread("www/summarystats/Locus_Special_Text.txt")
}
sumStats$generateUI<- function(){
div(
br(),
fluidRow(
column(
div(htmlOutput("sumstatsVariantOutput")),
div(htmlOutput("sumstatsRSOutput")),
div(htmlOutput("nearGeneOutput")),
div(htmlOutput("locusOutput")),
div(htmlOutput("UCSClinkOutput")),
br(),
div(htmlOutput("locusSpecialTextOutput")),
width = 4),
column(
htmlOutput("studyOutput"),
dataTableOutput("snpStatsTable"),
width = 4),
column(
dataTableOutput("freqTable"),
width = 4
)
),
hr(),
div(id="otherstats",
fluidRow(
column(
h3("Summary Statistics from Other GWASes:"),
dataTableOutput("otherSumStatsTable"),
width = 12
)
)
)
)
}
sumStats$serverLogic <- function(input,output,session,reactives){
#update variant chr:bp:ref:alt at summary stats section
output$sumstatsVariantOutput <- renderUI(HTML(paste0("<h2><b>Variant: </b>", (reactives$selRiskVariant()$CHR), ":", as.numeric(gsub("\\,", "", (reactives$selRiskVariant()$BP))), ":", toupper((reactives$selRiskVariant()$REF)), ":", toupper((reactives$selRiskVariant()$ALT)), "</h2>")))
#update rsid text at summary stats section
output$sumstatsRSOutput <- renderUI(HTML(paste0("<h3>", (reactives$selRiskVariant()$RSID), "</h3>")))
#show nearest gene
output$nearGeneOutput <- renderUI({
# link <- a((reactives$selRow$'Nearest Gene'), href = paste0("https://pdgenetics.shinyapps.io/ExomeBrowser/?gene=", (reactives$selRow$'Nearest Gene')), target = "_blank")
tagList(
HTML(
# paste0("<h3>Nearest Gene: <i>", link, "</i></h3>")
paste0("<h3>Nearest Gene: <i>", reactives$selRiskVariant()$'NEAR_GENE', "</i></h3>")
)
)
})
output$locusOutput <- renderUI(HTML(paste0("<h3>Locus: ", (reactives$selRiskVariant()$LOC_NUM), "</h3>")))
output$UCSClinkOutput <- renderUI({
link_row <- UCSC_links[UCSC_links$'SNP' == reactives$selRiskVariant()$RSID,]
if(nrow(link_row)!=0)
{
link <- a("UCSC Genomic View", href = link_row$'UCSC map link', target = "_blank")
HTML(paste0("<h3>",link,"</h3>"))
}
else
{
HTML("<p></p>")
}
})
output$locusSpecialTextOutput <- renderUI(
{
text <- locus_text[which(locus_text$'Locus Number' == reactives$selRiskVariant()$"LOC_NUM" & locus_text$GWAS == reactives$selRiskVariant()$GWAS),]
if(nrow(text)!=0)
{
HTML(paste0("<h3>Locus Info:</h3><h5><p>",text$Text,"</p></h5>"))
}
else
{
HTML("<p></p>")
}
}
)
#render the studyOutput for study reference
output$studyOutput <- renderUI({
HTML(paste0("<h4>",reactives$selRiskVariant()$GWAS, " Loci Summary Statistics (",a(gwas_info[gwas_info$ID==reactives$selRiskVariant()$GWAS,]$SHORT_REF, href = gwas_info[gwas_info$ID==reactives$selRiskVariant()$GWAS,]$LINK, target = "_blank"),")</h4>"))#gwas_info[gwas_info$ID==reactives$selRiskVariant()$GWAS,]$SHORT_REF, ")</h4>" ))
})
#render the snp statistics table
output$snpStatsTable <- renderDataTable({
#if the locus isn't from the progression study
data <- reactives$selRiskVariant()
if(reactives$selRiskVariant()$GWAS=="META5")
{
df <- data.frame("<b>Beta</b>"= signif(data$BETA,4),"<b>Odds Ratio</b>"= signif(data$OR,4), "<b>Effect Allele Frequency</b>"= signif(data$EFFECT_FREQ,4),"<b>Standard Error</b>"= signif(data$SE,4), "<b>P-value</b>"= signif(data$P,4), "<b>P Conditional and Joint Analysis</b>"= signif(data$P_COJO,4), check.names = F)
beta_label <- paste0('<b>Beta [',data$EFFECT_ALLELE,']</b>')
}
else
{
df <- data.frame("<b>Beta</b>"= signif(data$BETA,4),"<b>Odds Ratio</b>"= signif(data$OR,4), "<b>Effect Allele Frequency</b>"= signif(data$MAF,4),"<b>Standard Error</b>"= signif(data$SE,4), "<b>P-value</b>"= signif(data$P,4), check.names = F)
beta_label <- paste0('<b>Beta [',data$ALT,']</b>')
}
#assign the beta_label to the beta columns
names(df)[names(df) == "<b>Beta</b>"] <- beta_label
df <- t(df)
}, colnames = "", selection=list(mode="none"), escape = F,options = list(searching = F, paginate = F, ordering = F, dom = 't'))
#render the population frequency table
output$freqTable <- renderDataTable(
{
freqRow <- freqs[which(freqs$RSID==reactives$selRiskVariant()$RSID),]
freqRow <- freqRow[,!c("GWAS","LOC_NUM","RSID")]
if(reactives$selRiskVariant()$GWAS!="META5")
{
freqRow <- freqRow[,!c("Frequency_PD","Frequency_control","AFF","UNAFF")]
}
colnames(freqRow) <- paste0("<b>",colnames(freqRow),"</b>")
freqRow <- t(freqRow)
freqRow <- na.omit(freqRow,colnames(freqRow))
freqRow
}, colnames="", selection=list(mode="none"),escape=F, options = list(searching = F, paginate = F, ordering = F, dom = 't')
)
output$otherSumStatsTable <- renderDataTable(
{
statsData<-NULL
if(reactives$selRiskVariant()$GWAS=="META5")
{
statsData <- other_sum_stats_for_meta5_gwas[which(other_sum_stats_for_meta5_gwas$RSID == reactives$selRiskVariant()$RSID),]
}
else if(reactives$selRiskVariant()$GWAS=="Progression")
{
statsData <- other_sum_stats_for_prog_gwas[which(other_sum_stats_for_prog_gwas$RSID == reactives$selRiskVariant()$RSID),]
}
else if(reactives$selRiskVariant()$GWAS=="Asian")
{
statsData <- other_sum_stats_for_asian_gwas[which(other_sum_stats_for_asian_gwas$RSID == reactives$selRiskVariant()$RSID),]
}
other_gwas_info_sub <- other_gwas_info[which(other_gwas_info$ID %in% statsData$GWAS),]
statsData$STUDY <- paste0("<a href='",other_gwas_info_sub[other_gwas_info_sub$ID==statsData$GWAS,]$LINK, "' target = '_blank'>",other_gwas_info_sub[other_gwas_info_sub$ID==statsData$GWAS,]$SHORT_REF," GWAS</a>")
statsData <- statsData %>% select("STUDY","RSID","EFFECT_FREQ","BETA","SE","P")
colnames(statsData) <- c("GWAS", "Risk Variant", "Effect Allele Frequency", "Beta", "SE","P-value")
statsData
},selection=list(mode="none"),escape=F,rownames = F, options = list(searching = F, paginate = F, dom = 't', columnDefs = list(list(
className = 'dt-right',
targets = c(2,3,4,5),
render = JS(
"function(data, type, row, meta) {",
"return (data==null) ? 'NA' : parseFloat(data).toPrecision(3);",
"}"
))))
)
}