SGDDNB / ShinyCell

Shiny Interactive Web Apps for Single-Cell Data
GNU General Public License v3.0
151 stars 57 forks source link

launching shiny app throws errors #30

Closed kmshort closed 2 years ago

kmshort commented 2 years ago

Hi, Wonderful tool! I can launch the example shiny app from within Rstudio.. by doing something like this:

library(Seurat)
library(ShinyCell)

getExampleData()                       # Download example dataset (~200 MB)
seu = readRDS("readySeu_rset.rds")
scConf = createConfig(seu)
makeShinyApp(seu, scConf, gene.mapping = TRUE,
             shiny.title = "ShinyCell Quick Start") 

library(shiny)
runApp("shinyApp/")

the app displays, is fully interactive, and for all intents and purposes, seems to work. BUT, in the console - an error is thrown:

Error in if: missing value where TRUE/FALSE needed  106: args_regularity_evaluation
  105: h5data$read
  104: scDRnum [/mnt/d/low protein/snRNAseq/NPD_LPD_Bioinformatics/bioinformatics/shinyCell Scripts/shinyApp/server.R#150]
  103: exprFunc [/mnt/d/low protein/snRNAseq/NPD_LPD_Bioinformatics/bioinformatics/shinyCell Scripts/shinyApp/server.R#698]
  102: widgetFunc
  101: htmlwidgets::shinyRenderWidget
  100: func
   87: origRenderFunc
   86: renderFunc
   82: origRenderFunc
   81: output$sc1a1.dt
    1: runApp
  170: args_regularity_evaluation
  169: h5data$read
  168: scDRgene [/mnt/d/low protein/snRNAseq/NPD_LPD_Bioinformatics/bioinformatics/shinyCell Scripts/shinyApp/server.R#191]
  167: renderPlot [/mnt/d/low protein/snRNAseq/NPD_LPD_Bioinformatics/bioinformatics/shinyCell Scripts/shinyApp/server.R#707]
  165: func
  125: drawPlot
  111: <reactive:plotObj>
   95: drawReactive
   82: origRenderFunc
   81: output$sc1a1oup2
    1: runApp

This is my sessionInfo() when I run the app from within Rstudio:

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8   
 [6] LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C        
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggdendro_0.1.22    ggrepel_0.9.0      magrittr_2.0.1     DT_0.16            shinyhelper_0.3.2  shiny_1.5.0       
 [7] ShinyCell_2.1.0    RColorBrewer_1.1-2 readr_1.4.0        glue_1.4.2         gridExtra_2.3      ggplot2_3.3.5     
[13] R.utils_2.10.1     R.oo_1.24.0        R.methodsS3_1.8.1  reticulate_1.18    hdf5r_1.3.3        Matrix_1.3-2      
[19] data.table_1.13.4  Seurat_3.2.3      

loaded via a namespace (and not attached):
  [1] Rtsne_0.15           colorspace_2.0-0     deldir_0.2-3         ellipsis_0.3.2       ggridges_0.5.2      
  [6] rstudioapi_0.13      spatstat.data_2.1-0  farver_2.0.3         leiden_0.3.6         listenv_0.8.0       
 [11] bit64_4.0.5          fansi_0.4.1          codetools_0.2-18     splines_4.0.3        knitr_1.30          
 [16] polyclip_1.10-0      jsonlite_1.7.2       Cairo_1.5-12.2       ica_1.0-2            cluster_2.1.0       
 [21] png_0.1-7            uwot_0.1.10          sctransform_0.3.2    compiler_4.0.3       httr_1.4.2          
 [26] assertthat_0.2.1     fastmap_1.0.1        lazyeval_0.2.2       later_1.1.0.1        htmltools_0.5.1.1   
 [31] tools_4.0.3          rsvd_1.0.3           igraph_1.2.6         gtable_0.3.0         RANN_2.6.1          
 [36] reshape2_1.4.4       dplyr_1.0.7          tinytex_0.28         Rcpp_1.0.5           spatstat_1.64-1     
 [41] scattermore_0.7      vctrs_0.3.8          nlme_3.1-151         crosstalk_1.1.0.1    lmtest_0.9-38       
 [46] xfun_0.19            stringr_1.4.0        globals_0.14.0       mime_0.9             miniUI_0.1.1.1      
 [51] lifecycle_1.0.0      irlba_2.3.3          goftest_1.2-2        future_1.21.0        MASS_7.3-53         
 [56] zoo_1.8-8            scales_1.1.1         hms_1.1.0            promises_1.1.1       spatstat.utils_2.2-0
 [61] parallel_4.0.3       yaml_2.2.1           pbapply_1.4-3        rpart_4.1-15         stringi_1.5.3       
 [66] rlang_0.4.11         pkgconfig_2.0.3      matrixStats_0.57.0   evaluate_0.14        lattice_0.20-41     
 [71] ROCR_1.0-11          purrr_0.3.4          tensor_1.5           labeling_0.4.2       patchwork_1.1.1     
 [76] htmlwidgets_1.5.3    cowplot_1.1.0        bit_4.0.4            tidyselect_1.1.0     parallelly_1.22.0   
 [81] RcppAnnoy_0.0.18     plyr_1.8.6           R6_2.5.0             generics_0.1.0       DBI_1.1.0           
 [86] pillar_1.6.2         withr_2.3.0          mgcv_1.8-33          fitdistrplus_1.1-3   survival_3.2-7      
 [91] abind_1.4-5          tibble_3.1.4         future.apply_1.6.0   crayon_1.4.1         KernSmooth_2.23-18  
 [96] utf8_1.1.4           plotly_4.9.2.2       rmarkdown_2.6        digest_0.6.27        xtable_1.8-4        
[101] tidyr_1.1.3          httpuv_1.5.4         munsell_0.5.0        viridisLite_0.3.0   

Further, when I try to deploy this app on a shinyserver, the web browser renders this message rather than the app:

An error has occurred!
An error has occurred. Check your logs or contact the app author for clarification.

I can only think that this error has something to do with the errors that I see in the R console when I run the app from within R studio.

Any help would be greatly appreciated, and I've used the example data here to make it easier.

cheers, Kieran

kmshort commented 2 years ago

I should add that I'm running shiny-server version 1.5.17.973 (October 18, 2021 release).

kmshort commented 2 years ago

Okay, I'll try and bugfix it myself.

Something is up with the scDRnum and scDRgene functions. That's what I've got to so far.

jfouyang commented 2 years ago

Sorry for the delayed reply. The error message in the console is expected. Basically, it happens because the shiny app tries to load itself before the h5 files are being accessed. Eventually, this fixes itself (i.e. the h5files get accessed properly) and there should be no difference to an external user.

Given that the app works on RStudio and it crashes on shiny-server, I think the main problem lies with the shiny-server. One possibility I can think of is that... on the installation instructions, it says that additional packages have to be installed on the shiny server. I have reproduced the code to install the packages below:

reqPkg = c("shiny", "shinyhelper", "data.table", "Matrix", "DT", "hdf5r", 
           "reticulate", "ggplot2", "gridExtra", "magrittr", "ggdendro")
newPkg = reqPkg[!(reqPkg %in% installed.packages()[,"Package"])]
if(length(newPkg)){install.packages(newPkg)}

Have you installed these packages on the shiny-server?

jfouyang commented 2 years ago

To further test if the packages work on the shiny-server, can you make a new shinyapp using these two files and check if the app runs on the shiny-server? These two files only loads the packages and does nothing else.

ui.R:

library(shiny) 
library(shinyhelper) 
library(data.table) 
library(Matrix) 
library(DT) 
library(magrittr) 

ui <- fluidPage(
  "Hello, world!"
)

server.R

library(shiny) 
library(shinyhelper) 
library(data.table) 
library(Matrix) 
library(DT) 
library(magrittr) 
library(ggplot2) 
library(ggrepel) 
library(hdf5r) 
library(ggdendro) 
library(gridExtra) 

server <- function(input, output, session) {
}
kmshort commented 2 years ago

thanks - my server is offline at the moment so can't test yet - I'll let you know.

kmshort commented 2 years ago

To further test if the packages work on the shiny-server, can you make a new shinyapp using these two files and check if the app runs on the shiny-server? These two files only loads the packages and does nothing else.

ui.R:

library(shiny) 
library(shinyhelper) 
library(data.table) 
library(Matrix) 
library(DT) 
library(magrittr) 

ui <- fluidPage(
  "Hello, world!"
)

server.R

library(shiny) 
library(shinyhelper) 
library(data.table) 
library(Matrix) 
library(DT) 
library(magrittr) 
library(ggplot2) 
library(ggrepel) 
library(hdf5r) 
library(ggdendro) 
library(gridExtra) 

server <- function(input, output, session) {
}

Hi, thanks for your help. Yes, this throws the same error message. Now I just need to find out why shiny-server throws them when R on the same server sees them perfectly.

kmshort commented 2 years ago

Hello again, If I edit /etc/shiny-server/shiny-server.conf to change the user from run_as shiny; to run_as MyusernameLogin;

Then it works. My server is an instance from an academic research cluster; so I don't have the default shiny account password. So once I get that, I can probably get the packages installed under that user.

thanks for your help Kieran

kmshort commented 2 years ago

Hi again @jfouyang I have it working now. I just wasn't sure how to configure shiny-server. I didn't realise shiny-server was run under user "shiny". Once I'd logged in as "shiny" and installed the necessary packages as in your guide, it worked. many thanks, Kieran

jfouyang commented 2 years ago

Glad that the issue is resolved. Yes, it is quite common to have issues on the shiny-server since it is usually administered remotely. I will close the issue then. Thanks again for using ShinyCell!