无法在服务器上的闪亮应用中渲染图,但可以在本地和Rstudio服务器上工作

问题描述

我已经被这个问题困扰了好几天了。

我正在构建一个闪亮的应用程序,用户可以在其中选择一个数据集,然后服务器将读取相应的.rds文件并渲染图。绘图工具需要软件包Seurat。

当我在本地测试时,它可以工作。然后,我将其部署到我们大学托管的闪亮服务器上,这些应用程序也可以在Rstudio服务器上正常运行。

但是,当我通过外部链接时,没有显示任何图,说:“发生了错误。请检查您的日志或联系应用作者以进行澄清。”

我四处搜寻,发现了可能与环境有关的原因:

  1. 文件路径 我确实进行了检查,并且由于我在同一台机器上进行了测试(Rstudio服务器与闪亮的服务器相同),所以这可能不是问题吗?
  2. 包装 当我在闪亮的app.R的开头加载库(Seurat)时,外部链接会失败,但是Rstudio服务器运行良好。因此,我尝试了ggplot2来测试它是否是程序包问题,是否可以毫无问题地加载它并绘制图。

具体来说,这似乎是Seurat兼容性的问题,但是为什么在同一台计算机上它可以在Rstudio服务器中工作呢? Seurat社区表示此问题已在新的CRAN版本(3.2.0)中得到解决,但是为什么我仍然遇到此问题?如何解决.. ??

这些是我注意到的,希望您的专家能给我一些想法...

以下是读取.rds和渲染图的代码

# read .rds
germ <- readRDS(file.path(paste("/srv/shiny-server/GermlinAtlas/data/",input$dataset,".rds",sep="")))

# render plot
observeEvent(input$dataset,{
  if (is.null(input$dataset)) return(NULL)
     if (is.null(input$gene)) return(NULL)
          infile <- isolate(input$dataset)
          germ <- readRDS(file.path(paste("/srv/shiny-server/GermlinAtlas/data/",infile,sep=""))) # read .rds
          gene <- isolate(input$gene)
          
          x <- rnorm(100)  # for ggplot test
          y <- rnorm(300)  # for ggplot test
          output$dim <- renderPlot({
            DimPlot(germ,reduction = "umap") # plot with Seurat
            plot(x,y[1:100]) # plot with ggplot2
          })
          output$featureplot <- renderPlot({
            FeaturePlot(germ,input$gene) # plot with Seurat
          })
        })
Rstudio服务器的

输出

output from Rstudio server:

服务器(用户端)的

输出

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)