-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
82 lines (72 loc) · 3.75 KB
/
Copy pathserver.R
File metadata and controls
82 lines (72 loc) · 3.75 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
library(shiny)
library(dplyr)
load("kandothAnno.Rdata")
load("numBySample.Rdata")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
#for "CADD Summary" Tab
#Returns the requested data for the CADD distribution histogram
datasetInput <- reactive({
switch(input$distributionData,
"All"=na.omit(kandothAnno2$v13CADDscaled),
"Missense"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="Missense",]$v13CADDscaled),
"Nonsense"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="Nonsense",]$v13CADDscaled),
"Nonstop"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="Nonstop",]$v13CADDscaled),
"RNA"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="RNA",]$v13CADDscaled),
"Silent"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="Silent",]$v13CADDscaled),
"Splice Site"=na.omit(kandothAnno2[kandothAnno2$Variant_Classification=="Splice_Site",]$v13CADDscaled))
})
#generate summary of the distribution
output$summary<-renderPrint({
distributionData<-datasetInput()
summary(distributionData)
})
#CADD distribution histogram
output$scaledCADD <- renderPlot({
distributionData <- datasetInput() # R object in loaded data
bins <- seq(min(distributionData), max(distributionData), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(distributionData, breaks=bins, col = 'blue', border = 'white', xlab="CADD", main="C Score Frequency")
})
#Variant Classification barplot
mytable<-table(kandothAnno2$Variant_Classification)
names(mytable)[2]<-"Frameshift_Del"
names(mytable)[1]<-"NA"
names(mytable)[3]<-"Frameshift_Ins"
names(mytable)[4]<-"InframeDel"
names(mytable)[5]<-"InframeIns"
dfTable<-as.data.frame(mytable)
dfTable<-dfTable[order(-dfTable$Freq),]
library(ggplot2)
output$bp<-renderPlot({ggplot(dfTable, aes(x="", y=Freq, fill=Var1))+
geom_bar(width=1, colour="black", stat="identity") + scale_fill_manual(values=c("white", "orange", "lightblue", "black", "gray", "red", "blue", "pink", "purple", "green", "yellow"))+
labs(x="Variant Classification", y="Variant Frequency")})
#Samples by Cancer Pie Chart
numByCancer<-table(numBySample$V3)
numByCancerDF<-as.data.frame(numByCancer)
colnames(numByCancerDF)[1]<-"Cancer"
#pie chart
output$pieCancer<-renderPlot({ggplot(numByCancerDF, aes(x="", y=Freq, fill=Cancer))+
geom_bar(width=1, stat="identity")+
theme(panel.background=element_blank())+
coord_polar("y", start=0)+
theme(axis.text.x=element_blank())+
scale_fill_brewer(palette="Set3")+
scale_x_discrete(name="")+
scale_y_discrete(name="")})
#numBySample is the number of mutations by each sample, annotated with tumor type
#small<-subset(numBySample, numBySample$Freq<3000)
output$bp4<-renderPlot({ggplot(numBySample, aes(V3, log10(Freq)))+
geom_jitter()+
theme(axis.text.x=element_text(angle=90, hjust=1))+
labs(x="Cancer", y="log10(# of Variants per Sample)")})
output$variantCount<-renderText({paste("Total Number of Variants:", nrow(kandothAnno2))})
output$sampleCount<-renderText({paste("Total Number of Samples:", length(unique(kandothAnno2$ShortTumor_Sample)))})
output$cancerCount<-renderText({paste("Number of Cancers Represented:", length(unique(kandothAnno2$Cancer)))})
output$cancerSummary<-renderDataTable({count_(kandothAnno2, 'Cancer')})
geneCount<-count_(kandothAnno2, 'Gene.x')
geneCount<-geneCount[-1,]
names(geneCount)[1]<-"Gene"
names(geneCount)[2]<-"Mutations"
output$geneSummary<-renderDataTable({geneCount[order(-as.numeric(geneCount$Mutations)),]}, options=list(lengthMenu=c(10, 20, 30, 40, 50), pageLength=10))
})