ncborcherding / escape

Easy single cell analysis platform for enrichment
https://www.borch.dev/uploads/screpertoire/articles/running_escape
MIT License
143 stars 20 forks source link

Error in (function (..., deparse.level = 1) #83

Closed Sogand65 closed 7 months ago

Sogand65 commented 7 months ago

Hi, Thanks for the nice package you built I am very excited to use it for my analysis. I have a Seurat object and want to see some HLA gene scores with escape since it has a very nice visualization options ... Unfortunately I am getting an error this is my code: Idents(T_Mono) <- T_Mono$class1.5 hlaGenes <- list(HLA1=c("HLA-A", "HLA-B", "HLA-C", "B2M", "HLA-E"), HLA2=c("HLA-DRA","HLA-DRB1", "HLA-DQA1", "HLA-DQA2","HLA-DQB1", "HLA-DQB2", "HLA-DPA1", "HLA-DPB1", "CD74"))
First I used default group runEscape (Adding assay to Seurat object) Tmono_aucell <- runEscape(T_Mono, method = "AUCell", gene.sets = hlaGenes, new.assay.name = "escape.AUCell") [1] "Using sets of 1000 cells. Running 19 times." Error in (function (..., deparse.level = 1) : number of rows of matrices must match (see arg 18)

Next I tried to use all the cells at once: Tmono_aucell <- runEscape(T_Mono, method = "AUCell", gene.sets = hlaGenes, groups = dim(T_Mono)[2], new.assay.name = "escape.AUCell") [1] "Using sets of 18152 cells. Running 1 times." Error in [[<-: ! Cannot add new cells with [[<- Run rlang::last_trace() to see where the error occurred.

rlang::last_trace() <error/rlang_error> Error in [[<-: ! Cannot add new cells with [[<-

Backtrace: ▆

  1. └─escape::runEscape(...)
  2. └─escape:::.adding.Enrich(input.data, enrichment, new.assay.name)
  3. ├─methods (local) [[<-(*tmp*, enrichment.name, value = <Assay[,2]>)
  4. └─SeuratObject (local) [[<-(*tmp*, enrichment.name, value = <Assay[,2]>) Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.
Sogand65 commented 7 months ago

I should add I tested the "ssGSEA" method and it worked fine. I was wondering why isn't working with "AUCell"? am I supposed to change anything on the argument setting while using AUCell?

ncborcherding commented 7 months ago

Hey @Sogand65

Thanks for reaching out - would you mind giving me the output of sesssionInfo() to help with this problem? You should not need to call anything additionally for AUCell.

The jest of the issue is that AUCell automatically filters (via internall calls) the calculation resulting in uneven chunks (for the first example) and a matrix that does not match the number of cells for the second example.

The other approaches - ssGSEA, UCell, and GSVA should not be affecting at all.

I am on it and will tag a commit to this issue when I push to the dev branch.

Thanks again, Nick

Sogand65 commented 7 months ago

Hi, Thanks for replying and happy to help, this is my sessionInfo: sessionInfo() R version 4.3.2 (2023-10-31) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.6.4

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: America/Chicago tzcode source: internal

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

other attached packages: [1] ggplot2_3.5.0 Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-3
[5] escape_1.99.0

loaded via a namespace (and not attached): [1] RcppAnnoy_0.0.22 splines_4.3.2 later_1.3.2
[4] bitops_1.0-7 tibble_3.2.1 R.oo_1.26.0
[7] polyclip_1.10-6 graph_1.80.0 XML_3.99-0.16.1
[10] fastDummies_1.7.3 lifecycle_1.0.4 globals_0.16.2
[13] lattice_0.22-5 MASS_7.3-60.0.1 ggdist_3.3.1
[16] magrittr_2.0.3 plotly_4.10.4 httpuv_1.6.14
[19] sctransform_0.4.1 spam_2.10-0 spatstat.sparse_3.0-3
[22] reticulate_1.35.0 cowplot_1.1.3 pbapply_1.7-2
[25] DBI_1.2.2 RColorBrewer_1.1-3 abind_1.4-5
[28] zlibbioc_1.48.0 Rtsne_0.17 GenomicRanges_1.54.1
[31] purrr_1.0.2 R.utils_2.12.3 BiocGenerics_0.48.1
[34] msigdbr_7.5.1 RCurl_1.98-1.14 GenomeInfoDbData_1.2.11
[37] IRanges_2.36.0 S4Vectors_0.40.2 ggrepel_0.9.5
[40] irlba_2.3.5.1 spatstat.utils_3.0-4 listenv_0.9.1
[43] GSVA_1.51.6 goftest_1.2-3 RSpectra_0.16-1
[46] spatstat.random_3.2-2 annotate_1.80.0 fitdistrplus_1.1-11
[49] parallelly_1.37.0 DelayedMatrixStats_1.24.0 leiden_0.4.3.1
[52] codetools_0.2-19 DelayedArray_0.28.0 tidyselect_1.2.0
[55] UCell_2.6.2 ScaledMatrix_1.10.0 spatstat.explore_3.2-6
[58] matrixStats_1.2.0 stats4_4.3.2 jsonlite_1.8.8
[61] BiocNeighbors_1.20.2 ellipsis_0.3.2 progressr_0.14.0
[64] ggridges_0.5.6 survival_3.5-8 tools_4.3.2
[67] ica_1.0-3 Rcpp_1.0.12 glue_1.7.0
[70] gridExtra_2.3 SparseArray_1.2.4 MatrixGenerics_1.14.0
[73] distributional_0.4.0 GenomeInfoDb_1.38.6 AUCell_1.24.0
[76] dplyr_1.1.4 HDF5Array_1.30.1 withr_3.0.0
[79] fastmap_1.1.1 rhdf5filters_1.14.1 fansi_1.0.6
[82] ggpointdensity_0.1.0 digest_0.6.34 rsvd_1.0.5
[85] R6_2.5.1 mime_0.12 colorspace_2.1-0
[88] scattermore_1.2 tensor_1.5 spatstat.data_3.0-4
[91] RSQLite_2.3.5 R.methodsS3_1.8.2 utf8_1.2.4
[94] tidyr_1.3.1 generics_0.1.3 data.table_1.15.0
[97] httr_1.4.7 htmlwidgets_1.6.4 S4Arrays_1.2.0
[100] uwot_0.1.16 pkgconfig_2.0.3 gtable_0.3.4
[103] blob_1.2.4 lmtest_0.9-40 SingleCellExperiment_1.24.0 [106] XVector_0.42.0 htmltools_0.5.7 dotCall64_1.1-1
[109] GSEABase_1.64.0 scales_1.3.0 Biobase_2.62.0
[112] png_0.1-8 rstudioapi_0.15.0 reshape2_1.4.4
[115] nlme_3.1-164 cachem_1.0.8 zoo_1.8-12
[118] rhdf5_2.46.1 stringr_1.5.1 KernSmooth_2.23-22
[121] parallel_4.3.2 miniUI_0.1.1.1 AnnotationDbi_1.64.1
[124] pillar_1.9.0 grid_4.3.2 vctrs_0.6.5
[127] RANN_2.6.1 promises_1.2.1 BiocSingular_1.18.0
[130] beachmat_2.18.1 xtable_1.8-4 cluster_2.1.6
[133] cli_3.6.2 compiler_4.3.2 rlang_1.1.3
[136] crayon_1.5.2 future.apply_1.11.1 plyr_1.8.9
[139] stringi_1.8.3 deldir_2.0-2 viridisLite_0.4.2
[142] BiocParallel_1.36.0 babelgene_22.9 munsell_0.5.0
[145] Biostrings_2.70.2 lazyeval_0.2.2 spatstat.geom_3.2-8
[148] Matrix_1.6-5 RcppHNSW_0.6.0 patchwork_1.2.0
[151] sparseMatrixStats_1.14.0 bit64_4.0.5 future_1.33.1
[154] Rhdf5lib_1.24.2 KEGGREST_1.42.0 shiny_1.8.0
[157] SummarizedExperiment_1.32.0 ROCR_1.0-11 igraph_2.0.2
[160] memoise_2.0.1 bit_4.0.5

Sogand65 commented 7 months ago

Hi,

I am running the UCell method and getting the following error, I tried to use larger maxRank but still getting same error, I appreciate any help on this: cbmc <- runEscape(cbmc, method = "UCell", gene.sets = GS.GO,groups = 5000, new.assay.name = "escape.go.UCell") [1] "Using sets of 5000 cells. Running 15 times." Error in calculate_Uscore(m, features = features, maxRank = maxRank, chunk.size = chunk.size, : One or more signatures contain more genes than maxRank parameter. Increase maxRank parameter or make shorter signature

cbmc <- runEscape(cbmc, method = "UCell", gene.sets = GS.GO,groups = 5000, new.assay.name = "escape.go.UCell", maxRank = 5000) [1] "Using sets of 5000 cells. Running 15 times." Error in calculate_Uscore(m, features = features, maxRank = maxRank, chunk.size = chunk.size, : One or more signatures contain more genes than maxRank parameter. Increase maxRank parameter or make shorter signatures

Thanks!

ncborcherding commented 7 months ago

This one is more starightforward, you are passing to Ucell at least 1 gene set with > 1500 genes (which is the maxRank or limit). Either filter the gene sets and remove the extremely long ones (which is a pretty good policy anyway) or adjust the maxRanks = 2000 for example.

You can pass the maxRanks in the runEscape() call itself.

Nick

ncborcherding commented 7 months ago

Got the fix for AUCell in the development version - thanks again for letting me know!

Nick