Entering edit mode
                    4.9 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
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.