Skip to content

Commit aeef8ae

Browse files
anikde07PaulJonasJost
andauthoredMar 25, 2025··
Png svg fix (#531)
* Fixed png_device() not opening issue when saving plots and application crashing when saving plots in certain tabs * Made formated Sys.time() the norm for all plot downloads * Added SVG as an option * integrated comments * slight adjustments --------- Co-authored-by: PaulJonasJost <[email protected]>
1 parent 0def6e9 commit aeef8ae

File tree

16 files changed

+42
-42
lines changed

16 files changed

+42
-42
lines changed
 

‎program/shinyApp/R/enrichment_analysis/server.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ enrichment_analysis_geneset_server <- function(
101101
# Saving Plot
102102
output$SavePlot <- downloadHandler(
103103
filename = function() {
104-
paste(id,Sys.time(),input$file_ext,sep=" ")
104+
paste0(id,format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input$file_ext)
105105
},
106106
content = function(file){
107107
ggsave(

‎program/shinyApp/R/enrichment_analysis/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ geneset_panel_UI <- function(
4848
radioGroupButtons(
4949
inputId = ns("file_ext"),
5050
label = "File Type:",
51-
choices = c(".png", ".tiff", ".pdf"),
51+
choices = c(".png", ".tiff", ".svg", ".pdf"),
5252
selected = ".pdf"
5353
)
5454
),

‎program/shinyApp/R/heatmap/server.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ heatmap_server <- function(id){moduleServer(
356356

357357
output$SavePlot_Heatmap <- downloadHandler(
358358
filename = function() {
359-
paste0(isolate(heatmap_title()), " ", Sys.time(), input$file_ext_Heatmap)
359+
paste0(isolate(heatmap_title()), "_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Heatmap)
360360
},
361361
content = function(file){
362362
save_complex_heatmap(
@@ -373,7 +373,7 @@ heatmap_server <- function(id){moduleServer(
373373
tmp_filename <- paste0(
374374
getwd(),
375375
file_path,
376-
paste(paste0(isolate(heatmap_title()), Sys.time(), ".png"))
376+
paste0(isolate(heatmap_title()), Sys.Date(), ".png")
377377
)
378378
save_complex_heatmap(
379379
isolate(heatmap_plot()),

‎program/shinyApp/R/heatmap/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ heatmap_main <- function(ns){
155155
radioGroupButtons(
156156
inputId = ns("file_ext_Heatmap"),
157157
label = "File Type:",
158-
choices = c(".png", ".tiff", ".pdf"),
158+
choices = c(".png", ".tiff", ".svg", ".pdf"),
159159
selected = ".png"
160160
)
161161
),

‎program/shinyApp/R/pca/server.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ pca_Server <- function(id){
637637
paste0(create_default_title_pca(
638638
pcs = paste0(input$x_axis_selection," vs ",input$y_axis_selection),
639639
preprocessing = par_tmp[[session$token]]['preprocessing_procedure']
640-
), Sys.time(), input$file_ext_plot1)
640+
), format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_plot1)
641641
},
642642
content = function(file){
643643
ggsave(
@@ -651,7 +651,7 @@ pca_Server <- function(id){
651651

652652
output$SavePlot_Scree <- downloadHandler(
653653
filename = function() {
654-
paste0("Scree_Plot_", Sys.time(), input$file_ext_Scree)
654+
paste0("Scree_Plot_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Scree)
655655
},
656656
content = function(file){
657657
ggsave(
@@ -664,7 +664,7 @@ pca_Server <- function(id){
664664
)
665665

666666
output$SavePlot_Loadings <- downloadHandler(
667-
filename = function() { paste0("LOADINGS_PCA_", Sys.time(), input$file_ext_Loadings) },
667+
filename = function() { paste0("LOADINGS_PCA_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Loadings) },
668668
content = function(file){
669669
ggsave(
670670
file,
@@ -677,7 +677,7 @@ pca_Server <- function(id){
677677
)
678678

679679
output$SavePlot_Loadings_matrix <- downloadHandler(
680-
filename = function() { paste0("LOADINGS_Matrix_PCA_", Sys.time(), input$file_ext_Loadings_matrix) },
680+
filename = function() { paste0("LOADINGS_Matrix_PCA_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Loadings_matrix) },
681681
content = function(file){
682682
ggsave(
683683
file,

‎program/shinyApp/R/pca/ui.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pca_main_panel <- function(ns){
117117
radioGroupButtons(
118118
inputId = ns("file_ext_plot1"),
119119
label = "File Type:",
120-
choices = c(".png", ".tiff", ".pdf"),
120+
choices = c(".png", ".tiff", ".svg", ".pdf"),
121121
selected = ".png"
122122
)
123123
),
@@ -195,7 +195,7 @@ pca_main_panel <- function(ns){
195195
radioGroupButtons(
196196
inputId = ns("file_ext_Loadings"),
197197
label = "File Type:",
198-
choices = c(".png", ".tiff", ".pdf"),
198+
choices = c(".png", ".tiff", ".svg", ".pdf"),
199199
selected = ".png"
200200
)
201201
)
@@ -255,7 +255,7 @@ pca_main_panel <- function(ns){
255255
radioGroupButtons(
256256
inputId = ns("file_ext_Loadings_matrix"),
257257
label = "File Type:",
258-
choices = c(".png", ".tiff", ".pdf"),
258+
choices = c(".png", ".tiff", ".svg", ".pdf"),
259259
selected = ".png"
260260
)
261261
)
@@ -305,7 +305,7 @@ pca_main_panel <- function(ns){
305305
radioGroupButtons(
306306
inputId = ns("file_ext_Scree"),
307307
label = "File Type:",
308-
choices = c(".png", ".tiff", ".pdf"),
308+
choices = c(".png", ".tiff", ".svg", ".pdf"),
309309
selected = ".png"
310310
)
311311
)

‎program/shinyApp/R/pre_processing/ui.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pre_processing_main_panel <- mainPanel(
9494
radioGroupButtons(
9595
inputId = "file_type_mean_sd_plot",
9696
label = "File Type:",
97-
choices = c(".png", ".tiff", ".pdf"),
97+
choices = c(".png", ".tiff", ".svg", ".pdf"),
9898
selected = ".png"
9999
)
100100
), column(
@@ -116,9 +116,9 @@ pre_processing_main_panel <- mainPanel(
116116
class = "btn-info"
117117
),
118118
radioGroupButtons(
119-
inputId = "file_type_Preprocess",
119+
inputId = "file_ext_Preprocess",
120120
label = "File Type:",
121-
choices = c(".png", ".tiff", ".pdf"),
121+
choices = c(".png", ".tiff", ".svg", ".pdf"),
122122
selected = ".png"
123123
)
124124
)),

‎program/shinyApp/R/sample_correlation/server.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ sample_correlation_server <- function(id){
181181

182182
output$SavePlot_SampleCorrelation <- downloadHandler(
183183
filename = function() {
184-
paste0(sample_corr_reactive$customTitleSampleCorrelation, Sys.time(), input$file_ext_SampleCorrelation)
184+
paste0(sample_corr_reactive$customTitleSampleCorrelation, format(Sys.time(), "_(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_SampleCorrelation)
185185
},
186186
content = function(file){
187187
save_complex_heatmap(
@@ -200,7 +200,7 @@ sample_correlation_server <- function(id){
200200
tmp_filename <- paste0(
201201
getwd(),
202202
file_path,
203-
paste0(sample_corr_reactive$customTitleSampleCorrelation, Sys.time(), ".png")
203+
paste0(sample_corr_reactive$customTitleSampleCorrelation, Sys.Date(), ".png")
204204
)
205205

206206
save_complex_heatmap(

‎program/shinyApp/R/sample_correlation/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ sampleCorrelation_main_panel <- function(ns){
6969
radioGroupButtons(
7070
inputId = ns("file_ext_SampleCorrelation"),
7171
label = "File Type:",
72-
choices = c(".png", ".tiff", ".pdf"),
72+
choices = c(".png", ".tiff", ".svg", ".pdf"),
7373
selected = ".png"
7474
)
7575
),

‎program/shinyApp/R/significance_analysis/server.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ significance_analysis_server <- function(id){
474474
# Saving Plot
475475
output$SavePlot_Sig <- downloadHandler(
476476
filename = function() {
477-
paste0(id, Sys.time(), input$file_ext_Sig)
477+
paste0(id, format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Sig)
478478
},
479479
content = function(file){
480480
ggsave(

‎program/shinyApp/R/significance_analysis/tab_generator.R

+14-14
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,19 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n
157157
radioGroupButtons(
158158
inputId = ns("file_ext_Volcano"),
159159
label = "File Type:",
160-
choices = c(".png", ".tiff", ".pdf"),
160+
choices = c(".png", ".tiff", ".svg", ".pdf"),
161161
selected = ".png"
162162
),
163163
radioGroupButtons(
164164
inputId = ns("file_ext_Volcano_both"),
165165
label = "File Type:",
166-
choices = c(".png", ".tiff", ".pdf"),
166+
choices = c(".png", ".tiff", ".svg", ".pdf"),
167167
selected = ".png"
168168
),
169169
radioGroupButtons(
170170
inputId = ns("file_ext_Volcano_raw"),
171171
label = "File Type:",
172-
choices = c(".png", ".tiff", ".pdf"),
172+
choices = c(".png", ".tiff", ".svg", ".pdf"),
173173
selected = ".png"
174174
)
175175
)
@@ -484,7 +484,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n
484484
)
485485

486486
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano", sep = "_"))]] <- downloadHandler(
487-
filename = function() {paste0("VOLCANO_", Sys.time(), input[[ns("file_ext_Volcano")]])},
487+
filename = function() {paste0("VOLCANO_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input[[ns("file_ext_Volcano")]])},
488488
content = function(file){
489489
ggsave(
490490
filename = file,
@@ -501,7 +501,7 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n
501501
})
502502
})
503503
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano_raw", sep = "_"))]] <- downloadHandler(
504-
filename = function() { paste("raw_VOLCANO",Sys.time(),input[[ns("file_ext_Volcano_raw")]],sep="") },
504+
filename = function() { paste("raw_VOLCANO",format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input[[ns("file_ext_Volcano_raw")]],sep="") },
505505
content = function(file){
506506
ggsave(
507507
filename = file,
@@ -518,12 +518,12 @@ create_new_tab_manual <- function(title, targetPanel, result, contrast, alpha, n
518518
})
519519
})
520520
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano_both", sep = "_"))]] <- downloadHandler(
521-
filename = function() { paste0("VOLCANO_",Sys.time(),input[[ns("file_ext_Volcano")]]) },
521+
filename = function() { paste0("VOLCANO_",format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input[[ns("file_ext_Volcano_both")]]) },
522522
content = function(file){
523523
ggsave(
524524
filename = file,
525525
plot = gridExtra::arrangeGrob(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$VolcanoPlot),
526-
device = gsub("\\.","",input[[ns("file_ext_Volcano")]])
526+
device = gsub("\\.","",input[[ns("file_ext_Volcano_both")]])
527527
)
528528
on.exit({
529529
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")
@@ -702,19 +702,19 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
702702
radioGroupButtons(
703703
inputId = ns("file_ext_Volcano"),
704704
label = "File Type:",
705-
choices = c(".png", ".tiff", ".pdf"),
705+
choices = c(".png", ".tiff", ".svg", ".pdf"),
706706
selected = ".png"
707707
),
708708
radioGroupButtons(
709709
inputId = ns("file_ext_Volcano_both"),
710710
label = "File Type:",
711-
choices = c(".png", ".tiff", ".pdf"),
711+
choices = c(".png", ".tiff", ".svg", ".pdf"),
712712
selected = ".png"
713713
),
714714
radioGroupButtons(
715715
inputId = ns("file_ext_Volcano_raw"),
716716
label = "File Type:",
717-
choices = c(".png", ".tiff", ".pdf"),
717+
choices = c(".png", ".tiff", ".svg", ".pdf"),
718718
selected = ".png"
719719
)
720720
)
@@ -1023,7 +1023,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
10231023
)
10241024

10251025
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano", sep = "_"))]] <- downloadHandler(
1026-
filename = function() { paste("VOLCANO_",Sys.time(),input[[ns("file_ext_Volcano")]],sep="") },
1026+
filename = function() { paste("VOLCANO_",format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input[[ns("file_ext_Volcano")]],sep="") },
10271027
content = function(file){
10281028
ggsave(
10291029
filename = file,
@@ -1043,7 +1043,7 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
10431043
})
10441044
})
10451045
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano_raw", sep = "_"))]] <- downloadHandler(
1046-
filename = function() { paste("raw_VOLCANO",Sys.time(),input[[ns("file_ext_Volcano_raw")]],sep="") },
1046+
filename = function() { paste("raw_VOLCANO",format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input[[ns("file_ext_Volcano_raw")]],sep="") },
10471047
content = function(file){
10481048
ggsave(
10491049
filename = file,
@@ -1061,12 +1061,12 @@ create_new_tab_DESeq <- function(title, targetPanel, result, contrast, alpha, ns
10611061
})
10621062
})
10631063
output[[ns(paste(contrast[1], contrast[2], "SavePlot_Volcano_both", sep = "_"))]] <- downloadHandler(
1064-
filename = function() { paste0("VOLCANO_",Sys.time(),input[[ns("file_ext_Volcano")]]) },
1064+
filename = function() { paste0("VOLCANO_",format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"),input[[ns("file_ext_Volcano_both")]]) },
10651065
content = function(file){
10661066
ggsave(
10671067
filename = file,
10681068
plot = gridExtra::arrangeGrob(sig_ana_reactive$VolcanoPlot_raw, sig_ana_reactive$VolcanoPlot),
1069-
device = gsub("\\.","",input[[ns("file_ext_Volcano")]])
1069+
device = gsub("\\.","",input[[ns("file_ext_Volcano_both")]])
10701070
)
10711071
on.exit({
10721072
fun_LogIt(message = "## Differential analysis - Volcano {.tabset .tabset-fade}")

‎program/shinyApp/R/significance_analysis/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ significance_analysis_main_ui <- function(ns){
109109
radioGroupButtons(
110110
inputId = ns("file_ext_Sig"),
111111
label = "File Type:",
112-
choices = c(".png", ".tiff", ".pdf"),
112+
choices = c(".png", ".tiff", ".svg", ".pdf"),
113113
selected = ".png"
114114
)
115115
),

‎program/shinyApp/R/single_gene_visualisation/server.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ single_gene_visualisation_server <- function(id){
276276
output$SavePlot_singleGene <- downloadHandler(
277277
filename = function() {
278278
paste0(
279-
"Single_Gene_Boxplot_", Sys.time(), input$file_ext_singleGene
279+
"Single_Gene_Boxplot_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_singleGene
280280
)
281281
},
282282
content = function(file){

‎program/shinyApp/R/single_gene_visualisation/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ single_gene_visualisation_main_ui <- function(ns){
7070
radioGroupButtons(
7171
inputId = ns("file_ext_singleGene"),
7272
label = "File Type:",
73-
choices = c(".png", ".tiff", ".pdf"),
73+
choices = c(".png", ".tiff", ".svg", ".pdf"),
7474
selected = ".png"
7575
)
7676
),

‎program/shinyApp/server.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ server <- function(input,output,session){
18891889
## Preprocessing save, Report and Code Snippet
18901890
output$SavePlot_Preprocess <- downloadHandler(
18911891
filename = function() {
1892-
paste0("Preprocessing_ViolinPlot_", Sys.Date(), input$file_ext_Preprocess)
1892+
paste0("Preprocessing_ViolinPlot_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_ext_Preprocess)
18931893
},
18941894
content = function(file) {
18951895
# Create individual plots
@@ -1914,7 +1914,7 @@ server <- function(input,output,session){
19141914
width = 16, # Increase the width of the figure
19151915
height = 8, # Adjust height if necessary
19161916
units = "in",
1917-
device = gsub("\\.","",input$file_type_mean_sd_plot)
1917+
device = gsub("\\.","",input$file_ext_Preprocess)
19181918
)
19191919
on.exit({shinyjs::click("only2Report_Preprocess")})
19201920
}
@@ -1950,7 +1950,7 @@ server <- function(input,output,session){
19501950
width = 16, # Increase the width of the figure
19511951
height = 8, # Adjust height if necessary
19521952
units = "in",
1953-
device = gsub("\\.","",input$file_type_Preprocess)
1953+
device = gsub("\\.","",input$file_ext_Preprocess)
19541954
)
19551955
fun_LogIt(message = "## PreProcessing Violin Plot{.tabset .tabset-fade}")
19561956
fun_LogIt(message = "### Info")
@@ -2010,7 +2010,7 @@ server <- function(input,output,session){
20102010
)
20112011
output$SavePlot_mean_sd_plot <- downloadHandler(
20122012
filename = function() {
2013-
paste0("Preprocessing_mean_sd_plot_", Sys.Date(), input$file_type_mean_sd_plot)
2013+
paste0("Preprocessing_mean_sd_plot_", format(Sys.time(), "(%d.%m.%Y)_(%H;%M;%S)"), input$file_type_mean_sd_plot)
20142014
},
20152015
content = function(file) {
20162016
# Save the combined plot

‎program/shinyApp/ui.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ library(pcaPP) # requires gfortran. Not sure how to install on server
4747
library(reshape2)
4848
library(cowplot) # already imported but now we use it explicitly
4949
library("ComplexHeatmap")
50-
# library(svglite)
50+
library(svglite)
5151
library(formattable)
5252
library(codetools)
5353
library(vsn)

0 commit comments

Comments
 (0)
Please sign in to comment.