-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathburden_section.R
More file actions
80 lines (64 loc) · 2.48 KB
/
burden_section.R
File metadata and controls
80 lines (64 loc) · 2.48 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
burden<-list()
burden$id <- "burden"
burden$title <- "Burden Evidence"
burden$loadData<- function(){
#read the minimum p values for allburden tests for all the genes
burdenData <<- fread("www/burden/BurdenPValueData.csv")
}
burden$generateUI<- function(){
div(id = "burdenSection",
fluidRow(
column(div(uiOutput('burdenSelectUI'),class="geneselect"),width =2)
),
fluidRow(
column(dataTableOutput("burdenTable"), width = 5)
)
)
}
burden$serverLogic <- function(input,output,session,reactives)
{
#populate the dropdown using the reactive value
output$burdenSelectUI <- renderUI({
dropDownGenes <- (evidence[(evidence$RSID == reactives$selRiskVariant()$RSID & (evidence$GWAS == reactives$selRiskVariant()$GWAS)),]$GENE)
#add "All Genes" to the list for the other drop downs
dropDownGenes <- append(dropDownGenes, "All Genes", 0)
#default selected to the first in the list
selected_gene <- dropDownGenes[1]
#if there was a searched gene, select that
if(reactives$searchedGene()!="")
{
selected_gene <-dropDownGenes[match(toupper(reactives$searchedGene()), toupper(as.vector(dropDownGenes)))]
}
selectInput("burdenSelect",label = "Choose a gene", choices = dropDownGenes, selected = selected_gene)
})
output$burdenTable <- renderDT({
tableData <- NULL
#by default assume 'All Genes' option is selected
if(is.null(input$burdenSelect))
{
tableData <- burdenData[burdenData$GENE %in% (evidence[evidence$LOC_NUM== reactives$selRiskVariant()$LOC_NUM & evidence$GWAS == reactives$selRiskVariant()$GWAS,]$GENE),]
scrollYVal <- 200
}
else
{
if(input$burdenSelect=="All Genes")
{
tableData <- burdenData[burdenData$GENE %in% (evidence[evidence$LOC_NUM== reactives$selRiskVariant()$LOC_NUM & evidence$GWAS == reactives$selRiskVariant()$GWAS,]$GENE),]
scrollYVal <- 200
}
else
{
tableData <- burdenData[burdenData$GENE == input$burdenSelect,]
scrollYVal <- 50
}
}
colnames(tableData)[colnames(tableData)=='GENE'] <- 'Gene'
datatable(tableData, rownames = F, options = list(processing = F, searching = F, paginate = F, dom = 't', scrollY = paste0(scrollYVal,"px"), scrollX = T, columnDefs = list(list(
targets = c(1,2),
render = JS(
"function(data, type, row, meta) {",
"return (data==null) ? 'NA' : data.toPrecision(2);",
"}"
)))))
})
}