【发布时间】:2025-12-11 06:05:02
【问题描述】:
我正在尝试使用 Shiny 构建一个具有输出 pdf 文件功能的应用程序。具体来说,我尝试使用的函数是 msa 包中的 msaPrettyPrint 函数。它使用tools 包中的texi2pdf 函数来生成pdf 文件。
例如,如果您运行以下代码,您将在工作目录中生成一个名为“myFirstAlignment.pdf”的 pdf,其中包含氨基酸序列比对。
# source("http://www.bioconductor.org/biocLite.R")
# biocLite("msa")
library(msa)
mySequenceFile <- system.file("examples", "exampleAA.fasta", package="msa")
mySequences <- readAAStringSet(mySequenceFile)
myFirstAlignment <- msa(mySequences)
msaPrettyPrint(myFirstAlignment, output="pdf", showNames="left",showLogo="top",consensusColor="BlueRed", logoColors="accessible area", askForOverwrite=FALSE)
我想知道是否有办法使以下代码有效?我认为问题可能是因为输出已经是一个 pdf 文件。如果可能的话,我想在屏幕上看到 pdf 输出。如果在屏幕上看不到,pdf文件在哪里,我可以下载吗?
library(shiny)
runApp(list(
#Load the exmaple from the msa package.
mySequenceFile <- system.file("examples", "exampleAA.fasta", package="msa"),
mySequences <- readAAStringSet(mySequenceFile),
myFirstAlignment <- msa(mySequences),
# A simple shiny app.
# Is it possible to see the generated pdf file on screen?
ui = fluidPage(plotOutput('plot')),
server = function(input, output) {
output$plot <- renderPlot(msaPrettyPrint(myFirstAlignment, output="pdf", showNames="left",showLogo="top",consensusColor="BlueRed", logoColors="accessible area", askForOverwrite=FALSE))
}
))
要提一提的是,这段代码需要 LaTeX 才能工作。你需要 LaTeX 来运行这个例子。 非常感谢!
【问题讨论】: