I am trying to develop a shiny app for pairwise protein sequence alignment using Biostrings library. Although the code is working very fine in the console but I am not getting a display of sequence alignment in shinyapp. I think there is something wrong with a render function. Can anyone suggest me something useful? I am new in programming.
library(seqinr)
library(shiny)
library(Biostrings)
library(msa)
# User interface
ui <- fluidPage(
titlePanel("Pairwise alignment"),
sidebarLayout(
sidebarPanel (
fileInput("protein1",
label = "Choose a file",
multiple = FALSE,
accept =c( ".fasta")),
fileInput( "protein2",
label = NULL,
multiple=FALSE,
accept =c("fasta"))
),
# Outputs
mainPanel(
plotOutput(outputId = "text")
)
)
)
# Server Function
server <- function(input, output) {
seq1 <- reactive({
req(paste(read.fasta(input$protein1$datapath,seqtype = "AA", as.string = TRUE),collapse = ","))})
seq2 <- reactive({
req(paste(read.fasta(input$protein2$datapath, seqtype = "AA", as.string = TRUE),collapse = ","))
})
output$text <- renderText({
print(seq1())
print(seq2())
p<-pairwiseAlignment(pattern = seq1(), subject = seq2())
print(p)
})
}
# App
shinyApp(ui = ui, server = server)