ncborcherding / escape

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

Normalization error #86

Closed Sogand65 closed 8 months ago

Sogand65 commented 8 months ago

Hi,

I want to calculate the scoring of a single pathway on GO so I can run the runEscape() successfully but getting an error for normalization! can you help me with the following error. Do you think the number of gene sets would affect the normalization? Thanks for your help!

GS.GO_TNF <- list(GOBP_POSITIVE_REGULATION_OF_TUMOR_NECROSIS_FACTOR_SUPERFAMILY_CYTOKINE_PRODUCTION = GS.GO[["GOBP_POSITIVE_REGULATION_OF_TUMOR_NECROSIS_FACTOR_SUPERFAMILY_CYTOKINE_PRODUCTION"]]) cbmc <- LoadSeuratRds(paste0(resPath, "escape/cbmc_escape.Rds"))

cbmc <- runEscape(cbmc, method = "ssGSEA", gene.sets = GS.GO_TNF, groups = 5000, new.assay.name = "escape.GO_TNF_prod.ssGSEA")

cbmc <- performNormalization(cbmc, assay = "escape.GO_TNF_prod.ssGSEA", gene.sets = GS.GO_TNF, scale.factor = cbmc$nFeature_RNA)

[1] "Normalizing enrichment scores per cell..." Error in enriched[, x] <- enriched[, x]/scale.factor : number of items to replace is not a multiple of replacement length

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] stats4 stats graphics grDevices utils datasets methods base

other attached packages: [1] NMF_0.27 cluster_2.1.6 rngtools_1.5.2 registry_0.5-1 mixtools_2.0.0 GSEABase_1.64.0
[7] graph_1.80.0 annotate_1.80.0 XML_3.99-0.16.1 AnnotationDbi_1.64.1 IRanges_2.36.0 S4Vectors_0.40.2
[13] Biobase_2.62.0 BiocGenerics_0.48.1 AUCell_1.24.0 openxlsx_4.2.5.2 harmony_1.2.0 Rcpp_1.0.12
[19] gridExtra_2.3 beepr_1.3 ggpubr_0.6.0 clustree_0.5.1 ggraph_2.2.0 RColorBrewer_1.1-3
[25] tidyr_1.3.1 dplyr_1.1.4 readxl_1.4.3 patchwork_1.2.0 GSA_1.03.2 ggplot2_3.5.0
[31] Seurat_5.0.2 SeuratObject_5.0.1 sp_2.1-3 escape_1.99.1

loaded via a namespace (and not attached): [1] segmented_2.0-3 matrixStats_1.2.0 GSVA_1.51.6 spatstat.sparse_3.0-3
[5] bitops_1.0-7 doParallel_1.0.17 httr_1.4.7 tools_4.3.2
[9] sctransform_0.4.1 backports_1.4.1 utf8_1.2.4 R6_2.5.1
[13] HDF5Array_1.30.1 lazyeval_0.2.2 uwot_0.1.16 ggdist_3.3.1
[17] rhdf5filters_1.14.1 withr_3.0.0 progressr_0.14.0 cli_3.6.2
[21] spatstat.explore_3.2-6 fastDummies_1.7.3 spatstat.data_3.0-4 ggridges_0.5.6
[25] pbapply_1.7-2 R.utils_2.12.3 parallelly_1.37.1 rstudioapi_0.15.0
[29] RSQLite_2.3.5 generics_0.1.3 ica_1.0-3 spatstat.random_3.2-3
[33] zip_2.3.1 car_3.1-2 distributional_0.4.0 Matrix_1.6-5
[37] fansi_1.0.6 abind_1.4-5 R.methodsS3_1.8.2 lifecycle_1.0.4
[41] carData_3.0-5 SummarizedExperiment_1.32.0 rhdf5_2.46.1 SparseArray_1.2.4
[45] Rtsne_0.17 grid_4.3.2 blob_1.2.4 promises_1.2.1
[49] crayon_1.5.2 miniUI_0.1.1.1 lattice_0.22-5 beachmat_2.18.1
[53] msigdbr_7.5.1 cowplot_1.1.3 KEGGREST_1.42.0 pillar_1.9.0
[57] GenomicRanges_1.54.1 future.apply_1.11.1 codetools_0.2-19 leiden_0.4.3.1
[61] glue_1.7.0 data.table_1.15.2 vctrs_0.6.5 png_0.1-8
[65] spam_2.10-0 cellranger_1.1.0 gtable_0.3.4 kernlab_0.9-32
[69] cachem_1.0.8 S4Arrays_1.2.0 mime_0.12 tidygraph_1.3.1
[73] survival_3.5-8 audio_0.1-11 SingleCellExperiment_1.24.0 pheatmap_1.0.12
[77] iterators_1.0.14 ellipsis_0.3.2 fitdistrplus_1.1-11 ROCR_1.0-11
[81] nlme_3.1-164 bit64_4.0.5 RcppAnnoy_0.0.22 GenomeInfoDb_1.38.6
[85] irlba_2.3.5.1 KernSmooth_2.23-22 colorspace_2.1-0 DBI_1.2.2
[89] UCell_2.6.2 tidyselect_1.2.0 bit_4.0.5 compiler_4.3.2
[93] BiocNeighbors_1.20.2 DelayedArray_0.28.0 plotly_4.10.4 scales_1.3.0
[97] lmtest_0.9-40 stringr_1.5.1 digest_0.6.34 goftest_1.2-3
[101] spatstat.utils_3.0-4 XVector_0.42.0 htmltools_0.5.7 pkgconfig_2.0.3
[105] sparseMatrixStats_1.14.0 MatrixGenerics_1.14.0 fastmap_1.1.1 rlang_1.1.3
[109] htmlwidgets_1.6.4 shiny_1.8.0 DelayedMatrixStats_1.24.0 farver_2.1.1
[113] zoo_1.8-12 jsonlite_1.8.8 BiocParallel_1.36.0 R.oo_1.26.0
[117] BiocSingular_1.18.0 RCurl_1.98-1.14 magrittr_2.0.3 GenomeInfoDbData_1.2.11
[121] dotCall64_1.1-1 Rhdf5lib_1.24.2 munsell_0.5.0 babelgene_22.9
[125] viridis_0.6.5 reticulate_1.35.0 stringi_1.8.3 zlibbioc_1.48.0
[129] MASS_7.3-60.0.1 plyr_1.8.9 parallel_4.3.2 listenv_0.9.1
[133] ggrepel_0.9.5 deldir_2.0-4 Biostrings_2.70.2 graphlayouts_1.1.0
[137] splines_4.3.2 tensor_1.5 igraph_2.0.2 spatstat.geom_3.2-9
[141] ggsignif_0.6.4 RcppHNSW_0.6.0 reshape2_1.4.4 ScaledMatrix_1.10.0
[145] foreach_1.5.2 tweenr_2.0.3 httpuv_1.6.14 RANN_2.6.1
[149] purrr_1.0.2 polyclip_1.10-6 future_1.33.1 scattermore_1.2
[153] gridBase_0.4-7 ggforce_0.4.2 rsvd_1.0.5 broom_1.0.5
[157] xtable_1.8-4 RSpectra_0.16-1 rstatix_0.7.2 later_1.3.2
[161] viridisLite_0.4.2 ggpointdensity_0.1.0 tibble_3.2.1 memoise_2.0.1
[165] globals_0.16.2

ncborcherding commented 8 months ago

@Sogand65

As the error implies the seems to me a mismatch in lengths - What is the output of the following:

dim(cbmc)
length(cbmc$nFeature_RNA)
dim(cbmc@assays$escape.GO_TNF_prod.ssGSEA@data

Thanks, Nick

Sogand65 commented 8 months ago

Hi Nick, Thanks for replying. The error goes a way as long as I add another gene list, so it appears the error only occurs when using a single gene list! these are the outputs you asked: dim(cbmc) [1] 24897 74618

length(cbmc$nFeature_RNA) [1] 74618

dim(cbmc@assays$escape.GO_TNF.ssGSEA$data) NULL

class(cbmc@assays$escape.GO_TNF.ssGSEA$data) [1] "numeric" (I guess this is the problem when using only one feature (gene list))

thanks!

ncborcherding commented 8 months ago

Thanks for the follow up.