闪亮的应用程序仅适用于特定的浏览器/平台

时间:2016-09-05 11:06:44

标签: shiny rstudio

我使用R版本3.2.4在RStudio中编写了一个闪亮的应用程序。该应用可在此处找到:https://koenvandenberge.shinyapps.io/tempConditioning/ 请注意,要加载的数据非常多,因此加载需要几秒钟。

我已将它部署在我的Macbook上,似乎它只适用于Safari和Chromium浏览器。它似乎不适用于Chrome或Firefox浏览器。有了这个,我的意思是应该生成的图不是。下拉菜单应该是应有的,因此应用程序不会崩溃,但应该通过从下拉菜单中选择内容生成的图表不会崩溃。

有什么方法可以解决这个问题吗?你可以在下面找到我的应用程序的代码:

library(shiny)
library(scales)
load("countMatrix.RData")
countMatrixAllSub = as.data.frame(countMatrix$counts[,-1]) ; rm(countMatrix)
sampleNames = unlist(lapply(strsplit(colnames(countMatrixAllSub),split=".",fixed=TRUE), function(x) x[4]))
sampleNames[28] <- "3c0a"
treat=substr(sampleNames,2,2)
time=substr(sampleNames,3,nchar(sampleNames)-1)
timeC=as.numeric(time)
timeC[timeC==15]=0.25

ui <- shinyUI(fluidPage(

   # Application title
   titlePanel("Gene expression: conditioning experiment Gust"),

   # Sidebar with a
   sidebarLayout(
      sidebarPanel(
         selectInput("gene",
                     "Pick a gene",
                      choices = rownames(countMatrixAllSub))
      ),

      # Show a plot of the generated distribution
      mainPanel(
         plotOutput("genePlot")
      )
   )
))

# Define server logic required to draw an expression plot
server <- shinyServer(function(input, output) {
  output$genePlot <- renderPlot({
    par(mar = c(5.1, 4.1, 3, 1))
    plot(y=countMatrixAllSub[input$gene,],x=timeC, col=c("black","red")[as.numeric(factor(treat))], pch=19,cex=.6,xaxt="n",xlab="Time", ylab="Expression")
    lines(x=unique(timeC[!timeC==0]),y=colMeans(sapply(unique(timeC[!timeC==0]), function(t) as.matrix(countMatrixAllSub[input$gene,treat=="c" & timeC==t]))), col=1)
    lines(x=unique(timeC[!timeC==0]),y=colMeans(sapply(unique(timeC[!timeC==0]), function(t) as.matrix(countMatrixAllSub[input$gene,treat=="t" & timeC==t]))), col=2)
    axis(1,at=c(0,0.25,1,3,6,9),labels=c("","15m","1h","3h","6h","9h"))
    abline(v=c(0,0.25,1,3,6,9),col=alpha("grey",.6))
    mtext("Conditioned",side=3, adj=0,col="red")
    mtext("Unconditioned",side=3, adj=0.2, col="black")
  })
})

# Run the application
shinyApp(ui = ui, server = server)

0 个答案:

没有答案