<p>Not easy to reproduce your error but here is my guess. This is a string, you can check it:</p>
<pre><code>input<span class="math-container">$dataset
class(input$</span>dataset)
</code></pre>
<p>This is a simple solution. If you want to call out the dataset depending on input, use a list:</p>
<pre><code>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)
</code></pre>
<p>Then in the server :</p>
<pre><code>datasetInput &lt;- reactive({
        df &lt;- data_list[[input$dataset]]
            })
</code></pre>

CC BY-SA 4.0
2020-12-03T11:04:22.393Z
It worked, thank you:)
Angelo
CC BY-SA 4.0
2023-05-21T06:32:53.633Z
@StupidWolf if you can give a look at this https://bioinformatics.stackexchange.com/questions/21043/shiny-app-for-single-cell-cluster-export-issue
PesKchan
CC BY-SA 4.0
2020-12-03T10:37:09.583Z
2020-12-03T10:37:09.583Z
StupidWolf
<p>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:</p>
<pre><code>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<span class="math-container">$genePlot2 &lt;- renderPlot({
        FeaturePlot(datasetInput(), features = (input$</span>gene2), reduction = &quot;umap&quot;)
    })
    
}

shinyApp(ui, server)  
</code></pre>
<p>That error that I get on the section where image needs to be displayed is &quot;Subscript out of bound&quot;.</p>
<p>Following dataset can be downloaded and used as an example <code>curl -Lo pbmc_10k_v3.rds https://www.dropbox.com/s/3f3p5nxrn5b3y4y/pbmc_10k_v3.rds?dl=1</code></p>
<p>Can anyone help in fixing this shiny script so that it works.</p>
<p>Many thanks.</p>

<r><scrnaseq><seurat>
shiny code with seurat object
# shiny code with seurat object

(Asked by: username_0 on 2020-12-03)

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 <- readRDS("/temp2/data/mydataB10.rds")
set_2 <- readRDS("/temp2/data/mydataB5.rds")

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


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

shinyApp(ui, server)  

That error that I get on the section where image needs to be displayed is "Subscript out of bound".
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.

**Tags:** r, scrnaseq, seurat

---

## 1 answers

### Answer by username_1 on 2020-12-03. Score: 3 | Accepted answer

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 <- readRDS("/temp2/data/mydataB10.rds")
set_2 <- readRDS("/temp2/data/mydataB5.rds")
data_list = list(set_1=set_1,set_2=set_2)

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

> **Comments:**
> **username_0**: It worked, thank you:)  
> **username_2**: @StupidWolf if you can give a look at this https://bioinformatics.stackexchange.com/questions/21043/shiny-app-for-single-cell-cluster-export-issue  

---

