From af4b46052ca053431afc42174f7411ab34e3785a Mon Sep 17 00:00:00 2001 From: Schultheis Date: Tue, 15 Oct 2019 15:29:03 +0200 Subject: [PATCH 1/7] download: use orca for plotly downloads. Requires plotly > 4.8.0. --- DESCRIPTION | 2 +- R/function.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e200cc1..f02bd9e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ LazyData: true Imports: shiny, data.table, ggplot2, - plotly, + plotly (> 4.8.0), scales, shinydashboard, DT (>= 0.3), diff --git a/R/function.R b/R/function.R index 10b16c3..6648f67 100644 --- a/R/function.R +++ b/R/function.R @@ -1246,8 +1246,8 @@ download <- function(file, filename, plot, width, height, ppi = 72, save_plot = wd <- getwd() on.exit(setwd(wd)) # make sure working directory will be restored setwd(tempdir()) - plotly::export(p = plot, file = plot_file_pdf) - plotly::export(p = plot, file = plot_file_png) + plotly::orca(p = plot, file = plot_file_pdf) + plotly::orca(p = plot, file = plot_file_png) setwd(wd) } else if (class(plot) == "Heatmap") { # TODO: find better way to check for complexHeatmap object # complexHeatmap From b31580273d413740ee954f11de52b72a97d2eb56 Mon Sep 17 00:00:00 2001 From: Schultheis Date: Wed, 16 Oct 2019 11:00:07 +0200 Subject: [PATCH 2/7] download: omit filepath when using orca because it always prepends absolut path. --- R/function.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/function.R b/R/function.R index 6648f67..963d11d 100644 --- a/R/function.R +++ b/R/function.R @@ -1246,8 +1246,9 @@ download <- function(file, filename, plot, width, height, ppi = 72, save_plot = wd <- getwd() on.exit(setwd(wd)) # make sure working directory will be restored setwd(tempdir()) - plotly::orca(p = plot, file = plot_file_pdf) - plotly::orca(p = plot, file = plot_file_png) + # Omit file path because orca adds it regardles of it already being there. + plotly::orca(p = plot, file = basename(plot_file_pdf)) + plotly::orca(p = plot, file = basename(plot_file_png)) setwd(wd) } else if (class(plot) == "Heatmap") { # TODO: find better way to check for complexHeatmap object # complexHeatmap From 48443ca658867e7b299eba5f2ef6193dd3548353 Mon Sep 17 00:00:00 2001 From: Schultheis Date: Wed, 16 Oct 2019 11:05:53 +0200 Subject: [PATCH 3/7] download: use zip package to create archives. As the zip package is platform independent there is no longer the requirement to install Rtools on windows. --- DESCRIPTION | 3 ++- R/function.R | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f02bd9e..97aafc6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,7 +46,8 @@ Imports: shiny, openssl, methods, R6, - magrittr + magrittr, + zip RoxygenNote: 6.1.1 biocViews: Suggests: knitr, diff --git a/R/function.R b/R/function.R index 963d11d..0e6bbbc 100644 --- a/R/function.R +++ b/R/function.R @@ -1207,7 +1207,7 @@ searchData <- function(input, choices, options = c("=", "<", ">"), min. = min(ch #' @param save_plot Logical if plot object should be saved as .RData. #' @param ui List of user inputs. Will be converted to JavaScript Object Notation. See \code{\link[RJSONIO]{toJSON}} #' -#' @return See \code{\link[utils]{zip}}. +#' @return Path to zip archive. See \code{\link[zip]{zipr}}. download <- function(file, filename, plot, width, height, ppi = 72, save_plot = TRUE, ui = NULL) { session <- shiny::getDefaultReactiveDomain() @@ -1289,7 +1289,7 @@ download <- function(file, filename, plot, width, height, ppi = 72, save_plot = } # create zip file - out <- utils::zip(zipfile = file, files = files, flags = "-j") # discard file path + out <- zip::zipr(zipfile = file, files = files, include_directories = FALSE) # remove tmp files file.remove(files) From 313476292c451acfa2105f7d8c5edb66925839ee Mon Sep 17 00:00:00 2001 From: Schultheis Date: Wed, 16 Oct 2019 11:07:46 +0200 Subject: [PATCH 4/7] update download documentation --- R/function.R | 2 +- man/download.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/function.R b/R/function.R index 0e6bbbc..58fcb2f 100644 --- a/R/function.R +++ b/R/function.R @@ -1207,7 +1207,7 @@ searchData <- function(input, choices, options = c("=", "<", ">"), min. = min(ch #' @param save_plot Logical if plot object should be saved as .RData. #' @param ui List of user inputs. Will be converted to JavaScript Object Notation. See \code{\link[RJSONIO]{toJSON}} #' -#' @return Path to zip archive. See \code{\link[zip]{zipr}}. +#' @return Path to zip archive invisibly. See \code{\link[zip]{zipr}}. download <- function(file, filename, plot, width, height, ppi = 72, save_plot = TRUE, ui = NULL) { session <- shiny::getDefaultReactiveDomain() diff --git a/man/download.Rd b/man/download.Rd index a74245e..e500b7d 100644 --- a/man/download.Rd +++ b/man/download.Rd @@ -27,7 +27,7 @@ download(file, filename, plot, width, height, ppi = 72, \item{ui}{List of user inputs. Will be converted to JavaScript Object Notation. See \code{\link[RJSONIO]{toJSON}}} } \value{ -See \code{\link[utils]{zip}}. +Path to zip archive invisibly. See \code{\link[zip]{zipr}}. } \description{ Function used for downloading. From a062563bf5e54a43ab4425b97aca0b38f2ecca8c Mon Sep 17 00:00:00 2001 From: Schultheis Date: Wed, 16 Oct 2019 11:12:40 +0200 Subject: [PATCH 5/7] Update test plot svgs. This was needed because vdiffr had an update. --- .../create-static-plots/static-geneview.svg | 704 +++++++------- .../create-static-plots/static-heatmap.svg | 857 +++++++++--------- tests/figs/create-static-plots/static-pca.svg | 90 +- .../static-scatterplot.svg | 142 +-- tests/figs/deps.txt | 9 +- 5 files changed, 900 insertions(+), 902 deletions(-) diff --git a/tests/figs/create-static-plots/static-geneview.svg b/tests/figs/create-static-plots/static-geneview.svg index 6793332..22556ee 100644 --- a/tests/figs/create-static-plots/static-geneview.svg +++ b/tests/figs/create-static-plots/static-geneview.svg @@ -2,7 +2,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -190,25 +190,25 @@ - + - + - + - + - + @@ -222,25 +222,25 @@ - + - + - + - + - + @@ -254,270 +254,271 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Mazda RX4 -Mazda RX4 Wag -Datsun 710 -Hornet 4 Drive -Hornet Sportabout -Valiant -Duster 360 -Merc 240D -Merc 230 -Merc 280 -Merc 280C -Merc 450SE -Merc 450SL -Merc 450SLC -Cadillac Fleetwood -Lincoln Continental -Chrysler Imperial -Fiat 128 -Honda Civic -Toyota Corolla -Toyota Corona -Dodge Challenger -AMC Javelin -Camaro Z28 -Pontiac Firebird -Fiat X1-9 -Porsche 914-2 -Lotus Europa -Ford Pantera L -Ferrari Dino -Maserati Bora -Volvo 142E -mpg -cyl -disp -hp -drat -wt -qsec -vs -am -gear -carb -auto -0 -100 -200 -300 -400 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Mazda RX4 +Mazda RX4 Wag +Datsun 710 +Hornet 4 Drive +Hornet Sportabout +Valiant +Duster 360 +Merc 240D +Merc 230 +Merc 280 +Merc 280C +Merc 450SE +Merc 450SL +Merc 450SLC +Cadillac Fleetwood +Lincoln Continental +Chrysler Imperial +Fiat 128 +Honda Civic +Toyota Corolla +Toyota Corona +Dodge Challenger +AMC Javelin +Camaro Z28 +Pontiac Firebird +Fiat X1-9 +Porsche 914-2 +Lotus Europa +Ford Pantera L +Ferrari Dino +Maserati Bora +Volvo 142E +mpg +cyl +disp +hp +drat +wt +qsec +vs +am +gear +carb +auto +0 +100 +200 +300 +400 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/figs/create-static-plots/static-pca.svg b/tests/figs/create-static-plots/static-pca.svg index 609ff93..81b3f45 100644 --- a/tests/figs/create-static-plots/static-pca.svg +++ b/tests/figs/create-static-plots/static-pca.svg @@ -2,7 +2,7 @@