Can't figure this out: 'file' must be a character string or connection

I have what I thought was a pretty simple Shiny app. It would take an uploaded .csv file and pass it to a custom function I wrote. However, I keep getting this error and I cannot figure out how to solve this. Here is my code

rdsfiles <- list.files(pattern = "\\.Rds$")

# --- Front End ---
ui <- shinyUI(fluidPage(theme = shinytheme("cerulean"), pageWithSidebar(
  
  # Title
  headerPanel("Title"),
  
  # Sidebar to select a dataset
  sidebarPanel(
    selectInput("obj", "Choose a dataset:", 
                choices = rdsfiles),
    fileInput("tissue_csv", 
              "Load tissue positions .csv file", 
              accept = c("text/csv", "text/comma-separated-values,text/plain",".csv")
    ),
    textInput("feature", label = "Gene"),
    
    
  ),
  
  # Different analyses available
  mainPanel(
    tabsetPanel(
      tabPanel('UMAP', plotOutput("umap")),
      tabPanel('Tissue', plotOutput("tissue")),
      tabPanel('Gene Expression', plotOutput("genex")),
      
    ))
  
)))

# --- Back end ---
server <- shinyServer(function(input, output) {
  
  # Return the requested datasets
  datasetInput <- reactive({
    df <- readRDS(input$obj, input$obj)
    return(df)
  })
  tissueInput <- reactive({
    inFile <- req(input$tissue_csv)
    read.csv(inFile$datapath)
  })
  ###HERE IS WHERE THE ERROR COMES FROM###
  output$tissue <- renderPlot({
    obj <- datasetInput()
    tiss <- tissueInput()
    custom_function(obj, tiss)
    
 })
  # Retrieve the UMAP projection
  output$umap <- renderPlot({
    obj <- datasetInput()
    DimPlot(obj, reduction = "umap")
    
  })
  
  
})


shinyApp(ui, server)

Whats happening here ? Why the repetition?

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.