如何定义要在闪亮的应用程序屏幕上显示的输出?

时间:2019-07-01 08:08:53

标签: r shiny

我正在开发一种闪亮的应用程序,用于预测蛋白质的亚细胞定位,以便快速输入Fasta序列作为输入,并且将提供3种功能(AAC,DC,PseAAC)。用户必须选择其中任何一个,当用户选择功能时,与该功能相对应的R脚本将在后端运行,并且将预测亚细胞位置,并应将其打印在闪亮的应用程序屏幕上。

到目前为止,我已经尝试了许多输出选项,包括verbatimTextOutput,renderPrint,textOutput等,但没有得到预期的结果

 library(shiny)
 library(protr)
 ui <- fluidPage(
 titlePanel("SCL"),
 sidebarLayout(
 sidebarPanel(
 fileInput("file", "Choose FASTA File",
 accept = c("text/fasta",".fasta"), multiple = TRUE, buttonLabel = 
"Browse..."),
#selectInput("file_choice", "choose feature to calculate", choices = 
c("AAC" = "PredA.r", "DC" = "PredD.r", "PseAAC" = "PredP.r")),
h5("use case - button based navigation"),
#actionButton("bell", "run selected file", class = "btn action-button", 
onclick = "window.open$('file_choice').val())")),
actionButton("AAC", "runAAC"), verbatimTextOutput("Finished_AAC"),
br(),
actionButton("DC", "runDC"),
br(),
actionButton("PseAAC", "runPseAAC")

),
mainPanel(
h2("Results")) #verbatimTextOutput("Location"))
#textOutput("DC")
#textOutput("PseAAC"))

)
)

  server <- function(input, output, session)


 #FormulaText <- reactive({paste("Subcellular Location", input$filefasta
 #output$location <- renderText({FormulaText

 #output$file_choice <- renderText(paste("You have selected
 #output$location <- renderText(paste("subcellular location is"

{
#source(file = "C:/Users/BioInto/Desktop/PredA.r", args[1], local = TRUE)
aac = reactiveValues(aac = FALSE)
dc = reactiveValues(dc = FALSE)
pseaac = reactiveValues(pseaac = FALSE)


observeEvent({input$AAC(output$aa <- isolate(system(paste("\"C:/Program 
Files/R/R-3.4.4/bin/RScript.exe\"", "C:/Users/BioInto/Desktop/PredA.r", 
"C:/Users/BioInto/Desktop/4W/Pred/seq.fasta"))))})
output$AAC <- renderText({paste("Running finished")
})
output$AAC <- renderPrint({output$aa()})

#Text <- reactive({quote(input$AAC, pa, quote = TRUE)})
output$file <- renderText({paste("you have uploaded file")})
#output$Location <- renderPrint({Location})
#output$Location <- renderPrint({abc()
#})
#print(as.factor(Location))


}



shinyApp (ui, server)

下面是PredA.r文件

library("protr")
library("e1071")
library("caret")
args = commandArgs(trailingOnly = TRUE)
seq = readFASTA(args[1]) [[1]]
#seq = readFASTA("C:/Users/Biointo/Desktop/4W/pred/seq.fasta") [[1]]
length(seq)
seq = seq[(sapply(seq, protcheck))]
length(seq)
aac = extractAAC(seq)
write.table(aac , file = "C:/Users/Biointo/Desktop/4W/pred/20", append = 
TRUE, eol = "\n",  col.names = FALSE)
#write.table(aac , args[2], append = TRUE, eol = "\n",  col.names = 
FALSE)
bf <- read.table("C:/Users/Biointo/Desktop/4W/pred/20")
nbf <- data.frame(t(bf))
rownames(nbf) <- NULL
colnames(nbf) <- NULL
write.table(nbf, file = "C:/Users/Biointo/Desktop/4W/pred/mn20" , 
col.names = F)
#write.table(args[3], col.names = F)
mn <- read.table("C:/Users/Biointo/Desktop/4W/pred/mn20" , header = T)
load("C:/Users/Biointo/Desktop/4W/pred/AACT.rda")
aactune$best.model
#aacb <- predict(aactune , mn)
pa <- (predict(aactune$best.model, mn))
pa
write.table(pa, file = "C:/Users/Biointo/Desktop/4W/pred/loc.txt", sep = 
"") 
read.table(file = "C:/Users/Biointo/Desktop/4W/pred/loc.txt", sep = "") 
#library(shiny)
#output$Location <- renderText({as.factor(pa)})

我希望将预测的位置(文本输出)粘贴到闪亮的应用程序屏幕上

0 个答案:

没有答案