Open
Description
Hi, I faced a strange behavior of SCTransform when specifying vars.to.regress.
For examples, in the former two cases below, SCTransform returns the identical scale.data when specifying vars.to.regress = NULL and vars.to.regress = "percent.mt".
How can I fix this problem?
Thank you.
library(Seurat)
library(ggplot2)
library(patchwork)
options(future.globals.maxSize = 3e+09)
# on my data
obj <- Read10X( data.dir = "./filtered_feature_bc_matrix" );
obj <- CreateSeuratObject( counts = obj );
obj[[ "percent.mt" ]] <- PercentageFeatureSet( obj, pattern="^mt-" );
a <- SCTransform( obj, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = NULL, verbose = F );
b <- SCTransform( obj, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = "percent.mt", verbose = F );
identical( a[[ "SCT" ]]$scale.data, b[[ "SCT" ]]$scale.data );
[1] TRUE
library(SeuratData)
# on pbmcsca data
pbmcsca <- LoadData( "pbmcsca" );
pbmcsca[[ "percent.mt" ]] <- PercentageFeatureSet( pbmcsca, pattern="^MT-" );
c <- SCTransform( pbmcsca, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = NULL, verbose = F );
d <- SCTransform( pbmcsca, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = "percent.mt", verbose = F );
identical( c[[ "SCT" ]]$scale.data, d[[ "SCT" ]]$scale.data );
[1] TRUE
# on pbmc3k
pbmc <- LoadData( "pbmc3k" );
pbmc[[ "percent.mt" ]] <- PercentageFeatureSet( pbmc, pattern = "^MT-" );
g <- SCTransform( pbmc, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = NULL, verbose = F );
h <- SCTransform( pbmc, method = "glmGamPoi", variable.features.n = 3000, vars.to.regress = "percent.mt", verbose = F );
identical( g[[ "SCT" ]]$scale.data, h[[ "SCT" ]]$scale.data );
[1] FALSE
sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pbmcsca.SeuratData_3.0.0 pbmcref.SeuratData_1.0.0 pbmc3k.SeuratData_3.1.4
[4] SeuratData_0.2.2.9001 patchwork_1.2.0 ggplot2_3.4.4
[7] Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-2
loaded via a namespace (and not attached):
[1] Rtsne_0.17 colorspace_2.1-0
[3] deldir_2.0-2 ellipsis_0.3.2
[5] ggridges_0.5.5 XVector_0.38.0
[7] GenomicRanges_1.50.2 RcppHNSW_0.5.0
[9] spatstat.data_3.0-4 leiden_0.4.3.1
[11] listenv_0.9.0 ggrepel_0.9.5
[13] RSpectra_0.16-1 fansi_1.0.6
[15] sparseMatrixStats_1.10.0 codetools_0.2-19
[17] splines_4.2.3 R.methodsS3_1.8.2
[19] polyclip_1.10-6 spam_2.10-0
[21] jsonlite_1.8.8 ica_1.0-3
[23] cluster_2.1.6 png_0.1-8
[25] R.oo_1.25.0 uwot_0.1.16
[27] shiny_1.8.0 sctransform_0.4.1
[29] spatstat.sparse_3.0-3 compiler_4.2.3
[31] httr_1.4.7 Matrix_1.6-4
[33] fastmap_1.1.1 lazyeval_0.2.2
[35] cli_3.6.2 later_1.3.2
[37] htmltools_0.5.7 tools_4.2.3
[39] igraph_1.6.0 dotCall64_1.1-1
[41] GenomeInfoDbData_1.2.9 gtable_0.3.4
[43] glue_1.7.0 RANN_2.6.1
[45] reshape2_1.4.4 dplyr_1.1.4
[47] rappdirs_0.3.3 Rcpp_1.0.12
[49] Biobase_2.58.0 scattermore_1.2
[51] vctrs_0.6.5 spatstat.explore_3.2-5
[53] nlme_3.1-164 progressr_0.14.0
[55] DelayedMatrixStats_1.20.0 lmtest_0.9-40
[57] spatstat.random_3.2-2 stringr_1.5.1
[59] globals_0.16.2 mime_0.12
[61] miniUI_0.1.1.1 lifecycle_1.0.4
[63] irlba_2.3.5.1 goftest_1.2-3
[65] future_1.33.1 zlibbioc_1.44.0
[67] MASS_7.3-60.0.1 zoo_1.8-12
[69] scales_1.3.0 MatrixGenerics_1.10.0
[71] promises_1.2.1 spatstat.utils_3.0-4
[73] SummarizedExperiment_1.28.0 parallel_4.2.3
[75] RColorBrewer_1.1-3 reticulate_1.34.0
[77] pbapply_1.7-2 gridExtra_2.3
[79] stringi_1.8.3 S4Vectors_0.36.2
[81] fastDummies_1.7.3 BiocGenerics_0.44.0
[83] GenomeInfoDb_1.34.9 bitops_1.0-7
[85] rlang_1.1.3 pkgconfig_2.0.3
[87] matrixStats_1.1.0 lattice_0.22-5
[89] glmGamPoi_1.10.2 ROCR_1.0-11
[91] purrr_1.0.2 tensor_1.5
[93] htmlwidgets_1.6.4 cowplot_1.1.2
[95] tidyselect_1.2.0 parallelly_1.36.0
[97] RcppAnnoy_0.0.21 plyr_1.8.9
[99] magrittr_2.0.3 R6_2.5.1
[101] IRanges_2.32.0 generics_0.1.3
[103] DelayedArray_0.24.0 pillar_1.9.0
[105] withr_3.0.0 fitdistrplus_1.1-11
[107] RCurl_1.98-1.14 survival_3.5-7
[109] abind_1.4-5 tibble_3.2.1
[111] future.apply_1.11.1 crayon_1.5.2
[113] KernSmooth_2.23-22 utf8_1.2.4
[115] spatstat.geom_3.2-7 plotly_4.10.4
[117] grid_4.2.3 data.table_1.14.10
[119] digest_0.6.34 xtable_1.8-4
[121] tidyr_1.3.0 httpuv_1.6.13
[123] R.utils_2.12.3 stats4_4.2.3
[125] munsell_0.5.0 viridisLite_0.4.2