satijalab / sctransform

R package for modeling single cell UMI expression data using regularized negative binomial regression
GNU General Public License v3.0
206 stars 33 forks source link

sctransform: Error: node stack overflow #87

Closed duocang closed 3 years ago

duocang commented 3 years ago

Hi.

I am doing normal Seruat data process.

I tried with a very small dataset to run SCTransofrm but there is always an error. I got 32 GB RAM so I do not think it is a RAM problem.

If I save the Seurat object locally and then read the .rds and do SCTransform in other folder it works.

I have been stuck in this place for days and there is not much information concerning this.

Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from spliced_rna_ to splicedrna_
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from unspliced_rna_ to unsplicedrna_
Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 900 by 4208
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 900 genes, 4208 cells
  |                                           |   0%Error: node stack overflow
Error during wrapup: node stack overflow
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

Thank you!

@ChristophH tried traceback(), NO traceback available.

ChristophH commented 3 years ago

Hi, There are only 900 genes being used to estimate the parameters - that's not a problem, but lower than the default and makes me wonder whether something with your input matrix is off. Can you share the input object, so I can have a look? Also, always run traceback() after seeing the error and share the output as that can help to pinpoint the problem.

duocang commented 3 years ago

Hi @ChristophH

I have deleted the small data so I uploaded a bit one into OneDeive (1gb) , please feel free to try it out. https://1drv.ms/u/s!AtjLM4-mbBLkx8s9GP9060v5lrsxKQ?e=Of1bZX

I have tried the data again, still the same erro.

>seu <- readRDS(here("test_result/seurat_before_sct.rds"))
> seu <- SCTransform(seu, assay = "RNA", variable.features.n=500,
+                    new.assay.name = "SCT", verbose = TRUE)
Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 24718 by 17542
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 5000 cells
  |                                                           |   0%Error: node stack overflow
Error during wrapup: node stack overflow
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
> traceback()
No traceback available 
> 
ChristophH commented 3 years ago

I cannot reproduce the error. The output I see is

Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 24718 by 17542
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 5000 cells
  |=====================================================================| 100%
Found 39 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 24718 genes
  |=====================================================================| 100%
Computing corrected count matrix for 24718 genes
  |=====================================================================| 100%

I then run out of memory, but that was expected. If I pass the conserve.memory = TRUE parameter to Seurat::SCTransform it finishes without a problem.

Which versions of Seurat and sctransform are you using? You could try updating to the develop version of sctransform (remotes::install_github("ChristophH/sctransform@develop")) and Seurat (remotes::install_github("satijalab/seurat@release/4.0.0")).

In case it helps, here is my session info:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] Seurat_3.9.9.9008      sctransform_0.3.2.9000 Matrix_1.2-18         

loaded via a namespace (and not attached):
  [1] Rtsne_0.15                  colorspace_2.0-0           
  [3] deldir_0.1-29               ellipsis_0.3.1             
  [5] ggridges_0.5.2              XVector_0.28.0             
  [7] GenomicRanges_1.40.0        spatstat.data_1.4-3        
  [9] leiden_0.3.3                listenv_0.8.0              
 [11] ggrepel_0.8.2               codetools_0.2-16           
 [13] splines_4.0.2               knitr_1.30                 
 [15] polyclip_1.10-0             jsonlite_1.7.2             
 [17] ica_1.0-2                   cluster_2.1.0              
 [19] png_0.1-7                   uwot_0.1.8.9001            
 [21] shiny_1.5.0                 compiler_4.0.2             
 [23] httr_1.4.2                  fastmap_1.0.1              
 [25] lazyeval_0.2.2              later_1.1.0.1              
 [27] htmltools_0.5.0             tools_4.0.2                
 [29] rsvd_1.0.3                  igraph_1.2.6               
 [31] gtable_0.3.0                glue_1.4.2                 
 [33] GenomeInfoDbData_1.2.3      RANN_2.6.1                 
 [35] reshape2_1.4.4              dplyr_1.0.2                
 [37] rappdirs_0.3.1              tinytex_0.27               
 [39] Rcpp_1.0.5                  spatstat_1.64-1            
 [41] Biobase_2.48.0              vctrs_0.3.5                
 [43] nlme_3.1-149                lmtest_0.9-38              
 [45] xfun_0.19                   stringr_1.4.0              
 [47] globals_0.13.1              mime_0.9                   
 [49] miniUI_0.1.1.1              lifecycle_0.2.0            
 [51] irlba_2.3.3                 goftest_1.2-2              
 [53] future_1.19.1               zlibbioc_1.34.0            
 [55] MASS_7.3-53                 zoo_1.8-8                  
 [57] scales_1.1.1                promises_1.1.1             
 [59] spatstat.utils_1.17-0       parallel_4.0.2             
 [61] SummarizedExperiment_1.18.2 RColorBrewer_1.1-2         
 [63] yaml_2.2.1                  reticulate_1.16            
 [65] pbapply_1.4-3               gridExtra_2.3              
 [67] ggplot2_3.3.2               rpart_4.1-15               
 [69] stringi_1.5.3               S4Vectors_0.26.1           
 [71] BiocGenerics_0.34.0         GenomeInfoDb_1.24.2        
 [73] rlang_0.4.9                 pkgconfig_2.0.3            
 [75] matrixStats_0.57.0          bitops_1.0-6               
 [77] evaluate_0.14               lattice_0.20-41            
 [79] glmGamPoi_1.3.4             tensor_1.5                 
 [81] ROCR_1.0-11                 purrr_0.3.4                
 [83] patchwork_1.1.0.9000        htmlwidgets_1.5.2          
 [85] cowplot_1.1.0               tidyselect_1.1.0           
 [87] RcppAnnoy_0.0.16            plyr_1.8.6                 
 [89] magrittr_2.0.1              R6_2.5.0                   
 [91] IRanges_2.22.2              generics_0.0.2             
 [93] DelayedArray_0.14.1         mgcv_1.8-33                
 [95] pillar_1.4.7                fitdistrplus_1.1-1         
 [97] abind_1.4-5                 survival_3.2-3             
 [99] RCurl_1.98-1.2              tibble_3.0.4               
[101] future.apply_1.6.0          crayon_1.3.4.9000          
[103] KernSmooth_2.23-17          plotly_4.9.2.1             
[105] rmarkdown_2.5               grid_4.0.2                 
[107] data.table_1.13.2           digest_0.6.27              
[109] xtable_1.8-4                tidyr_1.1.2                
[111] httpuv_1.5.4                stats4_4.0.2               
[113] munsell_0.5.0               viridisLite_0.3.0 
duocang commented 3 years ago

@ChristophH Thank you for trying.

I have realized this could be a problem of R-project configuration.

SCTransform works well when setwd to a new environment. I am not sure what is the issue but it should be clear that it is not a problem from SCTransfrom.

duocang commented 3 years ago

Just in case someone meets this problem again.

Solution: Try another version of RStudio.

After one month of coding with Seurat, I met the problem again and had no clue why it happens(no coding even chagned).

I tried an old version RStudio and the problem is gone. I am just tried of debugging into R Library any more.