Shiny board with seurat object in .rds file

Dear community,

I am new to shiny and was trying to create my shiny page using seurat object.

I have stored my seurat objects as .rds files. and below is the script.

library(shiny)
library(shinythemes)
library(Seurat)
library(ggplot2)
library(gridExtra)
library(egg)
library(RColorBrewer)
library(shinyWidgets)

Getting the file names

rdsfiles <- list.files("/temp2/data", pattern = "\.rds$")

Define UI for dataset viewer application

ui <- shinyUI(fluidPage(theme = shinytheme("cerulean"), pageWithSidebar(

# Application title
headerPanel("Shiny App with multiple datasets"),
# Sidebar with controls to select a dataset and specify the number
# of observations to view
sidebarPanel(
    selectInput("dataset", "Choose a dataset:", 
                choices = rdsfiles),
),

# Show a summary of the dataset and an HTML table with the requested
# number of observations
mainPanel(
    tabsetPanel(
        tabPanel('UMAP', plotOutput("umap")),
        tabPanel('Gene', plotOutput("gene"))
        
    ))

)))

Define server logic required to summarize and view the selected dataset

server <- shinyServer(function(input, output) {

# Return the requested dataset
datasetInput <- reactive({
    df <- readRDS(paste0("/temp2/data/", input$dataset))
    return(df)
})

# Generate a UMAP of the dataset
output$umap <- renderPlot({
    dataset <- datasetInput()
    plot(input$dataset, reduction = "umap")
    
})

# Generate a Feature of the dataset
output$gene <- renderPlot({
    dataset <- datasetInput()
    FeaturePlot(dataset, reduction = "umap")
    
})

})

shinyApp(ui, server)

I am not able to understand what I am doing is wrong or missing or inaccurate that leads to no image rendering both tabs (UMAP and Feature Plot).

Any help is very much appreciated.

This topic was automatically closed 21 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.