-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
87 lines (68 loc) · 2.48 KB
/
Copy pathserver.R
File metadata and controls
87 lines (68 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
81
82
83
84
85
86
87
#HudsonAlpha Cancer Variant Annotation Tool
#Brittany N. Lasseigne, 160119
#v1.0
###Utilizes v1.0 cancer variant cache (Kandoth mutation data only)
library(shiny)
library(data.table)
#mutation cache v1.0
load("AnnotationCache2.RData")
#load variant annotation function
#if(!exists("Annotate", mode="function"))
source("Variant_Annotation_Script.R")
#load example data for user
exampleInputFile<-fread("Example_InputVCFwithDupes.txt", stringsAsFactors = FALSE, sep="\t")
shinyServer(function(input, output) {
#read in data from user
filedata <- reactive({
infile <- input$datafile
if(is.null(infile)) {
return(NULL)
}
fread(infile$datapath, stringsAsFactors = FALSE, sep="\t")
})
#return number of rows in file user loaded
output$numVarFile<-renderText({
output$numVarFile<-renderText({paste("Total number of variants in file:", nrow(filedata()))})
})
#view user input file head
output$view <- renderTable({
head(filedata(), n = 5)
})
#view annotated variant file head
output$viewAnno <- renderTable({
head(zoutput()$Found_Annotations, n = 5)
})
#variant selection module: annotate all variants or only unique variants
variantInput <- reactive({
switch(input$uniqueAll,
"All Variants" = FALSE,
"Unique Variants Only" = TRUE)
})
#show user if all variants or unique variants selected
output$options<-renderText({paste("Annotate only unique variants?", print(variantInput()))})
#annotate user file
zoutput<-eventReactive(input$submitButton, {
Annotate(InputVCF=filedata(), AnnotationCache=AnnotationCache, UniqueVariantsOnly=variantInput())
})
#show user total number of variants annotated/not annotated
output$annotatedVariants<-renderText({
paste("Total number of variants annotated:", zoutput()$Number_Found)
})
output$unannotatedVariants<-renderText({
paste("Total number of variants not in cache:", zoutput()$Number_Missing)
})
#downloading annotated, unannotated, or example data
output$downloadData <- downloadHandler(
filename = function() {
paste(input$dataOut, '.txt', sep='') },
content = function(file) {
write.table(datasetOutput(), file, quote=FALSE)
})
#download data module
datasetOutput <- reactive({
switch(input$dataOut,
"Annotated_Variants" = zoutput()$Found_Annotations,
"Unannotated_Variants" = zoutput()$Missing_Annotations,
"Example_Input_Data" = exampleInputFile)
})
})