-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize_custom_gene_sets.Rmd
125 lines (102 loc) · 3.94 KB
/
visualize_custom_gene_sets.Rmd
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
```{r}
library(shiny)
library(visNetwork)
options(shiny.trace = TRUE)
```
# Custom protein sets
## {.sidebar data-width="200" .opening-page-text}
#### Legend
<p class='options-text'><b>Kinase groups by color</b></p>
```{r}
imageOutput('legend3',height="auto")
output$legend3 <- renderImage({
list(src='img/kinase_families_legend2.png',width="100%",padding="0px 0px 5px 0px")
},deleteFile=FALSE)
```
#### Include more proteins
```{r,cache=FALSE}
checkboxInput(inputId='toggleOneDegree3', "Proteins adjacent to selected set", value = FALSE)
checkboxInput(inputId='toggleDisconnected3', "Proteins with no interactions", value = FALSE)
```
#### Layout
```{r,cache=FALSE}
selectizeInput('layout3',label=NULL,choices=names(layout_choices),selected="Default",multiple=FALSE)
```
#### Export
```{r, cache=FALSE}
selectizeInput('download_choice3',label=NULL,choices=names(export_choices))
filename3 <- reactive({export_choices[[input$download_choice3]]})
(downloadButton('download3',"Download"))
output$download3 <- downloadHandler(
filename=function() {paste(c('custom',filename3(), collapse='_'))},
content = function(file) {export_method(filename3(),g3(),file)}
)
```
## Main Panel {data-width=750}
#### Provide a custom set of proteins {.opening-page-text}
Visualize kinase-substrate interactions within any protein set. Paste a set of gene symbols in the text box below, then click Submit.
<p class='options-text'>
If the selected set does not include any interactions, you may not see any nodes or edges. Use the sidebar options to <b>include more proteins</b>.
</p>
```{r,cache=FALSE}
textAreaInput('customGeneList', label=NULL, value = NULL, height="100px",width = "98%")
actionButton('submit', "Submit")
actionButton('example',"Load an example")
actionButton('clear',"Clear")
initialGeneList3 <- reactiveVal('')
notFound <- reactiveVal(c())
textOutput('displayNotFound',inline=TRUE)
output$displayNotFound <- renderText({
if(length(notFound())==0) {""} else {paste(c("Warning! Genes not found: ",notFound()))}
})
default_gene_set <- "EGFR INSR MAPK1 GAB1 IRS1 PTPN1"
observeEvent(input$example,{updateTextAreaInput(session,'customGeneList', value=paste(default_gene_set))})
observeEvent(input$clear,{updateTextAreaInput(session,'customGeneList', value="")})
observeEvent(input$submit,{
s <- gsub(",","",toupper(isolate(input$customGeneList)))
genes <- unique(base::scan(text=s,what=""))
initialGeneList3(intersect(genes,all_nodes$GeneName))
notFound(setdiff(genes,all_nodes$GeneName))
})
```
##### {}
### {}
```{r,cache=FALSE}
g3 <- reactive({get_pathway_graph(initialGeneList3(),input$toggleOneDegree3,input$toggleDisconnected3)})
visNetworkOutput('network3')
output$network3 <- renderVisNetwork({
vis_default(g3()) %>%
visEvents(select="function(nodes){Shiny.onInputChange('selectNode3',nodes.nodes);}") %>%
visEvents(doubleClick="function(nodes){Shiny.onInputChange('nextCenterNode',nodes.nodes)}") %>%
visEvents(selectEdge = "function(edges) {Shiny.setInputValue('selectedEdges3', edges);}") %>%
visIgraphLayout(layout=layout_choices[[input$layout3]])
})
infoGene3 <- reactive({
if(is.null(input$selectNode3)) {NULL} else {get_gene_name(input$selectNode3)}
})
infoEdge3 <- reactive({
req(input$selectedEdges3)
req(input$selectedEdges3$edges)
req(g3())
req(g3()$edges)
edge_id <- input$selectedEdges3$edges
e <- g3()$edges %>% filter(id == edge_id)
req(nrow(e)==1)
render_edge_info(e)
})
```
## {data-width="650" .opening-page-text}
### {data-height="500"}
#### Interaction information
<p class='options-text'> <b> Click on an edge</b> </p>
```{r,cache=FALSE}
renderUI({infoEdge3()})
```
### {data-height="140"}
#### Troubleshooting
<div class="options-text">
<p><b>Not laid out as expected? </b></p>
<p>Try a different layout, or, manually move nodes around.</p>
<p><b>Not seeing any interactions?</b></p>
<p>There may be none in the selected set. Use the options provided to <b>include more proteins</b>. </p>
</div>