satijalab / seurat

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

missing value where TRUE/FALSE needed in IntegrateLayers() #9330

Open katkatrach opened 2 months ago

katkatrach commented 2 months ago

Hello! I am trying to run a Seurat pipeline that previously worked on an older version of R in the latest version and I am running into a weird error.

I run the following to integrate my layers after SCTransform and PCA: All_Samples <- IntegrateLayers( object = All_Samples, method = CCAIntegration, normalization.method = "SCT", verbose = F)

I am met with the error (and a warning) after a certain number of minutes after starting the integration:

Warning in irlba(A = mat3, nv = num.cc) :
  did not converge--results might be invalid!; try increasing work or maxit
Error in if (sign(x[1]) == -1) { : missing value where TRUE/FALSE needed

For the maxit, I am able to increase it on the previous step PCA (I get that warning there too) but it is not a condition for the IntegrateLayers function.

Runningwhich([is.na](http://is.na/)(rownames(All_Samples)) shows no NA values

I performed my pipeline with a small data set and the error does not occur.

InstallData("ifnb")

ifnb <- LoadData("ifnb")

ifnb[["RNA"]] <- split(ifnb[["RNA"]], f = ifnb$stim)

ifnb[["percent.mt"]] <- PercentageFeatureSet(ifnb,pattern="^MT-")

ifnb[["percent.er"]] <- PercentageFeatureSet(ifnb,pattern="^RP[SL][[:digit:]]")

ifnb <- subset(ifnb, subset=nFeature_RNA > 400 & nFeature_RNA < 5000)

ifnb <- subset(ifnb, subset=percent.mt < 30 &percent.er <15)

dim(ifnb)

ifnb[["RNA"]] <- JoinLayers(ifnb[["RNA"]])

countMatrix <- GetAssayData(object = ifnb, slot = "counts")

ifnb.gmcf <- gene.vs.molecule.cell.filter(countMatrix,min.cell.size=200)

ifnb <- subset(ifnb, cells = colnames(ifnb.gmcf))

ifnb[["RNA"]] <- split(ifnb[["RNA"]], f = ifnb$orig.ident)

ifnb <- SCTransform(ifnb, vst.flavor = "v2")

ifnb <- RunPCA(object = ifnb, features = VariableFeatures(object = ifnb), maxit=1000000)

ifnb <- IntegrateLayers(
  object = ifnb, method = CCAIntegration, normalization.method = "SCT", verbose = F, k.weight=30)

This makes me think it's an issue with my docker or session, any help is appreciated!

session info:

R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
[1] C

time zone: America/Chicago
tzcode source: system (glibc)

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

other attached packages:
 [1] ifnb.SeuratData_3.1.0 knitr_1.48            sctransform_0.4.1     glmGamPoi_1.14.3      pagoda2_1.0.12        igraph_2.0.3          Matrix_1.7-0         
 [8] pdfCluster_1.0-4      patchwork_1.2.0       ggplot2_3.5.1         dplyr_1.1.4           SeuratDisk_0.0.0.9021 Seurat_5.1.0          SeuratObject_5.0.2   
[15] sp_2.1-4              SeuratData_0.2.2.9001

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22            splines_4.4.0               later_1.3.2                 urltools_1.7.3              tibble_3.2.1                R.oo_1.26.0                
  [7] triebeard_0.4.1             polyclip_1.10-7             fastDummies_1.7.3           lifecycle_1.0.4             globals_0.16.3              lattice_0.22-6             
 [13] hdf5r_1.3.11                MASS_7.3-61                 magrittr_2.0.3              plotly_4.10.4               httpuv_1.6.15               spam_2.10-0                
 [19] spatstat.sparse_3.1-0       reticulate_1.38.0           cowplot_1.1.3               pbapply_1.7-2               RColorBrewer_1.1-3          abind_1.4-5                
 [25] zlibbioc_1.50.0             Rtsne_0.17                  GenomicRanges_1.56.1        purrr_1.0.2                 R.utils_2.12.3              BiocGenerics_0.50.0        
 [31] rappdirs_0.3.3              GenomeInfoDbData_1.2.12     IRanges_2.38.1              S4Vectors_0.42.1            ggrepel_0.9.5               RMTstat_0.3.1              
 [37] irlba_2.3.5.1               listenv_0.9.1               spatstat.utils_3.0-5        goftest_1.2-3               RSpectra_0.16-2             spatstat.random_3.3-1      
 [43] brew_1.0-10                 fitdistrplus_1.2-1          parallelly_1.37.1           DelayedMatrixStats_1.26.0   leiden_0.4.3.1              codetools_0.2-20           
 [49] DelayedArray_0.30.1         tidyselect_1.2.1            UCSC.utils_1.0.0            matrixStats_1.3.0           stats4_4.4.0                spatstat.explore_3.3-1     
 [55] jsonlite_1.8.8              Rook_1.2                    progressr_0.14.0            ggridges_0.5.6              survival_3.7-0              tools_4.4.0                
 [61] ica_1.0-3                   Rcpp_1.0.13                 glue_1.7.0                  gridExtra_2.3               SparseArray_1.4.8           xfun_0.46                  
 [67] mgcv_1.9-1                  MatrixGenerics_1.16.0       GenomeInfoDb_1.40.1         withr_3.0.0                 fastmap_1.2.0               fansi_1.0.6                
 [73] digest_0.6.36               R6_2.5.1                    mime_0.12                   colorspace_2.1-0            scattermore_1.2             N2R_1.0.3                  
 [79] sccore_1.0.5                tensor_1.5                  spatstat.data_3.1-2         R.methodsS3_1.8.2           utf8_1.2.4                  tidyr_1.3.1                
 [85] generics_0.1.3              data.table_1.15.4           httr_1.4.7                  htmlwidgets_1.6.4           S4Arrays_1.4.1              uwot_0.2.2                 
 [91] pkgconfig_2.0.3             gtable_0.3.5                lmtest_0.9-40               XVector_0.44.0              htmltools_0.5.8.1           dotCall64_1.1-1            
 [97] scales_1.3.0                Biobase_2.64.0              dendsort_0.3.4              png_0.1-8                   spatstat.univar_3.0-0       geometry_0.5.0             
[103] rstudioapi_0.16.0           reshape2_1.4.4              rjson_0.2.21                nlme_3.1-165                magic_1.6-1                 zoo_1.8-12                 
[109] stringr_1.5.1               KernSmooth_2.23-24          drat_0.2.4                  parallel_4.4.0              miniUI_0.1.1.1              pillar_1.9.0               
[115] grid_4.4.0                  vctrs_0.6.5                 RANN_2.6.1                  promises_1.3.0              xtable_1.8-4                cluster_2.1.6              
[121] cli_3.6.3                   compiler_4.4.0              rlang_1.1.4                 crayon_1.5.3                future.apply_1.11.2         plyr_1.8.9                 
[127] stringi_1.8.4               viridisLite_0.4.2           deldir_2.0-4                munsell_0.5.1               lazyeval_0.2.2              spatstat.geom_3.3-2        
[133] RcppHNSW_0.6.0              sparseMatrixStats_1.16.0    bit64_4.0.5                 future_1.33.2               shiny_1.8.1.1               SummarizedExperiment_1.34.0
[139] ROCR_1.0-11                 bit_4.0.5
longmanz commented 1 month ago

Hi, It likely that some "NaN" or "NA" are generated during the integration process. It is not clear why since using "ifnb" data cannot reproduce this issue. Would you be able to share your dataset with us? Alternatively, you may consider using other integration methods like "RPCA" or "Harmony" as a workaround.