Skip to content

Commit

Permalink
Bug fix: plot can be exported
Browse files Browse the repository at this point in the history
Plots can be exported as png or pdf files
  • Loading branch information
JoachimGoedhart committed Oct 8, 2018
1 parent 5f0f7e2 commit 7fbde45
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 24 deletions.
36 changes: 24 additions & 12 deletions about.html
Expand Up @@ -6,32 +6,44 @@


<h3>About PlotsOfData</h3>
<p>The PlotsOfData Shiny app plots the data and statistics to enable the comparison of (experimental) conditions. The philosophy of the approach is that plotting the raw data (instead of a summary) improves transparency and interpretation (see also <a href="http://thenode.biologists.com/leaving-bar-five-steps/">this blog</a>). To further facilitate the comparison, summary statistics (mean, median, boxplot) and inferential statistics (confidence intervals) can be added. The user has full control over the visibility of the raw data and statistics by adjustment of the transparency (alpha).</p>
<p>Bootstrapping is used to calculate the (asymmetric) 95% CI of medians. More information in <a href="http://thenode.biologists.com/a-better-bar/education/">this blog</a> </p>
<p>The PlotsOfData Shiny app plots the data and statistics to enable the comparison of (experimental) conditions. The philosophy of the approach is that plotting the raw data (instead of a summary) improves transparency and interpretation. To further facilitate the comparison, summary statistics (mean, median, boxplot, violinplot) and inferential statistics (confidence intervals) can be added. The user has full control over the visibility of the raw data and statistics by adjustment of the transparency (alpha). More details about the PlotsOfData app can be found in our <a href="https://doi.org/10.1101/426767">publication</a>.</br> </p>

<p>The data can be supplied in spreadsheet/long format (e.g. by copy-pasting from excel) or in tidy format. For more information on the conversion of spreadsheet data to tidy data see <a href="http://thenode.biologists.com/converting-excellent-spreadsheets-tidy-data/education/">this blog</a>.</p>

<h4>Source</h4>
<p>PlotsOfData is created and maintained by Joachim Goedhart (<a href="https://twitter.com/joachimgoedhart">@joachimgoedhart</a>) and Marten Postma</br>

Source code is available at <a href="https://github.com/JoachimGoedhart/PlotsOfData">github/JoachimGoedhart</a>
</br>
Please cite our work if you use the app: "PlotsOfData - a web app for visualizing data together with its summaries" - doi: <a href="https://doi.org/10.1101/426767">10.1101/426767</a>
</br>

</p>

<p>The plot can be saved as a PDF file, which can be opened and edited with Adobe Illustrator to allow for fine adjustments of the lay-out.</p>

<h4>Credits</h4>

<p>PlotsOfData is inspired on <a href="http://shiny.chemgrid.org/boxplotr/">BoxPlotR</a>. See <a href="https://www.nature.com/articles/nmeth.2813">this link</a>
for background information on boxplots.</br>
<p>PlotsOfData is inspired by <a href="http://shiny.chemgrid.org/boxplotr/">BoxPlotR</a></br>

The code for the shiny app is partially derived from <a href="https://github.com/gertstulp/ggplotgui">ggplotGUI</a>
by <a href="https://www.gertstulp.com">Gert Stulp</a></br>
The colorblind safe palletes were developed by <a href="https://personal.sron.nl/~pault/">Paul Tol</a>.</p>

<p>PlotsOfData is created and maintained by Joachim Goedhart (<a href="https://twitter.com/joachimgoedhart">@joachimgoedhart</a>) and Marten Postma
The colorblind safe palettes were developed by <a href="https://personal.sron.nl/~pault/">Paul Tol</a>.</p>


</p>

</br>


<h4>Further reading</h4>
<p>Some aspects of the app are explained in <a href="http://thenode.biologists.com/author/joachimg/">blogs at The Node</a>:
</br>
<a href="http://thenode.biologists.com/leaving-bar-five-steps/">Leaving the bar</a> (On plotting the actual data rather than summaries)
</br>
<a href="http://thenode.biologists.com/a-better-bar/education/">A better bar</a> (Explains the calculation of 95% CI for the median)
</br>
<a href="http://thenode.biologists.com/converting-excellent-spreadsheets-tidy-data/education/">Converting excellent spreadsheets to tidy data</a> (An introduction to tidy data)
</br>
<a href="http://thenode.biologists.com/p-value-parroting/research/">Prevent p-value parroting</a> (Why not every graph needs a p-value)
</br>

</p>


</html>
42 changes: 33 additions & 9 deletions app.R
Expand Up @@ -491,22 +491,35 @@ height <- reactive ({ input$plot_height })

output$downloadPlotPDF <- downloadHandler(
filename <- function() {
paste("ComparisonPlot_", Sys.time(), ".pdf", sep = "")
paste("PlotsOfData_", Sys.time(), ".pdf", sep = "")
# paste("PlotsOfData.pdf")
},
content <- function(file) {
ggsave(file, width = input$plot_width/72,
height = input$plot_height/72, dpi="retina")
pdf(file, width = input$myWidth/72, height = input$myHeight/72)
## ---------------
plot(plotdata())
## ---------------
dev.off()
# ggsave(file, width = input$plot_width/72,
# height = input$plot_height/72, dpi="retina")
},
contentType = "application/pdf" # MIME type of the image
)

output$downloadPlotPNG <- downloadHandler(
filename <- function() {
paste("ComparisonPlot_", Sys.time(), ".png", sep = "")
paste("PlotsOfData_", Sys.time(), ".png", sep = "")
},
content <- function(file) {
ggsave(file, width = input$plot_width/72,
height = input$plot_height/72)
png(file, width = input$plot_width*4, height = input$plot_height*4, res=300)
## ---------------
plot(plotdata())
## ---------------
dev.off()


# ggsave(file, width = input$plot_width/72,
# height = input$plot_height/72)
},
contentType = "application/png" # MIME type of the image
)
Expand All @@ -518,7 +531,7 @@ output$downloadPlotPNG <- downloadHandler(
######## PREPARE PLOT FOR DISPLAY ##########
###########################################

output$coolplot <- renderPlot(width = width, height = height, {
plotdata <- reactive({


####### Read the order from the ordered dataframe #############
Expand Down Expand Up @@ -689,9 +702,20 @@ output$coolplot <- renderPlot(width = width, height = height, {
}

### Output the plot ######
p
return(p)

}) #close output$coolplot
}) #close plotdata



########################################
##### Make actual plot ############

output$coolplot <- renderPlot(width = width, height = height, {
plot(plotdata())
}
)
##########################################


###########################################
Expand Down
6 changes: 3 additions & 3 deletions rsconnect/shinyapps.io/goedhart/PlotsOfData.dcf
Expand Up @@ -5,9 +5,9 @@ account: goedhart
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 458873
bundleId: 1604090
bundleId: 1609765
url: https://goedhart.shinyapps.io/PlotsOfData/
when: 1537871761.02692
when: 1538074556.99123
asMultiple: FALSE
asStatic: FALSE
ignoredFiles: .RData|.Rapp.history|ComparisonPlot_example1.png
ignoredFiles: .Rapp.history

0 comments on commit 7fbde45

Please sign in to comment.