Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: Error in cat: argument 1 (type 'list') cannot be handled by 'cat' [No stack trace available] in R shiny webtool

Im developing shiny webtool for R functions to generate the indices results on the webtool.

I have 6 R functions and i created 6 combinations in selectinput widget, where each combination is linked with the one R function each.

The 6 R functions are as follows:

RSCU(file){script},

cgr_res(file){script},

zscore_cal(file){script},

GC_Content7(file){} and

extractmod(file){script} all these 5 functions have single and same arguments i.e., input file as same input argument for all five R functions and last R function that is 6th R function have AMIP(file,n1,n2) 3 input arguments here input file is same as remaining 5, but n1 and n2 are different arguments , for n1 and n2 arguments I created numericalInput() widget. For GC_content7,RSCU, cgr_res and zscore_cal, webtool is working fine but for other two functions no results are displaying.

     library("shinythemes")
  library("shiny")
  library("htmltools")
  library("bsplus")
  library("DT")
  library("shinyalert")
  library("shinyjs")
  library("shinycssloaders")
  library("dplyr")
  library("data.table")
  library("reshape2")
  library("ggplot2")
  library("plotly")
  library("tools")
  library("readxl")
  library("writexl")
  library("seqinr")
  library("Biostrings")
  library("BiocManager")
  library("entropy")
  library("protr")
  
  source("GS_Source.R")
  
  ui = fluidPage(
    headerPanel(
      h1(tags$strong("Welcome to Web based Tool for Computation of Genomic"),
         style = "font-size: 20pt; line-height: 30pt; width = 100; color: #Red",
         align = "center"),
      windowTitle = "Home"),
    
    sidebarLayout(
      sidebarPanel(
        style = "background-color: #E52B50;",
        tags$style(type='text/css', 
                   "label { font-size: 12px; }",
                   ".selectize-input { font-size: 12pt; line-height: 12pt;}, 
                   .selectize-dropdown { font-size: 12pt; line-height: 12pt; }"),
        
        fileInput('file', HTML('<p style="color:#4A2768; font-size: 12pt"> Choose file to upload the expression data </p>'),accept = c('text/csv','text/comma-separated-values',
                                                                                                                                       'text/tab-separated-values','text/plain','.csv', '.tsv','.fasta')),
        
        selectInput("Signatures", HTML('<p style="color:#4A27C5; font-size: 12pt"> Genome signature </p>'), 
                    c("GC-content","RSCU","CGR","DI-nuculeotide odd Ratio","AAC","AMIP")),
        numericInput("num1",label = "FROM",value = 2),
        numericInput("num2", label = "TO", value = 3),
      
        useShinyalert(),
        actionButton("action", tags$b("Submit")), width = 3,  style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
      mainPanel(
       verbatimTextOutput("res1"),
        verbatimTextOutput("res2"),
       plotOutput("res3"),
       verbatimTextOutput("res4"),
       verbatimTextOutput("res5"),
       verbatimTextOutput("res6"),
        
      )
    )
  )
  
  server <- function(input, output, session) {
  
  
   
    
  
  df <- eventReactive(input$action, {
                      my_func <- switch(input$Signatures,
                                       
                                       "RSCU" = RSCU,
                                       "CGR"=cgr_res,
                                       "DI-nuculeotide odd Ratio"=zscore_cal,
                                       "GC-content" = GC_content7,
                                       "AAC"=extractAAC_mod,
                      )
                     
                      my_func(input$file$datapath)
                     
  })
  
  df1 <- eventReactive(input$actions, { 
                   my_func1 <- switch(input$signatures, 
                          "AMIP"=AMIP,
  )
     my_func1(input$file$datapath,input$num1,input$num2)
  })
  
  

  
  output$res1 <- renderPrint({
    req(input$Signatures)
    if (input$Signatures=="GC-content") {
      
      df()
    }
  })
  
  output$res2 <- renderPrint({
    req(input$Signatures)
    if (input$Signatures=="RSCU") {
      
      df()
    }
  })
    
  output$res3 <- renderPlot({
    req(input$Signatures)
    if (input$Signatures=="CGR") {
      
      df()
    }
  })
  
  output$res4 <- renderPrint({
    req(input$Signatures)
    if (input$Signatures=="DI-nuculeotide odd Ratio") {
      
      df()
    }
  })                    
  output$res5 <- renderPrint({
    req(input$Signatures)
    if (input$Signatures=="AAC") {
      
      df()
    }
  })
  
  output$res6 <- renderPrint({
   req(input$signatures)
    if(input$signatures=="AMIP"){
      df1()
      }
    
 })
  
  observeEvent(input$action, {
    shinyalert(title = "Please wait for the results...", type = "success")
  })
  
  }
  
  shinyApp(ui, server)
like image 288
mailarlinga Avatar asked Jan 30 '26 10:01

mailarlinga


1 Answers

One cannot return a list in renderText. You can use renderPrint instead of renderText and verbatimTextOutput instead of textOutput.

like image 197
Stéphane Laurent Avatar answered Feb 01 '26 01:02

Stéphane Laurent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!