ge11232002 / TFBSTools

Software Package for Transcription Factor Binding Site (TFBS) Analysis
25 stars 10 forks source link

TFBSTools breaks colSums and rowSums: Error in .local(x, na.rm, dims, ...) : object 'CRsparse_colSums' not found #37

Closed Gesmira closed 11 months ago

Gesmira commented 11 months ago

Hi, My name is Gesi and I'm a developer of the Seurat and Azimuth packages. We have recently noticed this bug reported in various issues across Seurat, Azimuth, and Signac. It seems that there is a specific TFBSTools implementation of colSums and rowSums that overwrites any other version even if you do not attach the package. The Matrix package used to have 'CRsparse_colSums' and 'CRsparse_rowSums' as internal functions but they have since been removed. It seems like the TFBSTools versions of colSums and rowSums are trying to call those.

Reproducible example shown with SeuratData object, but this has been reproduced with any dgCMatrix:

library(Seurat)
library(SeuratData)
pbmc3k <- LoadData("pbmc3k")
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(TFBSTools::colSums(pbmc3k[["RNA"]]$counts))
Error in .local(x, na.rm, dims, ...) : 
  object 'CRsparse_colSums' not found
> head(colSums(pbmc3k[["RNA"]]$counts))
Error in .local(x, na.rm, dims, ...) : 
  object 'CRsparse_colSums' not found
> head(Matrix::colSums(pbmc3k[["RNA"]]$counts))
Error in .local(x, na.rm, dims, ...) : 
  object 'CRsparse_colSums' not found

Once the TFBSTools version is run, it breaks any other attempts at colSums(). This causes many functions to break across Seurat, Azimuth, and Signac if the Azimuth or Signac packages are loaded in as they import/suggest TFBSTools.

Any advice or attempt at a bug fix to be up to date with the recent Matrix version would be greatly appreciated! Thank you!

ge11232002 commented 11 months ago

Hi, can you provide the sessionInfo()? I am able to reproduce the error from my side.

> library(Seurat)
Loading required package: SeuratObject
Loading required package: sp
‘SeuratObject’ was built with package ‘Matrix’ 1.6.3 but the current version is 1.6.4; it is recomended that you reinstall ‘SeuratObject’ as the ABI for ‘Matrix’ may
have changed

Attaching package: ‘SeuratObject’

The following object is masked from ‘package:base’:

    intersect

> library(SeuratData)
── Installed datasets ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── SeuratData v0.2.2.9001 ──
✔ pbmc3k 3.1.4                                                                                

──────────────────────────────────────────────────────────────────────────────────────────── Key ───────────────────────────────────────────────────────────────────────────────────────────
✔ Dataset loaded successfully
❯ Dataset built with a newer version of Seurat than installed
❓ Unknown version of Seurat installed

> pbmc3k <- LoadData("pbmc3k")
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Warning: Assay RNA changing from Assay to Assay
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Validating object structure for Assay ‘RNA’
Object representation is consistent with the most current Seurat version
Warning: Assay RNA changing from Assay to Assay5
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(TFBSTools::colSums(pbmc3k[["RNA"]]$counts))

AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(Matrix::colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1.2

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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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

time zone: Europe/Zurich
tzcode source: internal

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

other attached packages:
[1] pbmc3k.SeuratData_3.1.4 SeuratData_0.2.2.9001   Seurat_5.0.1            SeuratObject_5.0.1      sp_2.1-2               

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21            splines_4.3.1               later_1.3.1                 BiocIO_1.12.0               bitops_1.0-7                R.oo_1.25.0                
  [7] tibble_3.2.1                polyclip_1.10-6             XML_3.99-0.16               DirichletMultinomial_1.44.0 fastDummies_1.7.3           lifecycle_1.0.4            
 [13] globals_0.16.2              lattice_0.22-5              MASS_7.3-60                 magrittr_2.0.3              plotly_4.10.3               yaml_2.3.7                 
 [19] httpuv_1.6.12               sctransform_0.4.1           spam_2.10-0                 spatstat.sparse_3.0-3       reticulate_1.34.0           cowplot_1.1.1              
 [25] pbapply_1.7-2               DBI_1.1.3                   CNEr_1.38.0                 RColorBrewer_1.1-3          abind_1.4-5                 zlibbioc_1.48.0            
 [31] Rtsne_0.16                  GenomicRanges_1.54.1        R.utils_2.12.3              purrr_1.0.2                 BiocGenerics_0.48.1         RCurl_1.98-1.13            
 [37] pracma_2.4.4                rappdirs_0.3.3              GenomeInfoDbData_1.2.11     IRanges_2.36.0              S4Vectors_0.40.2            ggrepel_0.9.4              
 [43] irlba_2.3.5.1               listenv_0.9.0               spatstat.utils_3.0-4        seqLogo_1.68.0              goftest_1.2-3               RSpectra_0.16-1            
 [49] annotate_1.80.0             spatstat.random_3.2-2       fitdistrplus_1.1-11         parallelly_1.36.0           leiden_0.4.3.1              codetools_0.2-19           
 [55] DelayedArray_0.28.0         tidyselect_1.2.0            matrixStats_1.1.0           stats4_4.3.1                spatstat.explore_3.2-5      GenomicAlignments_1.38.0   
 [61] jsonlite_1.8.7              ellipsis_0.3.2              progressr_0.14.0            ggridges_0.5.4              survival_3.5-7              tools_4.3.1                
 [67] TFMPvalue_0.0.9             ica_1.0-3                   Rcpp_1.0.11                 glue_1.6.2                  gridExtra_2.3               SparseArray_1.2.2          
 [73] MatrixGenerics_1.14.0       GenomeInfoDb_1.38.1         dplyr_1.1.4                 BiocManager_1.30.22         fastmap_1.1.1               fansi_1.0.5                
 [79] caTools_1.18.2              digest_0.6.33               R6_2.5.1                    mime_0.12                   colorspace_2.1-0            GO.db_3.18.0               
 [85] scattermore_1.2             poweRlaw_0.70.6             gtools_3.9.5                tensor_1.5                  spatstat.data_3.0-3         RSQLite_2.3.3              
 [91] R.methodsS3_1.8.2           utf8_1.2.4                  tidyr_1.3.0                 generics_0.1.3              data.table_1.14.8           rtracklayer_1.62.0         
 [97] httr_1.4.7                  htmlwidgets_1.6.3           S4Arrays_1.2.0              TFBSTools_1.40.0            uwot_0.1.16                 pkgconfig_2.0.3            
[103] gtable_0.3.4                blob_1.2.4                  lmtest_0.9-40               XVector_0.42.0              htmltools_0.5.7             dotCall64_1.1-1            
[109] scales_1.3.0                Biobase_2.62.0              png_0.1-8                   rstudioapi_0.15.0           tzdb_0.4.0                  reshape2_1.4.4             
[115] rjson_0.2.21                nlme_3.1-164                zoo_1.8-12                  cachem_1.0.8                stringr_1.5.1               KernSmooth_2.23-22         
[121] parallel_4.3.1              miniUI_0.1.1.1              AnnotationDbi_1.64.1        restfulr_0.0.15             pillar_1.9.0                grid_4.3.1                 
[127] vctrs_0.6.5                 RANN_2.6.1                  promises_1.2.1              xtable_1.8-4                cluster_2.1.6               readr_2.1.4                
[133] cli_3.6.1                   compiler_4.3.1              Rsamtools_2.18.0            rlang_1.1.2                 crayon_1.5.2                future.apply_1.11.0        
[139] plyr_1.8.9                  stringi_1.8.2               viridisLite_0.4.2           deldir_2.0-2                BiocParallel_1.36.0         munsell_0.5.0              
[145] Biostrings_2.70.1           lazyeval_0.2.2              spatstat.geom_3.2-7         Matrix_1.6-4                BSgenome_1.70.1             RcppHNSW_0.5.0             
[151] hms_1.1.3                   patchwork_1.1.3             bit64_4.0.5                 future_1.33.0               ggplot2_3.4.4               KEGGREST_1.42.0            
[157] shiny_1.8.0                 SummarizedExperiment_1.32.0 ROCR_1.0-11                 igraph_1.5.1                memoise_2.0.1               bit_4.0.5      
Gesmira commented 11 months ago

Hi, Thanks for your response! I'm attaching my sessionInfo() below. I have found that I can't reproduce the issue if I have Matrix 1.6-1.1 installed, but it seems that we both have the most up to date Matrix version. In the meantime, I will also try to see if there are other specific differences. The sessions of other users are also included in some of the issues I tagged in the post above, where users experience the same problem.

> library(TFBSTools)

Attaching package: ‘TFBSTools’

The following object is masked from ‘package:Matrix’:

    Matrix

> head(colSums(pbmc3k[["RNA"]]$counts))
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'head': object 'CRsparse_colSums' not found

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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       

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

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

other attached packages:
 [1] TFBSTools_1.40.0                tonsilref.SeuratData_1.0.0     
 [3] pbmcsca.SeuratData_3.0.0        pbmcref.SeuratData_1.0.0       
 [5] pbmc3k.SeuratData_3.1.4         panc8.SeuratData_3.0.2         
 [7] mousecortexref.SeuratData_1.0.0 lungref.SeuratData_2.0.0       
 [9] ifnb.SeuratData_3.1.0           heartref.SeuratData_1.0.0      
[11] bonemarrowref.SeuratData_1.0.0  SeuratData_0.2.2.9001          
[13] Seurat_5.0.1                    SeuratObject_5.0.1             
[15] sp_2.1-2                        Matrix_1.6-4                   

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21            splines_4.3.2              
  [3] later_1.3.1                 BiocIO_1.12.0              
  [5] bitops_1.0-7                R.oo_1.25.0                
  [7] tibble_3.2.1                polyclip_1.10-6            
  [9] XML_3.99-0.16               DirichletMultinomial_1.44.0
 [11] fastDummies_1.7.3           lifecycle_1.0.4            
 [13] globals_0.16.2              lattice_0.21-8             
 [15] MASS_7.3-60                 magrittr_2.0.3             
 [17] plotly_4.10.3               yaml_2.3.7                 
 [19] httpuv_1.6.12               sctransform_0.4.1          
 [21] spam_2.10-0                 spatstat.sparse_3.0-3      
 [23] reticulate_1.34.0           cowplot_1.1.1              
 [25] pbapply_1.7-2               DBI_1.1.3                  
 [27] CNEr_1.38.0                 RColorBrewer_1.1-3         
 [29] abind_1.4-5                 zlibbioc_1.48.0            
 [31] Rtsne_0.16                  GenomicRanges_1.54.1       
 [33] R.utils_2.12.2              purrr_1.0.2                
 [35] BiocGenerics_0.48.1         RCurl_1.98-1.13            
 [37] pracma_2.4.4                rappdirs_0.3.3             
 [39] GenomeInfoDbData_1.2.11     IRanges_2.36.0             
 [41] S4Vectors_0.40.1            ggrepel_0.9.4              
 [43] irlba_2.3.5.1               listenv_0.9.0              
 [45] spatstat.utils_3.0-4        seqLogo_1.68.0             
 [47] goftest_1.2-3               RSpectra_0.16-1            
 [49] annotate_1.80.0             spatstat.random_3.2-2      
 [51] fitdistrplus_1.1-11         parallelly_1.36.0          
 [53] leiden_0.4.3                codetools_0.2-19           
 [55] DelayedArray_0.28.0         tidyselect_1.2.0           
 [57] matrixStats_1.1.0           stats4_4.3.2               
 [59] spatstat.explore_3.2-5      GenomicAlignments_1.38.0   
 [61] jsonlite_1.8.7              ellipsis_0.3.2             
 [63] progressr_0.14.0            ggridges_0.5.4             
 [65] survival_3.5-7              tools_4.3.2                
 [67] TFMPvalue_0.0.9             ica_1.0-3                  
 [69] Rcpp_1.0.11                 glue_1.6.2                 
 [71] gridExtra_2.3               SparseArray_1.2.2          
 [73] MatrixGenerics_1.14.0       GenomeInfoDb_1.38.1        
 [75] dplyr_1.1.4                 fastmap_1.1.1              
 [77] fansi_1.0.5                 caTools_1.18.2             
 [79] digest_0.6.33               R6_2.5.1                   
 [81] mime_0.12                   colorspace_2.1-0           
 [83] GO.db_3.18.0                scattermore_1.2            
 [85] poweRlaw_0.70.6             gtools_3.9.4               
 [87] tensor_1.5                  spatstat.data_3.0-3        
 [89] RSQLite_2.3.3               R.methodsS3_1.8.2          
 [91] utf8_1.2.4                  tidyr_1.3.0                
 [93] generics_0.1.3              data.table_1.14.8          
 [95] rtracklayer_1.62.0          httr_1.4.7                 
 [97] htmlwidgets_1.6.3           S4Arrays_1.2.0             
 [99] uwot_0.1.16                 pkgconfig_2.0.3            
[101] gtable_0.3.4                blob_1.2.4                 
[103] lmtest_0.9-40               XVector_0.42.0             
[105] htmltools_0.5.7             dotCall64_1.1-1            
[107] scales_1.2.1                Biobase_2.62.0             
[109] png_0.1-8                   tzdb_0.4.0                 
[111] rjson_0.2.21                reshape2_1.4.4             
[113] nlme_3.1-163                zoo_1.8-12                 
[115] cachem_1.0.8                stringr_1.5.1              
[117] KernSmooth_2.23-22          parallel_4.3.2             
[119] miniUI_0.1.1.1              AnnotationDbi_1.64.1       
[121] restfulr_0.0.15             pillar_1.9.0               
[123] grid_4.3.2                  vctrs_0.6.4                
[125] RANN_2.6.1                  promises_1.2.1             
[127] xtable_1.8-4                cluster_2.1.5              
[129] readr_2.1.4                 Rsamtools_2.18.0           
[131] cli_3.6.1                   compiler_4.3.2             
[133] rlang_1.1.2                 crayon_1.5.2               
[135] future.apply_1.11.0         plyr_1.8.9                 
[137] stringi_1.8.2               viridisLite_0.4.2          
[139] deldir_2.0-2                BiocParallel_1.36.0        
[141] munsell_0.5.0               Biostrings_2.70.1          
[143] lazyeval_0.2.2              spatstat.geom_3.2-7        
[145] BSgenome_1.70.1             RcppHNSW_0.5.0             
[147] hms_1.1.3                   patchwork_1.1.3            
[149] bit64_4.0.5                 future_1.33.0              
[151] ggplot2_3.4.4               KEGGREST_1.42.0            
[153] shiny_1.8.0                 SummarizedExperiment_1.32.0
[155] ROCR_1.0-11                 igraph_1.5.1               
[157] memoise_2.0.1               bit_4.0.5      
ehoreth commented 11 months ago

I am adding this here because I am having a similar issue that I think stems from the same underlying problem.

When trying to run FindMarkers() on scATAC-seq data with Seurat/Signac I get this error:

Warning: When testing Myo versus all: "CRsparse_rowSums" not resolved from current namespace (Matrix)

sessionInfo()

R version 4.3.1 (2023-06-16) Platform: x86_64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.0

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.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

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

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] motifmatchr_1.22.0 Matrix_1.6-4
[3] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome_1.68.0
[5] rtracklayer_1.60.1 Biostrings_2.68.1
[7] XVector_0.40.0 EnsDb.Hsapiens.v86_2.99.0
[9] ensembldb_2.24.1 AnnotationFilter_1.24.0
[11] GenomicFeatures_1.52.2 AnnotationDbi_1.62.2
[13] Biobase_2.60.0 GenomicRanges_1.52.0
[15] GenomeInfoDb_1.36.4 IRanges_2.34.1
[17] S4Vectors_0.38.2 BiocGenerics_0.46.0
[19] Signac_1.12.0 ggrepel_0.9.4
[21] patchwork_1.1.3 RColorBrewer_1.1-3
[23] clustree_0.5.1 ggraph_2.1.0
[25] ggplot2_3.4.4 Seurat_5.0.1
[27] SeuratObject_5.0.1 sp_2.1-2
[29] viridis_0.6.4 viridisLite_0.4.2
[31] JASPAR2020_0.99.10 TFBSTools_1.38.0

loaded via a namespace (and not attached): [1] ProtGenerics_1.32.0 matrixStats_1.1.0 spatstat.sparse_3.0-3
[4] bitops_1.0-7 DirichletMultinomial_1.42.0 httr_1.4.7
[7] tools_4.3.1 sctransform_0.4.1 utf8_1.2.4
[10] R6_2.5.1 lazyeval_0.2.2 uwot_0.1.16
[13] withr_2.5.2 prettyunits_1.2.0 gridExtra_2.3
[16] progressr_0.14.0 cli_3.6.1 spatstat.explore_3.2-5
[19] fastDummies_1.7.3 spatstat.data_3.0-3 readr_2.1.4
[22] ggridges_0.5.4 pbapply_1.7-2 Rsamtools_2.16.0
[25] R.utils_2.12.3 parallelly_1.36.0 rstudioapi_0.15.0
[28] RSQLite_2.3.3 generics_0.1.3 BiocIO_1.10.0
[31] gtools_3.9.5 ica_1.0-3 spatstat.random_3.2-2
[34] dplyr_1.1.4 GO.db_3.17.0 fansi_1.0.5
[37] abind_1.4-5 R.methodsS3_1.8.2 lifecycle_1.0.4
[40] yaml_2.3.7 SummarizedExperiment_1.30.2 BiocFileCache_2.8.0
[43] Rtsne_0.16 grid_4.3.1 blob_1.2.4
[46] promises_1.2.1 crayon_1.5.2 miniUI_0.1.1.1
[49] lattice_0.22-5 cowplot_1.1.1 annotate_1.78.0
[52] KEGGREST_1.40.1 pillar_1.9.0 rjson_0.2.21
[55] future.apply_1.11.0 codetools_0.2-19 fastmatch_1.1-4
[58] leiden_0.4.3.1 glue_1.6.2 data.table_1.14.8
[61] vctrs_0.6.5 png_0.1-8 spam_2.10-0
[64] gtable_0.3.4 poweRlaw_0.70.6 cachem_1.0.8
[67] S4Arrays_1.0.6 mime_0.12 tidygraph_1.2.3
[70] pracma_2.4.4 survival_3.5-7 RcppRoll_0.3.0
[73] ellipsis_0.3.2 fitdistrplus_1.1-11 ROCR_1.0-11
[76] nlme_3.1-164 bit64_4.0.5 progress_1.2.2
[79] filelock_1.0.2 RcppAnnoy_0.0.21 irlba_2.3.5.1
[82] KernSmooth_2.23-22 colorspace_2.1-0 seqLogo_1.66.0
[85] DBI_1.1.3 tidyselect_1.2.0 bit_4.0.5
[88] compiler_4.3.1 curl_5.1.0 xml2_1.3.6
[91] DelayedArray_0.26.7 plotly_4.10.3 scales_1.3.0
[94] caTools_1.18.2 lmtest_0.9-40 rappdirs_0.3.3
[97] stringr_1.5.1 digest_0.6.33 goftest_1.2-3
[100] spatstat.utils_3.0-4 htmltools_0.5.7 pkgconfig_2.0.3
[103] MatrixGenerics_1.12.3 dbplyr_2.4.0 fastmap_1.1.1
[106] rlang_1.1.2 htmlwidgets_1.6.3 shiny_1.8.0
[109] farver_2.1.1 zoo_1.8-12 jsonlite_1.8.8
[112] BiocParallel_1.34.2 R.oo_1.25.0 RCurl_1.98-1.13
[115] magrittr_2.0.3 GenomeInfoDbData_1.2.10 dotCall64_1.1-1
[118] munsell_0.5.0 Rcpp_1.0.11 reticulate_1.34.0
[121] stringi_1.8.2 zlibbioc_1.46.0 MASS_7.3-60
[124] plyr_1.8.9 parallel_4.3.1 listenv_0.9.0
[127] deldir_2.0-2 CNEr_1.36.0 graphlayouts_1.0.2
[130] splines_4.3.1 tensor_1.5 hms_1.1.3
[133] igraph_1.5.1 spatstat.geom_3.2-7 RcppHNSW_0.5.0
[136] reshape2_1.4.4 biomaRt_2.56.1 TFMPvalue_0.0.9
[139] XML_3.99-0.16 tzdb_0.4.0 tweenr_2.0.2
[142] httpuv_1.6.12 RANN_2.6.1 tidyr_1.3.0
[145] purrr_1.0.2 polyclip_1.10-6 future_1.33.0
[148] scattermore_1.2 ggforce_0.4.1 xtable_1.8-4
[151] restfulr_0.0.15 RSpectra_0.16-1 later_1.3.1
[154] tibble_3.2.1 memoise_2.0.1 GenomicAlignments_1.36.0
[157] cluster_2.1.6 globals_0.16.2

NaviedA commented 11 months ago

Please fix - this is breaking the use of Signac package.

ge11232002 commented 11 months ago

I don't see anything to fix on my side. Cannot reproduce it on alternative Linux cluster as well.

> library(Seurat)
Loading required package: SeuratObject
Loading required package: sp

Attaching package: ‘SeuratObject’

The following object is masked from ‘package:base’:

    intersect

> library(SeuratData)
> pbmc3k <- LoadData("pbmc3k")
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Warning: Assay RNA changing from Assay to Assay
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Validating object structure for Assay ‘RNA’
Object representation is consistent with the most current Seurat version
Warning: Assay RNA changing from Assay to Assay5
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(Matrix::colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: FlexiBLAS OPENBLAS;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        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               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Zurich
tzcode source: system (glibc)

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

other attached packages:
[1] Seurat_5.0.0            SeuratObject_5.0.0      sp_2.1-1                pbmc3k.SeuratData_3.1.4 SeuratData_0.2.2.9001  

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.15.0      jsonlite_1.8.7         magrittr_2.0.3         spatstat.utils_3.0-4   fs_1.6.3               vctrs_0.6.4           
  [8] ROCR_1.0-11            memoise_2.0.1          spatstat.explore_3.2-5 htmltools_0.5.7        usethis_2.2.2          curl_5.1.0             sctransform_0.4.1     
 [15] parallelly_1.36.0      KernSmooth_2.23-22     htmlwidgets_1.6.2      desc_1.4.2             ica_1.0-3              plyr_1.8.9             plotly_4.10.3         
 [22] zoo_1.8-12             cachem_1.0.8           igraph_1.5.1           mime_0.12              lifecycle_1.0.4        pkgconfig_2.0.3        Matrix_1.6-3          
 [29] R6_2.5.1               fastmap_1.1.1          fitdistrplus_1.1-11    future_1.33.0          shiny_1.7.5.1          digest_0.6.33          colorspace_2.1-0      
 [36] patchwork_1.1.3        ps_1.7.5               rprojroot_2.0.4        tensor_1.5             RSpectra_0.16-1        irlba_2.3.5.1          pkgload_1.3.3         
 [43] progressr_0.14.0       fansi_1.0.5            spatstat.sparse_3.0-3  httr_1.4.7             polyclip_1.10-6        abind_1.4-5            compiler_4.3.2        
 [50] remotes_2.4.2.1        fastDummies_1.7.3      pkgbuild_1.4.2         MASS_7.3-60            rappdirs_0.3.3         sessioninfo_1.2.2      tools_4.3.2           
 [57] lmtest_0.9-40          httpuv_1.6.12          future.apply_1.11.0    goftest_1.2-3          glue_1.6.2             callr_3.7.3            nlme_3.1-163          
 [64] promises_1.2.1         grid_4.3.2             Rtsne_0.16             cluster_2.1.4          reshape2_1.4.4         generics_0.1.3         gtable_0.3.4          
 [71] spatstat.data_3.0-3    tidyr_1.3.0            data.table_1.14.8      utf8_1.2.4             spatstat.geom_3.2-7    RcppAnnoy_0.0.21       ggrepel_0.9.4         
 [78] RANN_2.6.1             pillar_1.9.0           stringr_1.5.1          spam_2.10-0            RcppHNSW_0.5.0         later_1.3.1            splines_4.3.2         
 [85] dplyr_1.1.3            lattice_0.22-5         renv_1.0.3             survival_3.5-7         deldir_1.0-9           tidyselect_1.2.0       miniUI_0.1.1.1        
 [92] pbapply_1.7-2          gridExtra_2.3          scattermore_1.2        devtools_2.4.5         matrixStats_1.1.0      stringi_1.8.1          lazyeval_0.2.2        
 [99] codetools_0.2-19       tibble_3.2.1           cli_3.6.1              uwot_0.1.16            xtable_1.8-4           reticulate_1.34.0      munsell_0.5.0         
[106] processx_3.8.2         Rcpp_1.0.11            globals_0.16.2         spatstat.random_3.2-1  png_0.1-8              parallel_4.3.2         ellipsis_0.3.2        
[113] ggplot2_3.4.4          prettyunits_1.2.0      dotCall64_1.1-0        profvis_0.3.8          urlchecker_1.0.1       listenv_0.9.0          viridisLite_0.4.2     
[120] scales_1.2.1           ggridges_0.5.4         leiden_0.4.3.1         purrr_1.0.2            crayon_1.5.2           rlang_1.1.2            cowplot_1.1.1
ehoreth commented 11 months ago

Could you try to see if you can get an error when running with scATAC-seq data? I am not running into an issue with Matrix when running scRNA-seq data, only when I am trying to identify enriched motifs from scATAC-seq

Motif Analysis

Get a list of motif position frequency matrices from the JASPAR database

pfm <- getMatrixSet( x = JASPAR2020, opts = list(collection = "CORE", tax_group = 'vertebrates', all_versions = FALSE) )

add motif information

multi.sobj <- AddMotifs( object = multi.sobj, genome = BSgenome.Hsapiens.UCSC.hg38, pfm = pfm )

saveRDS(multi.sobj, "../input_files/huSMG_multiomeRNA-seq&ATAC-seq_processed_signac_with_motif_data_120523.rds") multi.sobj <- readRDS("../input_files/huSMG_multiomeRNA-seq&ATAC-seq_processed_signac_with_motif_data_120523.rds")

DefaultAssay(multi.sobj) <- "peaks"

da_peaks <- FindMarkers( object = multi.sobj, ident.1 = 'Myoepithelial', only.pos = TRUE, test.use = 'LR', min.pct = 0.05, latent.vars = 'nCount_peaks' )

Gesmira commented 11 months ago

Hi @ge11232002 , Just to confirm, you also don't get the error on this alternative cluster when you use TFBSTools? I see in the example you attached, you don't run the TFBSTools::colSums, which is the line that causes the break. You also don't seem to have TFBSTools as an installed package.

> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(Matrix::colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 

We're still working on looking into this on our end as well, but we have not found anything else that causes the issue except for the TFBSTools loading.

Gesmira commented 11 months ago

@ehoreth What is the error that you get?

ehoreth commented 11 months ago

Hello Gesmira,

The error code was this: Error in .Call("CRsparse_rowSums", x, na.rm, FALSE, sparseResult) : "CRsparse_rowSums" not resolved from current namespace (Matrix)

However, I reinstalled the TFBSTools just now and it is working now. So I am no longer having the issue.

ge11232002 commented 11 months ago
head(Matrix::colSums(pbmc3k[["RNA"]]$counts))

Forgot to include the TFBSTools::colSums. It works fine on a Linux cluster.

> library(Seurat)
> library(SeuratData)
> pbmc3k <- LoadData("pbmc3k")
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Warning: Assay RNA changing from Assay to Assay
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Validating object structure for Assay ‘RNA’
Object representation is consistent with the most current Seurat version
Warning: Assay RNA changing from Assay to Assay5
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(TFBSTools::colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 
> head(Matrix::colSums(pbmc3k[["RNA"]]$counts))
AAACATACAACCAC AAACATTGAGCTAC AAACATTGATCAGC AAACCGTGCTTCCG AAACCGTGTATGCG AAACGCACTGGTAC 
          2419           4903           3147           2639            980           2163 

S4 method colSums is extended to work for a object defined in TFBSTools. I don't see how it can disrupt the execution of colSums.

Gesmira commented 11 months ago

Hi @ge11232002, Thanks for all your info! After comparing multiple sessions that both had and did not have this issue related to TFBSTools, we realized updating all Bioconductor packages fixed the issue. We have detailed the solution here if it's useful to anyone else that stumbles on this issue: https://github.com/satijalab/seurat/issues/8089#issuecomment-1847816493

NaviedA commented 10 months ago

Actual solution here: https://github.com/satijalab/seurat/issues/8202#issue-2047511055