@@ -224,74 +224,80 @@ app_server <- function(input, output, session) {
224224 })
225225
226226 static_gene <- reactive({
227- gene_warning = NULL
228- withCallingHandlers({
229- p <- vis_gene(
230- spe ,
231- sampleid = input $ sample ,
232- geneid = input $ geneid ,
233- multi_gene_method = input $ multi_gene_method ,
234- assayname = input $ assayname ,
235- minCount = input $ minCount ,
236- cont_colors = cont_colors(),
237- image_id = input $ imageid ,
238- alpha = input $ alphalevel ,
239- point_size = input $ pointsize ,
240- auto_crop = input $ auto_crop ,
241- is_stitched = is_stitched
242- )
243- if (! input $ side_by_side_gene ) {
244- p_result = p
245- } else {
246- p_no_spots <- p
247- p_no_spots $ layers [[2 ]] <- NULL
248-
249- p_no_spatial <- p
250- p_no_spatial $ layers [[1 ]] <- NULL
251- p_result = cowplot :: plot_grid(
252- plotlist = list (
253- p_no_spots ,
254- p_no_spatial + ggplot2 :: theme(legend.position = " none" )
255- ),
256- nrow = 1 ,
257- ncol = 2
227+ gene_warning <- NULL
228+ withCallingHandlers(
229+ {
230+ p <- vis_gene(
231+ spe ,
232+ sampleid = input $ sample ,
233+ geneid = input $ geneid ,
234+ multi_gene_method = input $ multi_gene_method ,
235+ assayname = input $ assayname ,
236+ minCount = input $ minCount ,
237+ cont_colors = cont_colors(),
238+ image_id = input $ imageid ,
239+ alpha = input $ alphalevel ,
240+ point_size = input $ pointsize ,
241+ auto_crop = input $ auto_crop ,
242+ is_stitched = is_stitched
258243 )
244+ if (! input $ side_by_side_gene ) {
245+ p_result <- p
246+ } else {
247+ p_no_spots <- p
248+ p_no_spots $ layers [[2 ]] <- NULL
249+
250+ p_no_spatial <- p
251+ p_no_spatial $ layers [[1 ]] <- NULL
252+ p_result <- cowplot :: plot_grid(
253+ plotlist = list (
254+ p_no_spots ,
255+ p_no_spatial + ggplot2 :: theme(legend.position = " none" )
256+ ),
257+ nrow = 1 ,
258+ ncol = 2
259+ )
260+ }
261+ },
262+ warning = function (w ) {
263+ gene_warning <<- conditionMessage(w )
264+ invokeRestart(" muffleWarning" )
259265 }
260- }, warning = function (w ) {
261- gene_warning <<- conditionMessage(w )
262- invokeRestart(" muffleWarning" )
263- })
266+ )
264267 return (list (p = p_result , gene_warning = gene_warning ))
265268 })
266269
267270 static_gene_grid <- reactive({
268271 input $ gene_grid_update
269272
270- gene_grid_warnings = NULL
271- withCallingHandlers({
272- plots <-
273- vis_grid_gene(
274- spe ,
275- geneid = isolate(input $ geneid ),
276- multi_gene_method = input $ multi_gene_method ,
277- assayname = isolate(input $ assayname ),
278- minCount = isolate(input $ minCount ),
279- return_plots = TRUE ,
280- spatial = isolate(input $ grid_spatial_gene ),
281- cont_colors = isolate(cont_colors()),
282- image_id = isolate(input $ imageid ),
283- alpha = isolate(input $ alphalevel ),
284- point_size = isolate(input $ pointsize ),
285- sample_order = isolate(input $ gene_grid_samples ),
286- auto_crop = isolate(input $ auto_crop ),
287- is_stitched = is_stitched
288- )
289- }, warning = function (w ) {
290- gene_grid_warnings <<- c(gene_grid_warnings , conditionMessage(w ))
291- invokeRestart(" muffleWarning" )
292- })
273+ gene_grid_warnings <- NULL
274+ withCallingHandlers(
275+ {
276+ plots <-
277+ vis_grid_gene(
278+ spe ,
279+ geneid = isolate(input $ geneid ),
280+ multi_gene_method = input $ multi_gene_method ,
281+ assayname = isolate(input $ assayname ),
282+ minCount = isolate(input $ minCount ),
283+ return_plots = TRUE ,
284+ spatial = isolate(input $ grid_spatial_gene ),
285+ cont_colors = isolate(cont_colors()),
286+ image_id = isolate(input $ imageid ),
287+ alpha = isolate(input $ alphalevel ),
288+ point_size = isolate(input $ pointsize ),
289+ sample_order = isolate(input $ gene_grid_samples ),
290+ auto_crop = isolate(input $ auto_crop ),
291+ is_stitched = is_stitched
292+ )
293+ },
294+ warning = function (w ) {
295+ gene_grid_warnings <<- c(gene_grid_warnings , conditionMessage(w ))
296+ invokeRestart(" muffleWarning" )
297+ }
298+ )
293299
294- p_result = cowplot :: plot_grid(
300+ p_result <- cowplot :: plot_grid(
295301 plotlist = plots ,
296302 nrow = isolate(input $ gene_grid_nrow ),
297303 ncol = isolate(input $ gene_grid_ncol )
@@ -455,7 +461,7 @@ app_server <- function(input, output, session) {
455461 height = 8 ,
456462 width = 8 * ifelse(input $ side_by_side_gene , 2 , 1 )
457463 )
458- print(static_gene()[[' p ' ]])
464+ print(static_gene()[[" p " ]])
459465 dev.off()
460466 }
461467 )
@@ -483,7 +489,7 @@ app_server <- function(input, output, session) {
483489 height = 8 * isolate(input $ gene_grid_nrow ),
484490 width = 8 * isolate(input $ gene_grid_ncol )
485491 )
486- print(static_gene_grid()[[' p ' ]])
492+ print(static_gene_grid()[[" p " ]])
487493 dev.off()
488494 }
489495 )
@@ -548,7 +554,7 @@ app_server <- function(input, output, session) {
548554
549555 output $ gene <- renderPlot(
550556 {
551- static_gene()[[' p ' ]]
557+ static_gene()[[" p " ]]
552558 },
553559 width = function () {
554560 600 * ifelse(input $ side_by_side_gene , 2 , 1 )
@@ -560,9 +566,12 @@ app_server <- function(input, output, session) {
560566 # Since 'static_gene()' is invoked twice (once also in the assignment
561567 # of 'output$gene'), we silence any errors that occur in this second
562568 # invocation to not duplicate error messages
563- this_warning = NULL
564- temp = try(
565- { this_warning = static_gene()[[' gene_warning' ]] }, silent = TRUE
569+ this_warning <- NULL
570+ temp <- try(
571+ {
572+ this_warning <- static_gene()[[" gene_warning" ]]
573+ },
574+ silent = TRUE
566575 )
567576
568577 if (! is.null(this_warning )) {
@@ -585,7 +594,7 @@ app_server <- function(input, output, session) {
585594
586595 output $ gene_grid <- renderPlot(
587596 {
588- print(static_gene_grid()[[' p ' ]])
597+ print(static_gene_grid()[[" p " ]])
589598 },
590599 width = " auto" ,
591600 height = " auto"
@@ -595,9 +604,11 @@ app_server <- function(input, output, session) {
595604 # Since 'static_gene_grid()' is invoked twice (once also in the
596605 # assignment of 'output$gene_grid'), we silence any errors that occur
597606 # in this second invocation to not duplicate error messages
598- these_warnings = NULL
599- temp = try(
600- { these_warnings = static_gene_grid()[[' gene_grid_warnings' ]] },
607+ these_warnings <- NULL
608+ temp <- try(
609+ {
610+ these_warnings <- static_gene_grid()[[" gene_grid_warnings" ]]
611+ },
601612 silent = TRUE
602613 )
603614
0 commit comments