8000 Error in t.default(enrichment) : argument is not a matrix · Issue #152 · BorchLab/escape · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Error in t.default(enrichment) : argument is not a matrix #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

8000

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AhmedAbd5 opened this issue May 23, 2025 · 3 comments
Closed

Error in t.default(enrichment) : argument is not a matrix #152

AhmedAbd5 opened this issue May 23, 2025 · 3 comments
Assignees

Comments

@AhmedAbd5
Copy link

Hello,

Thanks for a great package! I am trying to normalize using performNormalization but I'm getting the following error:

Seu_escape <- performNormalization(Seu_escape, 
                                      assay = "escape.ssGSEA", 
                                      gene.sets = geneSets)
Computing expressed-gene counts per cell...
Normalizing enrichment scores...
Error in t.default(enrichment) : argument is not a matrix

My input is seurat object, SCT normalized. I'm using a custom gene set.

My full code is below:

Merged_Seurat <- readRDS("./Merged_Seurat.rds")

#load custom geneset
X3datasets <- read.delim("./CustomGeneSet.txt")
GS1<- X3datasets$GeneSet1
GS2<- X3datasets$GeneSet2
GS3<- X3datasets$GeneSet3

#transform them into the GeneSet format
gs1  <- GeneSet(GS1)
gs2  <- GeneSet(GS2)
gs3  <- GeneSet(GS3)

geneSets <- list(geneSet1=gs1, geneSet2=gs2, geneSet3=gs3)
geneSets <- GeneSetCollection(geneSets)


Seu_escape <- runEscape(Merged_Seurat, gene.sets = geneSets, groups = 5000, min.size = 3,
                           new.assay.name = "escape.ssGSEA")

Seu_escape <- performNormalization(Seu_escape, 
                                      assay = "escape.ssGSEA", 
                                      gene.sets = geneSets)

I tried to look at the sturcture of the input and here it is:

> enrichment_scores <- GetAssayData(Seu_escape, assay = "escape.ssGSEA")
> str(enrichment_scores)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:433491] 0 1 2 0 1 2 0 1 2 0 ...
  ..@ p       : int [1:144498] 0 3 6 9 12 15 18 21 24 27 ...
  ..@ Dim     : int [1:2] 3 144497
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:3] "geneSet1" "geneSet2" "geneSet3"
  .. ..$ : chr [1:144497] "XXXX_AAACCCAAGCACCTGC-1" "XXXX_AAACGAAAGATGCGAC-1" "XXXX_AAACGAAAGTCAATCC-1" "XXXX_AAACGAACACAACCGC-1" ...
  ..@ x       : num [1:433491] 5405 7396 7417 5506 7623 ...
  ..@ factors : list()

Session info below:

> sessionInfo()
R version 4.3.3 (2024-02-29)
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;  LAPACK version 3.8.0

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: America/Los_Angeles
tzcode source: system (glibc)

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

other attached packages:
 [1] MAST_1.28.0                 gridExtra_2.3               dittoSeq_1.14.3            
 [4] lubridate_1.9.4             forcats_1.0.0               stringr_1.5.1              
 [7] purrr_1.0.4                 readr_2.1.5                 tidyverse_2.0.0            
[10] AUCell_1.24.0               escape_2.5.0                GSEABase_1.64.0            
[13] graph_1.80.0                annotate_1.80.0             XML_3.99-0.18              
[16] AnnotationDbi_1.64.1        monocle3_1.3.7              SingleCellExperiment_1.24.0
[19] SummarizedExperiment_1.32.0 GenomicRanges_1.54.1        GenomeInfoDb_1.38.8        
[22] IRanges_2.36.0              S4Vectors_0.40.2            MatrixGenerics_1.14.0      
[25] matrixStats_1.5.0           Biobase_2.66.0              BiocGenerics_0.48.1        
[28] tidyr_1.3.1                 tibble_3.2.1                gprofiler2_0.2.3           
[31] RColorBrewer_1.1-3          viridis_0.6.5               viridisLite_0.4.2          
[34] DoubletFinder_2.0.4         patchwork_1.3.0             dplyr_1.1.4                
[37] cowplot_1.1.3               pheatmap_1.0.12             ggplot2_3.5.2              
[40] Signac_1.14.0               Seurat_5.2.1                SeuratObject_5.0.2         
[43] sp_2.2-0                   

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22          splines_4.3.3             later_1.4.1              
  [4] bitops_1.0-9              R.oo_1.27.0               polyclip_1.10-7          
  [7] fastDummies_1.7.5         lifecycle_1.0.4           Rdpack_2.6.4             
 [10] globals_0.16.3            lattice_0.22-6            MASS_7.3-60.0.1          
 [13] ggdist_3.3.3              magrittr_2.0.3            plotly_4.10.4            
 [16] httpuv_1.6.15             sctransform_0.4.1         spam_2.11-1              
 [19] spatstat.sparse_3.1-0     reticulate_1.41.0.1       pbapply_1.7-2            
 [22] DBI_1.2.3                 minqa_1.2.8               abind_1.4-8              
 [25] zlibbioc_1.48.2           Rtsne_0.17                R.utils_2.13.0           
 [28] RCurl_1.98-1.17           GenomeInfoDbData_1.2.11   ggrepel_0.9.6            
 [31] irlba_2.3.5.1             listenv_0.9.1             spatstat.utils_3.1-3     
 [34] goftest_1.2-3             RSpectra_0.16-2           spatstat.random_3.3-3    
 [37] fitdistrplus_1.2-2        parallelly_1.43.0         DelayedMatrixStats_1.24.0
 [40] codetools_0.2-20          DelayedArray_0.28.0       RcppRoll_0.3.1           
 [43] tidyselect_1.2.1          farver_2.1.2              lme4_1.1-37              
 [46] spatstat.explore_3.4-2    jsonlite_1.9.1            progressr_0.15.1         
 [49] ggridges_0.5.6            survival_3.8-3            systemfonts_1.2.3        
 [52] tools_4.3.3               ragg_1.3.3                ica_1.0-3                
 [55] Rcpp_1.0.14               glue_1.8.0                SparseArray_1.2.4        
 [58] distributional_0.5.0      withr_3.0.2               fastmap_1.2.0            
 [61] boot_1.3-31               digest_0.6.37             timechange_0.3.0         
 [64] R6_2.6.1                  mime_0.13                 textshaping_1.0.0        
 [67] colorspace_2.1-1          scattermore_1.2           tensor_1.5               
 [70] dichromat_2.0-0.1         spatstat.data_3.1-6       RSQLite_2.3.9            
 [73] R.methodsS3_1.8.2         generics_0.1.4            data.table_1.17.0        
 [76] httr_1.4.7                htmlwidgets_1.6.4         S4Arrays_1.2.1           
 [79] uwot_0.2.3                pkgconfig_2.0.3           gtable_0.3.6             
 [82] blob_1.2.4                lmtest_0.9-40             XVector_0.42.0           
 [85] htmltools_0.5.8.1         dotCall64_1.2             scales_1.4.0             
 [88] png_0.1-8                 spatstat.univar_3.1-2     reformulas_0.4.0         
 [91] rstudioapi_0.17.1         tzdb_0.5.0                reshape2_1.4.4           
 [94] nlme_3.1-167              nloptr_2.1.1              zoo_1.8-13               
 [97] cachem_1.1.0              KernSmooth_2.23-26        parallel_4.3.3           
[100] miniUI_0.1.1.1            pillar_1.10.2             vctrs_0.6.5              
[103] RANN_2.6.2                promises_1.3.2            xtable_1.8-4             
[106] cluster_2.1.8.1           cli_3.6.5                 compiler_4.3.3           
[109] Rsamtools_2.18.0          rlang_1.1.6               crayon_1.5.3             
[112] future.apply_1.11.3       labeling_0.4.3            plyr_1.8.9               
[115] stringi_1.8.7             deldir_2.0-4              BiocParallel_1.36.0      
[118] Biostrings_2.70.3         lazyeval_0.2.2            spatstat.geom_3.3-6      
[121] Matrix_1.6-5              RcppHNSW_0.6.0            hms_1.1.3                
[124] sparseMatrixStats_1.14.0  bit64_4.6.0-1             future_1.34.0            
[127] KEGGREST_1.42.0           shiny_1.10.0              rbibutils_2.3            
[130] ROCR_1.0-11               igraph_2.1.4              memoise_2.0.1            
[133] fastmatch_1.1-6           bit_4.6.0 
@ncborcherding
Copy link
Member

Hey @AhmedAbd5

Thanks for reaching out - escape 2.5.0 was just pushed so there is some likely bugs to fix. Thank you for the excellent rundown and issue formatting

Could you show me an example of the your escape assay in the seurat object? Before I start to troubleshoot, I want to ensure that you are getting an output from runEscape() that is properly formatted.

Thanks,
Nick

@AhmedAbd5
Copy link
Author

Thanks for the prompt response. I've included below the Seurat object, the escape assay, and the data layer within the escape assay. I had also included the structure of the assay in my message above (through str on GetAssayData) but I reincluded it below for ease of reference, in case helpful.

>Seu_escape
An object of class Seurat 
76332 features across 144497 samples within 3 assays 
Active assay: SCT (35880 features, 3000 variable features)
 3 layers present: counts, data, scale.data
 2 other assays present: RNA, escape.ssGSEA
 2 dimensional reductions calculated: pca, umap
> Seu_escape@assays$escape.ssGSEA
Assay (v5) data with 3 features for 144497 cells
First 3 features:
 geneSet1, geneSet2, geneSet3 
Layers:
 data 
> Seu_escape@assays$escape.ssGSEA$data
3 x 144497 sparse Matrix of class "dgCMatrix"
  [[ suppressing 46 column names ‘XXXX_AAACCCAAGCACCTGC-1’, ‘XXXX_AAACGAAAGATGCGAC-1’, ‘XXXX_AAACGAAAGTCAATCC-1’ ... ]]
                                                                                                 
geneSet1 5405.429 5506.108 6162.114 5919.400 6573.204 6572.565 6105.148 5336.057 5432.108 5523.026
geneSet2 7396.086 7623.484 8363.183 8259.517 8624.085 7440.403 8327.193 7417.951 7600.016 9041.816
geneSet3 7416.823 7792.180 8193.639 8145.941 8242.479 7682.779 8368.168 7581.908 7731.831 8793.986
                                                                                                 
geneSet1 5647.138 5714.723 6071.481 6216.053 5821.339 6150.044 5937.404 6651.601 5871.740 5274.911
geneSet2 7427.296 8235.697 7197.381 8252.879 8416.293 7165.374 7274.302 7519.874 8013.076 6997.896
geneSet3 7838.593 8265.139 7072.790 8474.091 8143.378 7059.950 7217.534 8230.698 7626.944 7679.002
                                                                                                 
geneSet1 6547.504 5943.069 6360.307 5546.873 5898.548 5726.816 5447.797 5770.468 6294.066 5384.069
geneSet2 8333.896 7552.335 7327.582 6894.783 7917.001 7160.239 8700.836 7084.428 7402.160 7629.479
geneSet3 8000.403 7745.808 7777.410 7258.279 7789.929 7201.755 8847.660 7586.567 7867.674 7840.631
                                                                                                 
geneSet1 5173.141 5837.640 5792.619 5329.918 6218.315 5750.802 5497.925 5445.966 5565.470 6152.461
geneSet2 7238.741 7936.343 8083.408 7552.599 8346.843 7469.243 8185.447 9017.684 6809.259 8446.329
geneSet3 7971.311 8520.442 8032.921 7864.617 8320.704 8382.915 8642.162 8478.201 7316.125 8580.649
                                                                    
geneSet1 5743.273 6272.616 5812.971 5687.151 5979.780 6123.854 ......
geneSet2 7160.998 8523.982 6950.165 7095.806 7087.075 7783.459 ......
geneSet3 7748.367 7964.617 7802.379 7625.417 7312.031 7806.314 ......

 .....suppressing 144451 columns in show(); maybe adjust options(max.print=, width=)
 ..............................
> enrichment_scores <- GetAssayData(Seu_escape, assay = "escape.ssGSEA")
> str(enrichment_scores)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:433491] 0 1 2 0 1 2 0 1 2 0 ...
  ..@ p       : int [1:144498] 0 3 6 9 12 15 18 21 24 27 ...
  ..@ Dim     : int [1:2] 3 144497
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:3] "geneSet1" "geneSet2" "geneSet3"
  .. ..$ : chr [1:144497] "XXXX_AAACCCAAGCACCTGC-1" "XXXX_AAACGAAAGATGCGAC-1" "XXXX_AAACGAAAGTCAATCC-1" "XXXX_AAACGAACACAACCGC-1" ...
  ..@ x       : num [1:433491] 5405 7396 7417 5506 7623 ...
  ..@ factors : list()

ncborcherding added a commit that referenced this issue May 23, 2025
#152 return single-cell object for performNormalization()
@ncborcherding
Copy link
7970 Member

@AhmedAbd5

Thank you a ton for the excellent run down, there was a bug in performNormalization() where the adding of the normalized assay did not return a single cell object.

The offending line:

.adding.Enrich(input.data, normalized, paste0(assay %||% "escape", "_normalized"))

Fixed:

input.data <- .adding.Enrich(input.data, normalized, paste0(assay %||% "escape", "_normalized"))

The fix is in the master branch and I will push it to bioconductor devel next week.

Thanks again,
Nick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0