satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

SCTransform function error #8258

Closed redtorrentCN closed 9 months ago

redtorrentCN commented 9 months ago

Hi, all

I'm just a fresh man using Seurat. when I run tutorial code step by step, an error occurred in SCTransform function as following:

library(Seurat) library(SeuratData)` library(SeuratWrappers)

library(Azimuth)

library(ggplot2) library(patchwork)

obj <- LoadData("pbmcsca") obj <- subset(obj, nFeature_RNA > 1000) options(future.globals.maxSize = 3e+09) obj <- SCTransform(obj,conserve.memory=TRUE)

Running SCTransform on assay: RNA Running SCTransform on layer: counts.Smart-seq2 vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes. Variance stabilizing transformation of count matrix of size 18301 by 512 Model formula is y ~ log_umi Get Negative Binomial regression parameters per gene Using 2000 genes, 512 cells Found 1 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 18301 genes Computing corrected count matrix for 18301 genes Calculating gene attributes Wall clock passed: Time difference of 10.37887 secs Determine variable features Centering data matrix |==============================================================================| 100% Error in asMethod(object) : could not find function "asMethod"

obj <- PrepSCTFindMarkers(obj)

Error in object[[assay]]: ! ‘SCT’ not found in this Seurat object

sessionIfo()

R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.3 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 LAPACK: /anaconda3/envs/scvi-env/lib/libmkl_rt.so.2; LAPACK version 3.10.1

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Asia/Shanghai tzcode source: system (glibc)

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

other attached packages: [1] patchwork_1.1.3 ggplot2_3.4.4 SeuratWrappers_0.3.2
[4] pbmcsca.SeuratData_3.0.0 ifnb.SeuratData_3.1.0 SeuratData_0.2.2.9001
[7] Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-2

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 rstudioapi_0.15.0
[3] jsonlite_1.8.8 magrittr_2.0.3
[5] spatstat.utils_3.0-4 farver_2.1.1
[7] zlibbioc_1.48.0 vctrs_0.6.5
[9] ROCR_1.0-11 DelayedMatrixStats_1.24.0
[11] spatstat.explore_3.2-5 RCurl_1.98-1.13
[13] S4Arrays_1.2.0 htmltools_0.5.7
[15] SparseArray_1.2.3 sctransform_0.4.1
[17] parallelly_1.36.0 KernSmooth_2.23-22
[19] htmlwidgets_1.6.4 ica_1.0-3
[21] plyr_1.8.9 plotly_4.10.3
[23] zoo_1.8-12 igraph_1.6.0
[25] mime_0.12 lifecycle_1.0.4
[27] pkgconfig_2.0.3 rsvd_1.0.5
[29] Matrix_1.6-4 R6_2.5.1
[31] fastmap_1.1.1 GenomeInfoDbData_1.2.11
[33] MatrixGenerics_1.14.0 fitdistrplus_1.1-11
[35] future_1.33.1 shiny_1.8.0
[37] digest_0.6.33 colorspace_2.1-0
[39] S4Vectors_0.40.2 tensor_1.5
[41] RSpectra_0.16-1 irlba_2.3.5.1
[43] Seurat4_4.4.0 GenomicRanges_1.54.1
[45] labeling_0.4.3 progressr_0.14.0
[47] fansi_1.0.6 spatstat.sparse_3.0-3
[49] httr_1.4.7 polyclip_1.10-6
[51] abind_1.4-5 compiler_4.3.1
[53] remotes_2.4.2.1 withr_2.5.2
[55] fastDummies_1.7.3 R.utils_2.12.3
[57] MASS_7.3-60 DelayedArray_0.28.0
[59] rappdirs_0.3.3 tools_4.3.1
[61] lmtest_0.9-40 httpuv_1.6.13
[63] future.apply_1.11.1 goftest_1.2-3
[65] glmGamPoi_1.14.0 R.oo_1.25.0
[67] glue_1.6.2 nlme_3.1-163
[69] promises_1.2.1 grid_4.3.1
[71] Rtsne_0.17 cluster_2.1.4
[73] reshape2_1.4.4 generics_0.1.3
[75] gtable_0.3.4 spatstat.data_3.0-3
[77] R.methodsS3_1.8.2 tidyr_1.3.0
[79] data.table_1.14.10 XVector_0.42.0
[81] utf8_1.2.4 BiocGenerics_0.48.1
[83] spatstat.geom_3.2-7 RcppAnnoy_0.0.21
[85] ggrepel_0.9.4 RANN_2.6.1
[87] pillar_1.9.0 stringr_1.5.1
[89] spam_2.10-0 RcppHNSW_0.5.0
[91] later_1.3.2 splines_4.3.1
[93] dplyr_1.1.4 lattice_0.21-9
[95] survival_3.5-7 deldir_2.0-2
[97] tidyselect_1.2.0 miniUI_0.1.1.1
[99] pbapply_1.7-2 gridExtra_2.3
[101] IRanges_2.36.0 SummarizedExperiment_1.32.0 [103] scattermore_1.2 stats4_4.3.1
[105] Biobase_2.62.0 matrixStats_1.2.0
[107] stringi_1.8.3 lazyeval_0.2.2
[109] codetools_0.2-19 tibble_3.2.1
[111] BiocManager_1.30.22 cli_3.6.2
[113] uwot_0.1.16 xtable_1.8-4
[115] reticulate_1.34.0 munsell_0.5.0
[117] GenomeInfoDb_1.38.5 Rcpp_1.0.11
[119] globals_0.16.2 spatstat.random_3.2-2
[121] png_0.1-8 parallel_4.3.1
[123] ellipsis_0.3.2 dotCall64_1.1-1
[125] sparseMatrixStats_1.14.0 bitops_1.0-7
[127] listenv_0.9.0 viridisLite_0.4.2
[129] scales_1.3.0 ggridges_0.5.5
[131] leiden_0.4.3.1 purrr_1.0.2
[133] crayon_1.5.2 rlang_1.1.2
[135] cowplot_1.1.2

I don't know how to correct this.

Above. thanks for your answers!

saketkc commented 9 months ago

For some reason you have both Seurat4 and Seurat5loaded. I cannot reproduce this with Seurat5:

Can you try uninstalling Seurat4 and then restart your session:

uninstall.packages(c("Seurat4")) # restart and rerun 
> obj[["RNA"]] <- split(x = obj[["RNA"]], f = obj$Method)
> 
> obj <- SCTransform(obj
+ )
Running SCTransform on assay: RNA
Running SCTransform on layer: counts.Smart-seq2
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 18301 by 512
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 512 cells
Found 1 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 18301 genes
Computing corrected count matrix for 18301 genes
Calculating gene attributes
Wall clock passed: Time difference of 5.985782 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.CEL-Seq2
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 15859 by 504
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 504 cells
Found 66 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 15859 genes
Computing corrected count matrix for 15859 genes
Calculating gene attributes
Wall clock passed: Time difference of 4.800133 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.10x_Chromium_v2_A
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 13191 by 844
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 844 cells
Found 82 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 13191 genes
Computing corrected count matrix for 13191 genes
Calculating gene attributes
Wall clock passed: Time difference of 5.974408 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.10x_Chromium_v2_B
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 12822 by 831
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 831 cells
Found 84 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 12822 genes
Computing corrected count matrix for 12822 genes
Calculating gene attributes
Wall clock passed: Time difference of 5.173038 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.10x_Chromium_v3
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 16651 by 2866
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 2866 cells
Found 48 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 16651 genes
Computing corrected count matrix for 16651 genes
Calculating gene attributes
Wall clock passed: Time difference of 16.44587 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.Drop-seq
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 15203 by 1810
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 1810 cells
Found 7 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 15203 genes
Computing corrected count matrix for 15203 genes
Calculating gene attributes
Wall clock passed: Time difference of 8.902395 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.Seq-Well
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 10546 by 350
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 350 cells
Found 10 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 10546 genes
Computing corrected count matrix for 10546 genes
Calculating gene attributes
Wall clock passed: Time difference of 3.363313 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.inDrops
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 11594 by 545
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 545 cells
Found 35 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 11594 genes
Computing corrected count matrix for 11594 genes
Calculating gene attributes
Wall clock passed: Time difference of 3.834601 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Running SCTransform on layer: counts.10x_Chromium_v2
vst.flavor='v2' set. Using model with fixed slope and excluding poisson genes.
Variance stabilizing transformation of count matrix of size 16261 by 2172
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 2172 cells
Found 108 outliers - those will be ignored in fitting/regularization step

Second step: Get residuals using fitted parameters for 16261 genes
Computing corrected count matrix for 16261 genes
Calculating gene attributes
Wall clock passed: Time difference of 12.89776 secs
Determine variable features
Centering data matrix
  |===========================================================================================================================| 100%
Set default assay to SCT
> obj <- PrepSCTFindMarkers(obj)
Found 9 SCT models. Recorrecting SCT counts using minimum median counts: 2572
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=25s