result different between the local application and the one on shinyapps.io

Hi everyone,
I'm developing my first shiny app and it's working fine on my computer, but when I publish it on shinyapps.io it disconnects from server and stops working.
There isn't anything in the log and looking at the developper console on my browser, I could only find a code":4702, message.

After digging a little bit I managed to isolate the line inside my code with the problem.
It seems to be linked to the following call
BSgenome::getSeq()

Trying to figure out what was the problem with this function, I did this :

library(shiny)
library(BSgenome.Hsapiens.NCBI.GRCh38)

# Define UI for application that draws a histogram
ui <- fluidPage(
    titlePanel("Bsgenome test"),
    verbatimTextOutput("bs_text")
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  output$bs_text <- renderPrint(Biostrings::getSeq(BSgenome.Hsapiens.NCBI.GRCh38, names = "5"))
}

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

I was a little bit suprised by the difference between the locale and online version of this code

I don't understand why there is a difference ?

Hmm, on my computer it agrees with the shinyapps.io output:

library(BSgenome.Hsapiens.NCBI.GRCh38)

xx <- Biostrings::getSeq(BSgenome.Hsapiens.NCBI.GRCh38, names = "5")
xx
#> 181538259-letter DNAString object
#> seq: NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
substr(xx, 100000,101000)
#> 1001-letter DNAString object
#> seq: TTCTGTTAATGTGGTGTATTACATTGATTGGTTTTC...AAAGCCCTGGAAAAAGTCTGTAGGGGAGAGACTGTT

Created on 2022-05-25 by the reprex package (v2.0.1)

On your local computer, if you just print Biostrings::getSeq(BSgenome.Hsapiens.NCBI.GRCh38, names = "5") not in a Shiny app, do you get a better result? I think the [48;5;249... is the ANSI to try and print with colors. That would happen if your terminal does not support {crayon}, or in other words, not a problem you need to worry about for now.

So I suspect the fact that you get an error on shinapps.io is unrelated to this difference in output. Is there a more explicit error message after the "code 4702"? Is it possible your Shiny app is running out of memory? Could you try a smaller genome?
You could try adding a few cat() to follow the App execution in the logs, and get a better idea of where exactly it fails (before getSeq() or when executing renderPrint()).

Indeed, it is definitely a memory issue.
It works with a smaller genome and runs like a charm if I use :

rsconnect::configureApp("myapp", size="xlarge")

Regarding the difference between local and shinyapp.io.
Using the same command outside shinyapp give a good print, with a grey background.

Thanks a lot for your help

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.