satijalab / sctransform

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

Reproducible SCTransform crash #120

Closed ms3389 closed 2 years ago

ms3389 commented 2 years ago

Reproducible SCTransform crash on a particular Seurat object:

library(Seurat) sample.tmp.seurat = readRDS(file = 'SCTransform_crash.rds') sample.tmp.seurat <- SCTransform(sample.tmp.seurat, verbose = TRUE)

Seurat object dropbox link: https://www.dropbox.com/s/g1a04widdj9jvp3/SCTransform_crash.rds?dl=0

Error:

  sample.tmp.seurat <- SCTransform(sample.tmp.seurat, verbose = TRUE)

Calculating cell attributes from input UMI matrix: log_umi Variance stabilizing transformation of count matrix of size 16720 by 5628 Model formula is y ~ log_umi Get Negative Binomial regression parameters per gene Using 2000 genes, 5000 cells |=================================================================================================================== | 75%

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': missing value where TRUE/FALSE needed In addition: There were 50 or more warnings (use warnings() to see the first 50)

sessionInfo:

sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages: [1] SeuratObject_4.0.4 Seurat_4.0.6

loaded via a namespace (and not attached): [1] nlme_3.1-152 matrixStats_0.61.0 spatstat.sparse_2.1-0 RcppAnnoy_0.0.19 RColorBrewer_1.1-2 httr_1.4.2 sctransform_0.3.2
[8] tools_4.1.1 utf8_1.2.2 R6_2.5.1 irlba_2.3.5 rpart_4.1-15 KernSmooth_2.23-20 uwot_0.1.11
[15] mgcv_1.8-36 DBI_1.1.2 lazyeval_0.2.2 colorspace_2.0-2 tidyselect_1.1.1 gridExtra_2.3 compiler_4.1.1
[22] plotly_4.10.0 scales_1.1.1 lmtest_0.9-39 spatstat.data_2.1-2 ggridges_0.5.3 pbapply_1.5-0 goftest_1.2-3
[29] stringr_1.4.0 digest_0.6.28 spatstat.utils_2.3-0 pkgconfig_2.0.3 htmltools_0.5.2 parallelly_1.30.0 fastmap_1.1.0
[36] htmlwidgets_1.5.4 rlang_0.4.12 shiny_1.7.1 generics_0.1.1 zoo_1.8-9 jsonlite_1.7.2 ica_1.0-2
[43] dplyr_1.0.7 magrittr_2.0.1 patchwork_1.1.1 Matrix_1.3-4 Rcpp_1.0.7 munsell_0.5.0 fansi_0.5.0
[50] abind_1.4-5 reticulate_1.22 lifecycle_1.0.1 stringi_1.7.6 MASS_7.3-54 Rtsne_0.15 plyr_1.8.6
[57] grid_4.1.1 parallel_4.1.1 listenv_0.8.0 promises_1.2.0.1 ggrepel_0.9.1 crayon_1.4.2 miniUI_0.1.1.1
[64] deldir_1.0-6 lattice_0.20-44 cowplot_1.1.1 splines_4.1.1 tensor_1.5 knitr_1.37 pillar_1.6.4
[71] igraph_1.2.7 spatstat.geom_2.3-1 future.apply_1.8.1 reshape2_1.4.4 codetools_0.2-18 leiden_0.3.9 glue_1.4.2
[78] data.table_1.14.2 png_0.1-7 vctrs_0.3.8 httpuv_1.6.4 gtable_0.3.0 RANN_2.6.1 purrr_0.3.4
[85] spatstat.core_2.3-2 polyclip_1.10-0 tidyr_1.1.4 scattermore_0.7 future_1.23.0 assertthat_0.2.1 ggplot2_3.3.5
[92] xfun_0.27 mime_0.12 xtable_1.8-4 later_1.3.0 survival_3.2-11 viridisLite_0.4.0 tibble_3.1.5
[99] cluster_2.1.2 globals_0.14.0 fitdistrplus_1.1-6 ellipsis_0.3.2 ROCR_1.0-11

saketkc commented 2 years ago

I am unable to replicate this using sctransform from the development branch. Can you try installing sctransform from the dev branch devtools::install_github("satijalab/sctransform", ref="develop")?

> obj <- readRDS("SCTransform_crash.rds")
> obj <- SCTransform(obj)
Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 16720 by 5628
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 5000 cells
  |=================================================================================================================================================| 100%
Found 139 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 16720 genes
  |=================================================================================================================================================| 100%
Computing corrected count matrix for 16720 genes
  |=================================================================================================================================================| 100%
Calculating gene attributes
Wall clock passed: Time difference of 52.93888 secs
Determine variable features
Place corrected count matrix in counts slot
Centering data matrix
  |=================================================================================================================================================| 100%
Set default assay to SCT
ms3389 commented 2 years ago

I tried installing the developer branch as you suggested but I'm still getting the same error on that one particular object (out of 31 for this dataset)

I installed Seurat and sctransform from scratch by deleting them manually from my library to be sure and the error still persists.

I installed the developer version via devtools::install_github("satijalab/sctransform", ref="develop") and remotes::install_github("ChristophH/sctransform@develop", force = T)

I've also updated all my packages to the latest versions.

Any suggestions?

Thanks!!

sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages: [1] SeuratObject_4.0.4 Seurat_4.0.6

loaded via a namespace (and not attached): [1] Rtsne_0.15 colorspace_2.0-2 deldir_1.0-6 ellipsis_0.3.2 ggridges_0.5.3 rprojroot_2.0.2
[7] fs_1.5.2 spatstat.data_2.1-2 rstudioapi_0.13 leiden_0.3.9 listenv_0.8.0 remotes_2.4.2
[13] ggrepel_0.9.1 fansi_0.5.0 codetools_0.2-18 splines_4.1.1 cachem_1.0.6 knitr_1.37
[19] polyclip_1.10-0 pkgload_1.2.4 jsonlite_1.7.2 ica_1.0-2 cluster_2.1.2 png_0.1-7
[25] uwot_0.1.11 spatstat.sparse_2.1-0 shiny_1.7.1 sctransform_0.3.2.9008 compiler_4.1.1 httr_1.4.2
[31] assertthat_0.2.1 Matrix_1.4-0 fastmap_1.1.0 lazyeval_0.2.2 cli_3.1.0 later_1.3.0
[37] htmltools_0.5.2 prettyunits_1.1.1 tools_4.1.1 igraph_1.2.10 gtable_0.3.0 glue_1.6.0
[43] RANN_2.6.1 reshape2_1.4.4 dplyr_1.0.7 Rcpp_1.0.7 scattermore_0.7 vctrs_0.3.8
[49] nlme_3.1-152 lmtest_0.9-39 xfun_0.29 stringr_1.4.0 globals_0.14.0 ps_1.6.0
[55] testthat_3.1.1 mime_0.12 miniUI_0.1.1.1 lifecycle_1.0.1 irlba_2.3.5 devtools_2.4.3
[61] goftest_1.2-3 future_1.23.0 MASS_7.3-54 zoo_1.8-9 scales_1.1.1 spatstat.core_2.3-2
[67] spatstat.utils_2.3-0 promises_1.2.0.1 parallel_4.1.1 RColorBrewer_1.1-2 curl_4.3.2 memoise_2.0.1
[73] reticulate_1.22 pbapply_1.5-0 gridExtra_2.3 ggplot2_3.3.5 rpart_4.1-15 stringi_1.7.6
[79] desc_1.4.0 pkgbuild_1.3.1 rlang_0.4.12 pkgconfig_2.0.3 matrixStats_0.61.0 lattice_0.20-44
[85] tensor_1.5 ROCR_1.0-11 purrr_0.3.4 patchwork_1.1.1 htmlwidgets_1.5.4 cowplot_1.1.1
[91] processx_3.5.2 tidyselect_1.1.1 parallelly_1.30.0 RcppAnnoy_0.0.19 plyr_1.8.6 magrittr_2.0.1
[97] R6_2.5.1 generics_0.1.1 DBI_1.1.2 mgcv_1.8-36 pillar_1.6.4 withr_2.4.3
[103] fitdistrplus_1.1-6 abind_1.4-5 survival_3.2-11 tibble_3.1.6 future.apply_1.8.1 crayon_1.4.2
[109] KernSmooth_2.23-20 utf8_1.2.2 spatstat.geom_2.3-1 plotly_4.10.0 usethis_2.1.5 grid_4.1.1
[115] data.table_1.14.2 callr_3.7.0 digest_0.6.29 xtable_1.8-4 tidyr_1.1.4 httpuv_1.6.4
[121] munsell_0.5.0 viridisLite_0.4.0 sessioninfo_1.2.2

saketkc commented 2 years ago

Can you try installing glmGamPoi and pass it to SCTransform: SCTransform(method="glmGamPoi")

ms3389 commented 2 years ago

That did the trick! Thank you! Question - does specifying this method change the behavior of SCTransform? If so is there some documentation I can review? Should all the samples be redone with this method for consistence?

saketkc commented 2 years ago

No, glmGamPoi just provides a faster (and often more stable) maximum likelihood estimates. It would make little difference switching from one to other estimator.