Commit 139d9ca3 authored by dmattek's avatar dmattek

Change: heatmaps saved as PNGs instead of PDfs

parent b84003b7
......@@ -19,8 +19,8 @@ downPlotUI <- function(id, label = "Download Plot") {
3,
numericInput(
ns('inPlotWidth'),
"Width",
17,
"Width (in)",
8.5,
min = 1,
width = 100
)
......@@ -29,32 +29,61 @@ downPlotUI <- function(id, label = "Download Plot") {
3,
numericInput(
ns('inPlotHeight'),
"Height",
10,
"Height (in)",
11,
min = 1,
width = 100
)
),
column(6,
downloadButton(ns('downPlot'), 'PDF'))
uiOutput(ns('uiDownButton')))
)
)
}
downPlot <- function(input, output, session, in.fname, in.plot) {
downPlot <- function(input, output, session, in.fname, in.plot, in.gg = FALSE) {
output$uiDownButton = renderUI({
ns <- session$ns
if (in.fname() %like% 'pdf') {
downloadButton(ns('downPlot'), 'PDF')
} else {
downloadButton(ns('downPlot'), 'PNG')
}
})
output$downPlot <- downloadHandler(
filename = function() {
in.fname
cat(in.fname(), "\n")
in.fname()
},
content = function(file) {
pdf(file,
if (in.gg) {
ggsave(
file,
limitsize = FALSE,
in.plot(),
width = input$inPlotWidth,
height = input$inPlotHeight)
in.plot()
dev.off()
height = input$inPlotHeight
)
} else {
if (in.fname() %like% 'pdf') {
pdf(file,
width = input$inPlotWidth,
height = input$inPlotHeight)
} else {
png(file,
width = input$inPlotWidth,
height = input$inPlotHeight, units = 'in', res = 300)
}
in.plot()
dev.off()
}
}
)
......
......@@ -179,7 +179,7 @@ clustHierUI <- function(id, label = "Hierarchical CLustering") {
)
),
br(),
downPlotUI(ns('downPlotHier'), "Download PDF"),
downPlotUI(ns('downPlotHierPNG'), "Download PNG"),
br(),
checkboxInput(ns('plotInt'),
......@@ -293,12 +293,18 @@ clustHier <- function(input, output, session, dataMod) {
output$outPlotHier <- renderPlot({
plotHier()
})
createFnameHeatMap = reactive({
paste0('clust_hierch_heatMap_',
s.cl.dist[as.numeric(input$selectDist)],
'_',
s.cl.linkage[as.numeric(input$selectLinkage)],
'.png')
})
# Hierarchical - download pdf
callModule(downPlot, "downPlotHier", paste0('clust_hierch_',
s.cl.dist[as.numeric(input$selectDist)],
'_',
s.cl.linkage[as.numeric(input$selectLinkage)], '.pdf'), plotHier)
# Hierarchical - download png
callModule(downPlot, "downPlotHierPNG", createFnameHeatMap, plotHier)
# Hierarchical clustering - interactive version
output$outPlotInt <- renderD3heatmap({
......
......@@ -193,7 +193,7 @@ clustHierSparUI <- function(id, label = "Sparse Hierarchical CLustering") {
br(),
downPlotUI(ns('downPlotHierSpar'), "Download PDF"),
downPlotUI(ns('downPlotHierSparPNG'), "Download PNG"),
br(),
checkboxInput(ns('inPlotHierSparInteractive'), 'Interactive Plot?', value = FALSE),
......@@ -396,12 +396,19 @@ clustHierSpar <- function(input, output, session, dataMod) {
plotHierSpar()
})
# Sparse Hierarchical - download pdf
callModule(downPlot, "downPlotHierSpar", paste0('clust_hierchSparse_',
s.cl.spar.dist[as.numeric(input$selectPlotHierSparDist)],
"_",
s.cl.spar.linkage[as.numeric(input$selectPlotHierSparLinkage)], '.pdf'), plotHierSpar)
createFnameHeatMap = reactive({
paste0('clust_hierchSparse_',
s.cl.spar.dist[as.numeric(input$selectPlotHierSparDist)],
"_",
s.cl.spar.linkage[as.numeric(input$selectPlotHierSparLinkage)], '.png')
})
# Sparse Hierarchical - download png
callModule(downPlot, "downPlotHierSparPNG", createFnameHeatMap, plotHierSpar)
# Sparse Hierarchical clustering (sparcl) interactive version
output$plotHierSparInt <- renderD3heatmap({
cat(file = stderr(), 'plotHierSparInt \n')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment