Shiny board with seurat object
2
0
Entering edit mode
4.0 years ago
Dataminer ★ 2.8k

Dear community,

I am trying to make a shiny app by reading in seurat object. Unfortunately, it doesn't work. I have deployed the following code:

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)

The output is an error "Cannot find "umap" in seurat object" for both the buttons.

I am not sure what I doing wrong. However, I am sure that some of you must have tackled this problem in past. Your input is highly appreciated.

Thank you

Seurat Shiny • 3.4k views
ADD COMMENT
0
Entering edit mode
4.0 years ago

Seurat depends on the uwot R package which you also need to install.

ADD COMMENT
0
Entering edit mode

Hi, My seurat works fine and I get all the images and analysis done. It is when I try to put the seurat object into R shiny, it throws up this error.

ADD REPLY
0
Entering edit mode
3.8 years ago
AB ▴ 360

You have to use the DimPlot function in place of

plot(input$dataset, reduction = "umap")

Try

DimPlot(input$dataset, reduction = "umap")
ADD COMMENT

Login before adding your answer.

Traffic: 1988 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6