【问题标题】:Extract Metadata from uploaded Seurat Object in Shiny to make selectInput choices在 Shiny 中从上传的 Seurat 对象中提取元数据以进行 selectInput 选择
【发布时间】:2021-04-27 04:37:56
【问题描述】:

我正在尝试创建一个 Shiny 应用程序,它允许我比较来自 Seurat 对象的簇,并输出差异表达基因的列表。到目前为止我已经尝试过了:

#here's the UI portion I need help with:

          
      selectInput(inputId = "clusters", 
                  label = "Choose cluster 1: ", 
                  choices = NULL)

#here's the server function

server <- function(input, output, session) {
  
#this is to load in the datasets reactively; i.e, they are not loaded until you select them
  
datasetInput <- reactive({
    if (input$dataset_selec == "NK AD Dataset") {
      dataset <- get(load("~/Desktop/Shiny App/Seuratapp/data/nk_integrated_object.Rdata"))
    }
    else if (input$dataset_selec == "APPPS1 Dataset") {
      dataset <- get(load("~/Desktop/ShinyApp/Seuratapp/data/appps1_lymphocytes_object.Rdata"))
    }
    else if (input$dataset_selec == "T Cell Infiltration Dataset") { 
      dataset <- get(load("~/Desktop/Shiny App/Seuratapp/data/tcell_infiltration.Rdata"))
    }
    return(dataset)
  })

#this is to transform the loaded dataset into something I can use as labels
  dataset <- datasetInput

  updateSelectInput(session, 
                    inputId = "metadata_split", 
                    label = "Choose category to split by: ",
                    choices = colnames(dataset@metadata))

这不起作用,我敢肯定有很多原因,但坦率地说,我什至无法理解从哪里开始解决这个问题。谁能帮帮我?

【问题讨论】:

    标签: r shiny seurat


    【解决方案1】:

    一些建议:

    1. 您的代码不完整。制作minimal reproducible example,以便人们可以重现您的错误。对于公开的 Seurat 数据,您可以尝试使用 Seurat tutorial 中的 PBMC dataset
    2. 如果dataset应该是反应式的,那么我认为你需要call the reactive expression
    dataset <- datasetInput()
    
    1. dataset &lt;- get(load(...)) 是一种不寻常的策略。如果你有RData 对象,那么你可以做dataset &lt;- readRDS(...)。见here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-24
      • 1970-01-01
      • 2019-01-19
      • 2019-09-25
      • 1970-01-01
      • 2022-09-25
      • 2017-04-22
      相关资源
      最近更新 更多