In ShinyApp getting output in console but not in App page

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)

Hi @naeem_hmg, if you want to display what you see printed in your R console, you should use renderPrint() instead of renderText(). Also, you need to link that output id (text) to a suitable output container, so in the case of renderPrint(), a good option is verbatimTextOutput() (note: if you wanted to use renderText() for some reason, you should link that to textOutput(), not plotOutput()).

1 Like

Thanks Dear cpsievert, i got the solution.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.