diff --git a/.gitignore b/.gitignore index a700a93..9498ad1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ apps/LOLAweb/shinylog apps/LOLAweb/results apps/LOLAweb/userSets apps/LOLAweb/scratch.R +*.rdb \ No newline at end of file diff --git a/apps/LOLAweb/about.md b/apps/LOLAweb/about.md index 0c798fe..10616e4 100644 --- a/apps/LOLAweb/about.md +++ b/apps/LOLAweb/about.md @@ -97,7 +97,13 @@ The columns in the results table are: ### How do I cite LOLAweb? -LOLAweb is pending publication. In the interim, please cite the LOLA R package: +LOLAweb is published in *Nucleic Acids Research*: + +V. P. Nagraj, N. E. Magee and N. C. Sheffield, "LOLAweb: a containerized web server for interactive genomic locus overlap enrichment analysis," Nucleic Acids Research, vol. 46, no. w1, pp. w194-w199, Jul. 2018. + +[https://doi.org/10.1093/nar/gky464](https://doi.org/10.1093/nar/gky464) + +The LOLA R package is published in *Bioinformatics*: N. C. Sheffield and C. Bock, “LOLA: enrichment analysis for genomic region sets and regulatory elements in R and Bioconductor,” Bioinformatics, vol. 32, no. 4, pp. 587–589, Oct. 2016. diff --git a/apps/LOLAweb/app.R b/apps/LOLAweb/app.R index c2863c7..99f724b 100644 --- a/apps/LOLAweb/app.R +++ b/apps/LOLAweb/app.R @@ -133,7 +133,11 @@ ui <- list( uiOutput("slider_pvalue"), uiOutput("select_collection"), uiOutput("select_sort"), - uiOutput("select_userset")), + uiOutput("select_userset"), + shinyjs::hidden( + downloadButton("all_plots_dl", + label = "Download all plots", + class = "dt-button"))), column(10, shinyjs::hidden( div( @@ -210,7 +214,8 @@ ui <- list( ), tabPanel("Run summary", h4("Run summary"), - tableOutput("run_sum"), style = "font-size:18px;") + tableOutput("run_sum"), + style = "font-size:18px;") ), id = "result-tabs"))) ) @@ -740,7 +745,6 @@ server <- function(input, output, session) { shinyjs::show("gear2") shinyjs::show("result-tabs") - # show help text for results sliders and plots shinyjs::show("infoplot_div") shinyjs::show("infodisplay_div") @@ -770,6 +774,8 @@ server <- function(input, output, session) { shinyjs::hide("gear2") shinyjs::show("scatterhead") + shinyjs::show("all_plots_dl") + } @@ -1064,7 +1070,7 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = scatterplot_input() + ggsave(file, plot = scatterplot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)) , device = "pdf") } ) @@ -1084,7 +1090,7 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = plot_input(dat(), "oddsRatio", "Odds ratio", input$select_sort_i) + ggsave(file, plot = plot_input(dat(), "oddsRatio", "Odds ratio", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)) , device = "pdf") } ) @@ -1118,7 +1124,7 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = plot_input(dat(), "support", "Support", input$select_sort_i) + ggsave(file, plot = plot_input(dat(), "support", "Support", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)) , device = "pdf") } ) @@ -1154,7 +1160,7 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = plot_input(dat(), "pValueLog", "log(p value)", input$select_sort_i) + ggsave(file, plot = plot_input(dat(), "pValueLog", "log(p value)", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)) , device = "pdf") } ) @@ -1167,7 +1173,7 @@ server <- function(input, output, session) { if (is.null(genDist)) { - NULL + missing_plot() } else { @@ -1195,7 +1201,7 @@ server <- function(input, output, session) { if (is.null(TSSDist)) { - NULL + missing_plot() } else { @@ -1222,7 +1228,7 @@ server <- function(input, output, session) { if(is.null(gp)) { - NULL + missing_plot() } else { @@ -1247,7 +1253,7 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = distrib_plot_input(), device = "pdf") + ggsave(file, plot = distrib_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), device = "pdf", width = 11, height = 5) } ) @@ -1256,19 +1262,74 @@ server <- function(input, output, session) { ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = dist_plot_input(), device = "pdf") + ggsave(file, plot = dist_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), device = "pdf") } ) output$part_plot_dl <- downloadHandler( - filename = function() { paste("paritions", + filename = function() { paste("partitions", ".pdf", sep="") }, content = function(file) { - ggsave(file, plot = part_plot_input(), device = "pdf") + ggsave(file, plot = part_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), device = "pdf") } ) + # to zip all plots and save individually ... + + output$all_plots_dl <- downloadHandler( + filename = function() { + paste("lolawebplots", "zip", sep=".") + }, + content = function(fname) { + + ggsave(filename = "scatter.pdf", + plot = scatterplot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + ggsave(filename = "oddsratio.pdf", + plot = plot_input(dat(), "oddsRatio", "Odds ratio", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + ggsave(filename = "support.pdf", + plot = plot_input(dat(), "support", "Support", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + ggsave(filename = "pvalue.pdf", + plot = plot_input(dat(), "pValueLog", "log(p value)", input$select_sort_i) + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + # using pdf() device here bc custom aspect ratio not working with ggsave() in this case + pdf("plots/gendist.pdf", width = 11, height = 5) + print(distrib_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9))) + dev.off() + + ggsave(filename = "tssdist.pdf", + plot = dist_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + ggsave(filename = "partitions.pdf", + plot = part_plot_input() + theme(axis.text = element_text(size = 9), text = element_text(size = 9)), + device = "pdf", + path = "plots") + + # identify files to be zipped and zip them + fs <- list.files("plots", full.names = TRUE) + zip(zipfile=fname, files=fs) + + # delete tmp plot files after zip is done + unlink(fs) + + }, + contentType = "application/zip" + + ) + # data table diff --git a/apps/LOLAweb/misc.R b/apps/LOLAweb/misc.R index 95cd68b..f3214ad 100644 --- a/apps/LOLAweb/misc.R +++ b/apps/LOLAweb/misc.R @@ -60,6 +60,22 @@ plot_input <- function(res, metric, ylabel, sortcol) { } +# missing_plot() creates +missing_plot <- function() { + + ggplot(data.frame(x=1:5, y = 1:5), aes(x, y)) + + geom_blank() + + annotate("text", x = 3, y = 4, label = "Unable to render plot", size = 10, col = "red") + + xlab("") + + ylab("") + + theme(line = element_blank(), + rect = element_blank(), + axis.ticks.length = unit(0,"cm"), + axis.text = element_blank(), + legend.position = "none", + panel.spacing = unit(0,"lines"), + plot.margin = unit(c(0, 0, 0, 0), "lines")) +} # This function just wraps the base Sys.gentenv function to provide a default # value for the case that the environment variable is not specified. diff --git a/docker/Dockerfile b/docker/Dockerfile index 1f34f74..de93945 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,6 +13,10 @@ RUN git clone https://github.com/databio/LOLAweb.git # add dir for cache RUN mkdir LOLAweb/cache RUN chown -R shiny:shiny LOLAweb/cache + +# add plots dir for zipping up all figures to download with one button +RUN mkdir LOLAweb/apps/LOLAweb/plots +RUN chown -R shiny:shiny LOLAweb/apps/LOLAweb/plots # run the server setup script CMD ["/usr/bin/shiny-server.sh"] diff --git a/docker/README.md b/docker/README.md index ba42064..dc87e43 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,6 +2,8 @@ # Shiny LOLAweb for Docker +The `databio/lolaweb` container is based on the `databio/shinybase` container, which you can find in its [github repository](https://github.com/databio/shinyBase) or [on dockerhub](https://hub.docker.com/r/databio/shinybase/). + ## `build` the container image yourself 1. Clone this repository diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index f146a37..718b84d 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -14,5 +14,9 @@ RUN git clone -b dev https://github.com/databio/LOLAweb.git RUN mkdir LOLAweb/cache RUN chown -R shiny:shiny LOLAweb/cache +# add plots dir for zipping up all figures to download with one button +RUN mkdir LOLAweb/apps/LOLAweb/plots +RUN chown -R shiny:shiny LOLAweb/apps/LOLAweb/plots + # run the server setup script CMD ["/usr/bin/shiny-server.sh"] diff --git a/docker/dev/shiny-server.sh b/docker/dev/shiny-server.sh index 2b7adb7..2a2c51f 100755 --- a/docker/dev/shiny-server.sh +++ b/docker/dev/shiny-server.sh @@ -5,6 +5,10 @@ mkdir -p /var/log/shiny-server chown shiny.shiny /var/log/shiny-server +# make sure relevant environment variables are visible to shiny server .Renviron +env | grep "LWLOCAL\|LWREF" > /home/shiny/.Renviron +chown shiny.shiny /home/shiny/.Renviron + exec shiny-server 2>&1 # done diff --git a/docker/shiny-server.sh b/docker/shiny-server.sh index 2b7adb7..2a2c51f 100755 --- a/docker/shiny-server.sh +++ b/docker/shiny-server.sh @@ -5,6 +5,10 @@ mkdir -p /var/log/shiny-server chown shiny.shiny /var/log/shiny-server +# make sure relevant environment variables are visible to shiny server .Renviron +env | grep "LWLOCAL\|LWREF" > /home/shiny/.Renviron +chown shiny.shiny /home/shiny/.Renviron + exec shiny-server 2>&1 # done diff --git a/docker/staging/Dockerfile b/docker/staging/Dockerfile deleted file mode 100644 index f146a37..0000000 --- a/docker/staging/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM databio/shinybase:latest - -MAINTAINER VP Nagraj "vpnagraj@virginia.edu" - -# move conf files -COPY shiny-server.conf /etc/shiny-server/shiny-server.conf -COPY shiny-server.sh /usr/bin/shiny-server.sh - -# get the code -WORKDIR /srv/shiny-server -RUN git clone -b dev https://github.com/databio/LOLAweb.git - -# add dir for cache -RUN mkdir LOLAweb/cache -RUN chown -R shiny:shiny LOLAweb/cache - -# run the server setup script -CMD ["/usr/bin/shiny-server.sh"] diff --git a/docker/staging/shiny-server.conf b/docker/staging/shiny-server.conf deleted file mode 100644 index 3f7e026..0000000 --- a/docker/staging/shiny-server.conf +++ /dev/null @@ -1,29 +0,0 @@ -# Define the user we should use when spawning R Shiny processes -run_as shiny; - -# disable websocket -disable_protocols websocket; - -# disable idle timeout to retain connection -app_idle_timeout 0; - -# Define a top-level server which will listen on a port -server { - # Instruct this server to listen on port 80. The app at dokku-alt need expose PORT 80, or 500 e etc. See the docs - listen 80; - - # Define the location available at the base URL - location / { - - # Run this location in 'site_dir' mode, which hosts the entire directory - # tree at '/srv/shiny-server' - site_dir /srv/shiny-server; - - # Define where we should put the log files for this location - log_dir /var/log/shiny-server; - - # Should we list the contents of a (non-Shiny-App) directory when the user - # visits the corresponding URL? - directory_index on; - } -} diff --git a/docker/staging/shiny-server.sh b/docker/staging/shiny-server.sh deleted file mode 100755 index 2b7adb7..0000000 --- a/docker/staging/shiny-server.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - - -# Make sure the directory for individual app logs exists -mkdir -p /var/log/shiny-server -chown shiny.shiny /var/log/shiny-server - -exec shiny-server 2>&1 - -# done