ncborcherding / scRepertoire

A toolkit for single-cell immune profiling
https://www.borch.dev/uploads/screpertoire/
MIT License
311 stars 54 forks source link

runEscape - subscript out of bounds error #389

Closed kkearns13 closed 4 months ago

kkearns13 commented 4 months ago

Hi! I've been having some issues running escape. When I try runEscape, I get the error Error in .subscript.2ary(x, i, j, drop = drop) : subscript out of bounds. Here is the code I'm using (essentially what's on the vignette):

GS.hallmark <- getGeneSets(library = "H")

# check if present in dataset
lapply(GS.hallmark, function(i) i %in% rownames(gd.sub@assays$SCT@counts))

# not everything is found in gd.sub, so will subset for genes found
GS.hallmark.sub <- lapply(GS.hallmark, function(i) i[i %in% rownames(gd.sub@assays$SCT@counts)])

enrichment.scores <- escape.matrix(gd.sub@assays$SCT@counts, 
                                   gene.sets = GS.hallmark.sub, 
                                   method="ssGSEA",
                                   groups = 1000, 
                                   min.size = 5)

scRep_example <- runEscape(gd.sub, 
                           method = "ssGSEA",
                           gene.sets = GS.hallmark.sub, 
                           groups = 5000, 
                           min.size = 0,
                           new.assay.name = "escape.ssGSEA")

I've also tried using all the genes in GS.hallmark and that's when I initially ran into the error and thought it was an issue with the genes not being found in the Seurat object, but I don't think that's the case since the above doesn't work either. Any help would be greatly appreciated! Thank you!

sessionInfo details:

R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.0

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

other attached packages:
 [1] escape_1.99.1               GSVA_1.51.17                fgsea_1.28.0                presto_1.0.0               
 [5] Rcpp_1.0.12                 RColorBrewer_1.1-3          DEGreport_1.38.5            DESeq2_1.42.1              
 [9] SummarizedExperiment_1.30.2 Biobase_2.62.0              MatrixGenerics_1.12.3       matrixStats_1.3.0          
[13] GenomicRanges_1.52.1        GenomeInfoDb_1.38.8         IRanges_2.36.0              S4Vectors_0.40.2           
[17] BiocGenerics_0.48.1         pheatmap_1.0.12             heatmap3_1.1.9              msigdbr_7.5.1              
[21] rstatix_0.7.2               ggpubr_0.6.0                plyr_1.8.9                  ggrepel_0.9.5              
[25] clustree_0.5.1              ggraph_2.2.1                data.table_1.15.4           scRepertoire_2.0.0         
[29] lubridate_1.9.3             forcats_1.0.0               stringr_1.5.1               dplyr_1.1.4                
[33] purrr_1.0.2                 readr_2.1.5                 tidyr_1.3.1                 tibble_3.2.1               
[37] ggplot2_3.5.0               tidyverse_2.0.0             SeuratObject_4.1.4          Seurat_4.4.0
ncborcherding commented 4 months ago

Hey Kendell,

Everything looks fine from your rundown of the issue - you do not need to subset the gene sets by rownames - that will be handled during the calculation.

I did find this issue on the Seurat repo - it looks like it is a known issue with Seurat and they are in progress of fixing it.

Let me know if you have any other questions or suggestions.

Nick

ncborcherding commented 4 months ago

An alternative I just though about is feeding the RNA matrix directly into the escape.matrix()

kkearns13 commented 4 months ago

Hi Nick,

Thank you for the quick reply and for sending the Seurat issue! Sorry for the delayed response! It seems like the original poster is running Seurat v5. I'm running Seurat v4, so I'm not sure how it would work if they provide a fix for v5. But escape.matrix works fine and I can use the normalization option in there instead of using runEscape and performNormalization. Thanks again!