Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this user
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
HendrikSchultheis
/
wilson
Public
forked from
loosolab/wilson
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
233d37d
.buildkite
R
exec
inst
extdata
templates
geneView_wilson.Rmd
heatmap_wilson.Rmd
scatterplot_wilson.Rmd
www
man
revdep
tests
vignettes
.Rbuildignore
DESCRIPTION
LICENSE
NAMESPACE
NEWS.md
README.md
cran-comments.md
wilson.Rproj
Breadcrumbs
wilson
/
inst
/
templates
/
geneView_wilson.Rmd
Blame
Blame
Latest commit
History
History
272 lines (228 loc) · 9.95 KB
Breadcrumbs
wilson
/
inst
/
templates
/
geneView_wilson.Rmd
Top
File metadata and controls
Code
Blame
272 lines (228 loc) · 9.95 KB
Raw
### {{ title }} <!-- Component created on {{ date }} --> ```{r} {{ env_id }} <- readRDS("envs/{{ env_id }}.rds") is_shiny <- identical(knitr::opts_knit$get("rmarkdown.runtime"), "shiny") ``` ```{r, eval=!is_shiny} # Parameters for wilson::create_geneview() # params <- list() "%ni%" <- Negate("%in%") additional_arguments <- {{ env_id }}$additional_arguments if("plot.type" %ni% names({{ env_id }}$additional_arguments)){ additional_arguments$plot.type <- "line" } if("facet.target" %ni% names({{ env_id }}$additional_arguments)){ additional_arguments$facet.target <- "gene" } if("facet.cols" %ni% names({{ env_id }}$additional_arguments)){ additional_arguments$facet.cols <- 3 } if("color" %ni% names({{ env_id }}$additional_arguments)){ color <- RColorBrewer::brewer.pal(8, "Accent") additional_arguments$color <- color } # force static additional_arguments$plot.method <- "static" # set variables countTable <- {{ env_id }}$countTable group_by <- {{ env_id }}$group_by[1] # create data.tables "data" and "grouping" from provided data data <- data.table::data.table("features" = rownames(countTable), countTable) grouping <- data.table::data.table("keys" = colnames(countTable), "factor" = group_by[[1]]) additional_arguments$data <- data additional_arguments$grouping <- grouping # Provide data for download #i2dash::embed_var(data) # Render plot output_list <- do.call(wilson::create_geneview, additional_arguments) plot <- output_list$plot plot ``` ```{r, eval=is_shiny} ################ UI #################### ui_list <- list() # select type of plot ui_list <- rlist::list.append(ui_list, selectInput("select_type_{{ env_id }}", label = "Type of Plot:", choices = c("line", "box", "violin", "bar"), selected = "line")) # subset features ui_list <- rlist::list.append(ui_list, selectInput("select_subset_{{ env_id }}", label = "Select features:", choices = rownames({{ env_id }}$countTable), multiple = TRUE) ) # selection field for group_by if ({{ env_id }}$group_by_selection){ ui_list <- rlist::list.append(ui_list, selectInput("select_group_by_{{ env_id }}", label = "Select grouping:", choices = names({{ env_id }}$group_by))) } # selection grouping by ui_list <- rlist::list.append(ui_list, selectInput("select_by_{{ env_id }}", label = "Grouping by:", choices = c("gene", "condition"), selected = "gene", multiple = FALSE) ) # selection column number of plot ui_list <- rlist::list.append(ui_list, sliderInput("colnumber_{{ env_id }}", label = "Number of plot columns:", min = 1, max = 7, value = 3) ) # Download link ui_list <- rlist::list.append(ui_list, tags$div(tags$br(), downloadButton('downloadData_{{ env_id }}', 'Download data'))) ################# Server #################### # if component is a reciever if({{ env_id }}$compId %in% edgeTable$reciever){ # set variables reciever_{{ env_id }} <- {{ env_id }}$compId transmitter_to_{{ env_id }} <- edgeTable[reciever=={{ env_id }}$compId]$transmitter df_{{ env_id }} <- shiny::reactive({ # Parameters for wilson::create_geneview() # params <- list() "%ni%" <- Negate("%in%") additional_arguments <- {{ env_id }}$additional_arguments # type of plot additional_arguments$plot.type <- input$select_type_{{ env_id }} # type of grouping by additional_arguments$facet.target <- input$select_by_{{ env_id }} # number of columns in plot additional_arguments$facet.cols <- input$colnumber_{{ env_id }} if("color" %ni% names({{ env_id }}$additional_arguments)){ color <- RColorBrewer::brewer.pal(8, "Accent") additional_arguments$color <- color } additional_arguments$plot.method <- "static" # Set values for 'group_by' and 'countTable' if( !{{ env_id }}$group_by_selection ) { group_by <- {{ env_id }}$group_by[1] } else { group_by <- {{ env_id }}$group_by[input$select_group_by_{{ env_id }}] } countTable <- {{ env_id }}$countTable # subset countTable according to transmitted sample keys plot_transmitter_string <- paste0("plot_env_", transmitter_to_{{ env_id }}) keys_transmitter_string <- paste0("df_env_", transmitter_to_{{ env_id }}, "()$key") selection_transmitter <- plotly::event_data("plotly_selected", source = plot_transmitter_string)$key if(!is.null(selection_transmitter)){ if(all(selection_transmitter %in% colnames(countTable))){ countTable <- subset(countTable, select = selection_transmitter) # subset group_by according to countTable group_by <- group_by[[1]][which(colnames(countTable) == selection_transmitter)] group_by <- list("group_by" = group_by) } else { false_keys <- which(!(selection_transmitter %in% colnames(countTable))) print("The following keys are not in the countTable:") print(selection_transmitter[false_keys]) if(!is.null(ncol(selection_transmitter[-false_keys]))){ selection_transmitter <- selection_transmitter[-false_keys] countTable <- subset(countTable, select = selection_transmitter) # subset group_by according to countTable group_by <- group_by[[1]][which(colnames(countTable) == selection_transmitter)] group_by <- list("group_by" = group_by) } } } # subset countTable by chosen features if(!is.null(input$select_subset_{{ env_id }})){ subset_features <- input$select_subset_{{ env_id }} if(length(subset_features) > 1){ countTable <- countTable[subset_features,] } else if(length(subset_features) == 1){ countTable <- countTable[subset_features,,drop = FALSE] } } # create data.tables "data" and "grouping" from provided data data <- data.table::data.table("features" = rownames(countTable), countTable) grouping <- data.table::data.table("keys" = colnames(countTable), "factor" = group_by[[1]]) download_dt <- data.table::data.table("features" = rownames(countTable), "factor" = group_by[[1]], countTable) additional_arguments$data <- data additional_arguments$grouping <- grouping #additional_arguments$width <- 20 #additional_arguments$height <- 15 return(list("params" = additional_arguments, "data" = download_dt)) }) } else { df_{{ env_id }} <- shiny::reactive({ # Parameters for wilson::create_geneview() # params <- list() "%ni%" <- Negate("%in%") additional_arguments <- {{ env_id }}$additional_arguments # type of plot additional_arguments$plot.type <- input$select_type_{{ env_id }} # type of grouping by additional_arguments$facet.target <- input$select_by_{{ env_id }} # number of columns in plot additional_arguments$facet.cols <- input$colnumber_{{ env_id }} if("color" %ni% names({{ env_id }}$additional_arguments)){ color <- RColorBrewer::brewer.pal(8, "Accent") additional_arguments$color <- color } additional_arguments$plot.method <- "static" # Set values for 'group_by' and 'countTable' if( !{{ env_id }}$group_by_selection ) { group_by <- {{ env_id }}$group_by[1] } else { group_by <- {{ env_id }}$group_by[input$select_group_by_{{ env_id }}] } countTable <- {{ env_id }}$countTable # subset countTable by chosen features if(!is.null(input$select_subset_{{ env_id }})){ subset_features <- input$select_subset_{{ env_id }} if(length(subset_features) > 1){ countTable <- countTable[subset_features,] } else if(length(subset_features) == 1){ countTable <- countTable[subset_features,,drop = FALSE] } } # # create data.tables "data" and "grouping" from provided data data <- data.table::data.table("features" = rownames(countTable), countTable) grouping <- data.table::data.table("keys" = colnames(countTable), "factor" = group_by[[1]]) download_dt <- data.table::data.table("features" = rownames(countTable), "factor" = group_by[[1]], countTable) additional_arguments$data <- data additional_arguments$grouping <- grouping #additional_arguments$width <- 20 #additional_arguments$height <- 15 return(list("params" = additional_arguments, "data" = download_dt)) }) } # Download output$downloadData_{{ env_id }} <- downloadHandler( filename = paste('data-', Sys.Date(), '.csv', sep=''), content = function(file) { write.csv(df_{{ env_id }}()$data, file) } ) # works as transmitter with brushopt plot_{{ env_id }} <- shiny::reactive({ if(!is.null(input$select_subset_{{ env_id }})){ output_list <- do.call(wilson::create_geneview, df_{{ env_id }}()$params) dt <- output_list$plot$data return(dt) } }) # Output output$plot_{{ env_id }} <- renderPlot({ if(!is.null(input$select_subset_{{ env_id }})){ output_list <- do.call(wilson::create_geneview, df_{{ env_id }}()$params) gg <- output_list$plot gg #p <- plotly::ggplotly(gg) #p } # convert to plotly object for automatic resizing }) # Layout of component shiny::fillRow(flex = c(NA, 1), shinyWidgets::dropdownButton(div(style='max-height: 350px; overflow-x: auto;',do.call(shiny::inputPanel, ui_list)), circle = TRUE, status = "danger", icon = icon("gear"), width = "300px", tooltip = shinyWidgets::tooltipOptions(title = "Click, to change plot settings:")), plotOutput("plot_{{ env_id }}", width = "100%",click = "plot1_click", brush = brushOpts( id = "plot1_brush" )) ) ```
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
You can’t perform that action at this time.