Answers.Body: <p>There are two issues that I can see.</p>
  <p>The first is that the results are loaded via <code>RData</code> files, which include information about the variable names. Assuming these work, I expect they create a variable within the R environment called <code>dds</code> which has the DESeq2 results. The second load overwrites that variable:</p>
  <pre><code>set_1&lt;-load(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData&quot;)
  set_2&lt;-load(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData&quot;)
  </code></pre>
  <p>What should probably be done is storing the results as an R Dataset that doesn't include variable name information:</p>
  <pre><code># create set_1 DESeq2 results called 'dds'
  saveRDS(dds, &quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.rds&quot;)
  # create set_2 DESeq2 results called 'dds'
  saveRDS(dds, &quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.rds&quot;)
  </code></pre>
  <p>Then those can be loaded into the R environment using the assignment you expect:</p>
  <pre><code>set_1&lt;-readRDS(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData&quot;)
  set_2&lt;-readRDS(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData&quot;)
  data_list = list(set_1=set_1,set_2=set_2)
  </code></pre>
  <p>The second issue is that the plot output displays <code>dds</code>, rather than the <code>datasetInput</code> variable, and there is no assignment to change the definition of <code>dds</code>:</p>
  <pre><code>    output$widgets &lt;- renderPlot({
          dds &lt;- datasetInput() ## Note: added assignment
          par(mfrow=c(1,2))
          
          boxplot(counts(dds, normalized=F), outline=F, col=dds<span class="math-container">$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
          boxplot(counts(dds, normalized=T), outline=F, col=dds$</span>condition, medcol = &quot;white&quot;, cex.axis=0.6, main=&quot;Normalized&quot;)
          
          })
      
      }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-01T19:13:23.387Z
Answers.Text: Thank you, your tips were very helpful
Answers.UserDisplayName: Angelo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-01T12:22:38.597Z
Answers.LastActivityDate: 2021-08-01T12:22:38.597Z
Answers.UserDisplayName: gringer
Body: <p>I am trying to build a shiny dashboard for the visualization of different RNAseq data sets.</p>
  <p>However, I am encountering problem with reactive input, the code is always using the second dataset that I have loaded/read in. Anyone has faced a similar issue? If yes, how did you resolve it.</p>
  <p>My code is</p>
  <pre><code>    library(shinydashboard)
  library(uwot)
  library(DESeq2)
  library(gridExtra)
  library(tidyverse)
  library(RColorBrewer)
  library(DESeq2)
  library(pheatmap)
  library(DEGreport)
  library(vsn)
  library(RColorBrewer)
  library(&quot;genefilter&quot;)
  library(org.Hs.eg.db)
  library(dplyr)
  library(tidyverse)
  library(fgsea)
  library(clusterProfiler)
  library(ggplot2)
  
  
  set_1&lt;-load(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData&quot;)
  set_2&lt;-load(&quot;C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData&quot;)
  data_list = list(set_1=set_1,set_2=set_2)
  
  ui &lt;- dashboardPage(
      dashboardHeader(title = &quot;Data Visualizer&quot;, titleWidth = 300),
      dashboardSidebar(
          width = 300,
          sidebarMenu(
  
              menuItem(&quot;Datasets&quot;,  icon = icon(&quot;cog&quot;),
                       selectInput(&quot;Datasets&quot;, &quot;Datasets:&quot;, choices = list(&quot;sample1&quot; = &quot;set_1&quot;, &quot;sample2&quot; = &quot;set_2&quot;),
                                   selected = &quot;set_1&quot;)),
              menuItem(&quot;Quality Control&quot;, tabName = &quot;widgets&quot;, icon = icon(&quot;th&quot;)),
              menuItem(&quot;Differential Genes&quot;, tabName = &quot;widgets2&quot;, icon = icon(&quot;th&quot;)),
              menuItem(&quot;Downstream&quot;, tabName = &quot;widgets3&quot;, icon = icon(&quot;th&quot;))
              
           )
      ),
      ## Body content
      dashboardBody(
          tabItems(
              # First tab content
              # Second tab content
              tabItem(tabName=&quot;widgets&quot;,
                     h2(&quot;widgets&quot;),
                     plotOutput(&quot;widgets&quot;),
                      
              ),
              tabItem(tabName = &quot;widgets2&quot;,
                      h2(&quot;Widgets2 tab content&quot;),
                      
              ),
              tabItem(tabName = &quot;widgets3&quot;,
                      h2(&quot;Widgets3 tab content&quot;),
                      plotOutput(&quot;widgets3&quot;),
                      
              )
  
          )
      )
  )
  
  
  server &lt;- function(input, output) {
  
      
      datasetInput &lt;- reactive({
          df &lt;- data_list[[input$Datasets]]
          })
      
          output$widgets &lt;- renderPlot({
              datasetInput()
              par(mfrow=c(1,2))
              
              boxplot(counts(dds, normalized=F), outline=F, col=dds<span class="math-container">$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
              boxplot(counts(dds, normalized=T), outline=F, col=dds$</span>condition, medcol = &quot;white&quot;, cex.axis=0.6, main=&quot;Normalized&quot;)
              
              })
          
          }
  
  shinyApp(ui, server)
  </code></pre>
  
Tags: <r><rna-seq>
Title: shiny dashboard to visualise RNA seq data
ThreadText: # shiny dashboard to visualise RNA seq data
  
  (Asked by: username_0 on 2021-08-01)
  
  I am trying to build a shiny dashboard for the visualization of different RNAseq data sets.
  
  However, I am encountering problem with reactive input, the code is always using the second dataset that I have loaded/read in. Anyone has faced a similar issue? If yes, how did you resolve it.
  
  My code is
  
  ```
      library(shinydashboard)
  library(uwot)
  library(DESeq2)
  library(gridExtra)
  library(tidyverse)
  library(RColorBrewer)
  library(DESeq2)
  library(pheatmap)
  library(DEGreport)
  library(vsn)
  library(RColorBrewer)
  library("genefilter")
  library(org.Hs.eg.db)
  library(dplyr)
  library(tidyverse)
  library(fgsea)
  library(clusterProfiler)
  library(ggplot2)
  
  set_1<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData")
  set_2<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData")
  data_list = list(set_1=set_1,set_2=set_2)
  
  ui <- dashboardPage(
      dashboardHeader(title = "Data Visualizer", titleWidth = 300),
      dashboardSidebar(
          width = 300,
          sidebarMenu(
  
              menuItem("Datasets",  icon = icon("cog"),
                       selectInput("Datasets", "Datasets:", choices = list("sample1" = "set_1", "sample2" = "set_2"),
                                   selected = "set_1")),
              menuItem("Quality Control", tabName = "widgets", icon = icon("th")),
              menuItem("Differential Genes", tabName = "widgets2", icon = icon("th")),
              menuItem("Downstream", tabName = "widgets3", icon = icon("th"))
              
           )
      ),
      ## Body content
      dashboardBody(
          tabItems(
              # First tab content
              # Second tab content
              tabItem(tabName="widgets",
                     h2("widgets"),
                     plotOutput("widgets"),
                      
              ),
              tabItem(tabName = "widgets2",
                      h2("Widgets2 tab content"),
                      
              ),
              tabItem(tabName = "widgets3",
                      h2("Widgets3 tab content"),
                      plotOutput("widgets3"),
                      
              )
  
          )
      )
  )
  
  server <- function(input, output) {
  
      
      datasetInput <- reactive({
          df <- data_list[[input$Datasets]]
          })
      
          output$widgets <- renderPlot({
              datasetInput()
              par(mfrow=c(1,2))
              
              boxplot(counts(dds, normalized=F), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
              boxplot(counts(dds, normalized=T), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Normalized")
              
              })
          
          }
  
  shinyApp(ui, server)
  
  ```
  
  **Tags:** r, rna-seq
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-01. Score: 1 | Accepted answer
  
  There are two issues that I can see.
  
  The first is that the results are loaded via `RData` files, which include information about the variable names. Assuming these work, I expect they create a variable within the R environment called `dds` which has the DESeq2 results. The second load overwrites that variable:
  
  ```
  set_1<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData")
  set_2<-load("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData")
  
  ```
  
  What should probably be done is storing the results as an R Dataset that doesn't include variable name information:
  
  ```
  # create set_1 DESeq2 results called 'dds'
  saveRDS(dds, "C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.rds")
  # create set_2 DESeq2 results called 'dds'
  saveRDS(dds, "C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.rds")
  
  ```
  
  Then those can be loaded into the R environment using the assignment you expect:
  
  ```
  set_1<-readRDS("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData2.RData")
  set_2<-readRDS("C:/Users/abn/Documents/Shiny/DashBoardTutorial/TeData1.RData")
  data_list = list(set_1=set_1,set_2=set_2)
  
  ```
  
  The second issue is that the plot output displays `dds`, rather than the `datasetInput` variable, and there is no assignment to change the definition of `dds`:
  
  ```
      output$widgets <- renderPlot({
          dds <- datasetInput() ## Note: added assignment
          par(mfrow=c(1,2))
          
          boxplot(counts(dds, normalized=F), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Without Normalization")
          boxplot(counts(dds, normalized=T), outline=F, col=dds$condition, medcol = "white", cex.axis=0.6, main="Normalized")
          
          })
      
      }
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you, your tips were very helpful  
  
  ---
  
  