我无法在ShinyApp中实现renderImage。在某些时候,我启动一个函数,在脚本目录中生成3个png文件。我无法找到renderImage函数是否可以处理多个图像。另外,我发现renderImage不会在脚本目录中搜索,而是在另一个临时文件目录中搜索。我该如何解决这个问题?
以下是相关代码:
observe({
if (input$startkegg != 0) { # referecne to an actionButton "Start"
kegg <- reactive({ enrichKEGG(entrezIDs() ,pAdjustMethod="fdr", pvalueCutoff=input$keggp, qvalueCutoff=input$keggq)}) # Some bioinformatics stuff
output$enrichKegg <- renderImage({
width <- session$clientData$output_enrichKegg_width
height <- session$clientData$output_enrichKegg_height
outfile <- tempfile(fileext='.png')
png(outfile)
pathview(gene.data=entrezIDs(), pathway.id=as.matrix(summary(kegg())[1])[1:3],species = "hsa", limit=3) # The function wich generates a image with the output of the previous instruction.
dev.off()
list(src = outfile,
width = width,
height = height,
alt = "plotGoGraph")
}, deleteFile = FALSE)
}
})
我几乎设法以“脏”方式解决问题,使用标签$ img和renderUI,但为此我必须在'www'子文件中移动图像,而我的'system'命令不起作用:
observe({
if (input$startkegg != 0) {
kegg <- reactive({ enrichKEGG(entrezIDs(), pAdjustMethod=input$adjmk, pvalueCutoff=input$keggp, qvalueCutoff=input$keggq)})
pathview(gene.data=entrezIDs(), pathway.id=as.matrix(summary(kegg())[1])[1:3],species = "hsa", limit=3)
system("copy hsa04060.pathview.png www")
system("copy hsa04064.pathview.png www")
system("copy hsa04668.pathview.png www")
#Essayer de mettre la commande pathview dans un tempoutfile : un temp par pathview
output$pathway1 <- renderUI({ tags$img(src="hsa04060.pathview.png", width="400px", height="247px") })
output$pathway2 <- renderUI({ tags$img(src="hsa04064.pathview.png", width="400px", height="318px") })
output$pathway3 <- renderUI({ tags$img(src="hsa04668.pathview.png", width="400px", height="273px") })
}
})