-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfastproto.R
executable file
·127 lines (84 loc) · 3.8 KB
/
fastproto.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
library("shiny")
load("../F11-juliane/annoHuman_rel82.RData")
set.seed(42)
allcoding <- annoHuman[annoHuman$gene_biotype=="protein_coding",]
genenames <- allcoding$gene_name %>% sort %>% unique()
alltheknockdowns <- paste0("KD_",1:20,"_",sample(genenames,20))
proto_kdmat <- matrix(0,length(genenames),length(alltheknockdowns))
dim(proto_kdmat)
for (i in 1:length(alltheknockdowns)){
proto_kdmat[sample((1:nrow(proto_kdmat)),200),i] <- 1 # set 200 random genes to 1
}
head(proto_kdmat)
rownames(proto_kdmat) <- genenames
colnames(proto_kdmat) <- alltheknockdowns
library("DT")
library(shinydashboard)
protoTrend <- function(){
newuiui <-
shinydashboard::dashboardPage(
dashboardHeader(
title = paste0("Quick prototype of trendseq exploration app"),
titleWidth = 900),
dashboardSidebar(
width = 350,
menuItem("App settings",icon = icon("cogs"),
textInput("inText1","Type something")
),
menuItem("Plot settings", icon = icon("paint-brush"),
# bstooltip: Use the widgets below to setup general parameters for exporting produced plots
numericInput("export_width",label = "Width of exported figures (cm)",value = 30,min = 2),
numericInput("export_height",label = "Height of exported figures (cm)",value = 30,min = 2)
)
),
dashboardBody(
tabBox(
width=12,
tabPanel("About",
includeMarkdown(system.file("extdata", "about.md",package = "pcaExplorer"))),
tabPanel("Instructions",
includeMarkdown(system.file("extdata", "instructions.md",package = "pcaExplorer"))),
tabPanel("Data Preview",
h1("Here will go some head of the count dataset, the samples design/covariates and so"),
DT::dataTableOutput("inspectMatrix")),
tabPanel("Main View",
p(h1('MAIN VIEW')),
selectInput("geneInput","type the name of a gene",choices = c("",genenames),selected = NULL),
selectInput("kdInput","type the name of a knockdown condition",choices = c("",alltheknockdowns),selected = NULL),
h2("AFFECTED GENES"),
textOutput("printAffectedGenes"),
h2("INVOLVED CONDITIONS"),
textOutput("printConditionsInvolved")
)
)
),
skin="blue"
)
## ------------------------------------------------------------------ ##
## Define server ##
## ------------------------------------------------------------------ ##
newserver <- function(input, output) {
output$inspectMatrix <- renderDataTable({
head(proto_kdmat,20)
})
affectedGenes <- reactive({
allgenes_selectedKD <- proto_kdmat[,colnames(proto_kdmat) %in% input$kdInput,drop=FALSE] # force staying as a matrix
affectedGenes <- rownames(allgenes_selectedKD)[allgenes_selectedKD==1]
return(affectedGenes)
})
output$printAffectedGenes <- renderPrint({
cat(paste0("The following genes are affected in the",input$kdInput," condition:\n",
paste(affectedGenes(), collapse=", ")))
})
conditionsInvolved <- reactive({
allconds_selectedGene <- proto_kdmat[(rownames(proto_kdmat) %in% input$geneInput),,drop=FALSE] # force staying as a matrix
involvedConds <- colnames(allconds_selectedGene)[allconds_selectedGene==1]
return(involvedConds)
})
output$printConditionsInvolved <- renderPrint({
cat(paste0("The following conditions are involved in the regulation of the ",input$geneInput," gene:\n",
paste(conditionsInvolved(), collapse=", ")))
})
}
shinyApp(ui = newuiui, server = newserver)
}