shiny code with seurat object I am trying to create a shiny board for my scRNA seq data. I have saved my seurat objects adn I use following code as below:
library(shiny)
library(shinythemes)
library(Seurat)
library(uwot)


set_1 &lt;- readRDS(&quot;/temp2/data/mydataB10.rds&quot;)
set_2 &lt;- readRDS(&quot;/temp2/data/mydataB5.rds&quot;)

ui &lt;- fluidPage(
    
    # Application title
    titlePanel(&quot;scRNAseq data browser&quot;),
    
    fluidRow(
        column(4,
               
               sidebarPanel(
                   radioButtons(&quot;dataset&quot;, label = h3(&quot;Dataset&quot;),
                                choices = list(&quot;sample1&quot; = &quot;set_1&quot;, &quot;sample2&quot; = &quot;set_2&quot;),
                                selected = &quot;set_1&quot;),
                   helpText(&quot;Enter gene names in CAPS.  Gene names must be exact.&quot;),
                   textInput(&quot;gene2&quot;, label = &quot;Gene Name&quot;, value = &quot;GAPDH&quot;)
                   
               )
        ),
        column(8,
               column(6, 
                      mainPanel(
                          plotOutput(&quot;dimPlot1&quot;, width = &quot;150%&quot;),
                          plotOutput(&quot;genePlot2&quot;, width = &quot;150%&quot;)
                      )
               )
        )
    )
)


server &lt;- function(input, output, session) {
    
    datasetInput &lt;- reactive({
        df &lt;- (input$dataset)
            })
    
    output$dimPlot1 &lt;- renderPlot({
        DimPlot(datasetInput(), reduction = &quot;umap&quot;)
    })
    
    output$genePlot2 &lt;- renderPlot({
        FeaturePlot(datasetInput(), features = (input$gene2), reduction = &quot;umap&quot;)
    })
    
}

shinyApp(ui, server)  

That error that I get on the section where image needs to be displayed is &quot;Subscript out of bound&quot;.
Following dataset can be downloaded and used as an example curl -Lo pbmc_10k_v3.rds https://www.dropbox.com/s/3f3p5nxrn5b3y4y/pbmc_10k_v3.rds?dl=1
Can anyone help in fixing this shiny script so that it works.
Many thanks.
Not easy to reproduce your error but here is my guess. This is a string, you can check it:
input$dataset
class(input$dataset)

This is a simple solution. If you want to call out the dataset depending on input, use a list:
set_1 &lt;- readRDS(&quot;/temp2/data/mydataB10.rds&quot;)
set_2 &lt;- readRDS(&quot;/temp2/data/mydataB5.rds&quot;)
data_list = list(set_1=set_1,set_2=set_2)

Then in the server :
datasetInput &lt;- reactive({
        df &lt;- data_list[[input$dataset]]
            })