satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 909 forks source link

Issue adding a pool list of features on AddModuleScore #6713

Closed KWhytock13 closed 1 year ago

KWhytock13 commented 1 year ago

Hi, Thanks for creating this great package!

I am having issues including a pool list of features in the AddModuleScore() function when using the RNA assay.

The error I get is;

Adips_young <- AddModuleScore(Adips_young, features = Section1, pool = combine, assay = "RNA", name = "Section1") Error in sample.int(length(x), size, replace, prob) : cannot take a sample larger than the population when 'replace = FALSE'

str(Section1) List of 1 $ : chr [1:38] "TSPYL1" "PSMB4" "TRARG1" "TPI1" ... class(Section1) [1] "list" str(combine) chr [1:115] "MALAT1" "NEAT1" "SOX5" "PDE3B" "EBF1" "PLIN4" "FTX" "IMMP2L" "CAVIN1" "NAV3" "SRSF11" "GHR" "WDPCP" "LRP1B" "LINC02237" "AHNAK" ... class(combine) [1] "character"

Adips_young An object of class Seurat 141495 features across 6478 samples within 5 assays Active assay: RNA (31356 features, 0 variable features) 4 other assays present: SCT, integrated, unfiltered, Pcoding 2 dimensional reductions calculated: pca, umap

Interestingly the error does not seem to occur when I use a longer pool of features;

Adips_young <- AddModuleScore(Adips_young, features = Section1, pool = young_background, name = "Section1")

str(young_background) chr [1:6351] "PLIN4" "DPP10" "ESYT1" "EPHA6" "CFD" "NRXN1" "GRID2" "PTCHD1-AS" "NKAIN3" "MIR325HG" "PTPRD" "LRRC7" "CTNNA2" "LINC00276" ... class(young_background) [1] "character"

The genes in my features list and pool list match up on both examples.

setdiff(Section1[[1]], combine) character(0) setdiff(Section1[[1]], young_background) character(0)

sessionInfo() R version 4.2.2 (2022-10-31) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.6

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

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

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

other attached packages: [1] ggvenn_0.1.9 escape_1.8.0 hypeR_1.14.0 NbClust_3.0.1 ComplexHeatmap_2.14.0
[6] mgcv_1.8-41 nlme_3.1-160 RColorBrewer_1.1-3 SeuratObject_4.1.3 Seurat_4.2.1
[11] forcats_0.5.2 stringr_1.4.1 dplyr_1.0.10 purrr_0.3.5 readr_2.1.3
[16] tidyr_1.2.1 tibble_3.1.8 ggplot2_3.4.0 tidyverse_1.3.2 viridis_0.6.2
[21] viridisLite_0.4.1 monocle3_1.3.1 SingleCellExperiment_1.20.0 SummarizedExperiment_1.28.0 GenomicRanges_1.50.1
[26] GenomeInfoDb_1.34.3 IRanges_2.32.0 S4Vectors_0.36.0 MatrixGenerics_1.10.0 matrixStats_0.62.0
[31] Biobase_2.58.0 BiocGenerics_0.44.0

loaded via a namespace (and not attached): [1] scattermore_0.8 bit64_4.0.5 knitr_1.40 irlba_2.3.5.1 DelayedArray_0.24.0
[6] data.table_1.14.6 KEGGREST_1.38.0 RCurl_1.98-1.9 doParallel_1.0.17 generics_0.1.3
[11] ScaledMatrix_1.6.0 callr_3.7.3 terra_1.6-17 cowplot_1.1.1 usethis_2.1.6
[16] RSQLite_2.2.18 RANN_2.6.1 future_1.29.0 bit_4.0.5 tzdb_0.3.0
[21] spatstat.data_3.0-0 webshot_0.5.4 xml2_1.3.3 lubridate_1.9.0 httpuv_1.6.6
[26] assertthat_0.2.1 gargle_1.2.1 xfun_0.35 hms_1.1.2 babelgene_22.9
[31] evaluate_0.18 promises_1.2.0.1 fansi_1.0.3 dbplyr_2.2.1 readxl_1.4.1
[36] igraph_1.3.5 DBI_1.1.3 htmlwidgets_1.5.4 spatstat.geom_3.0-3 googledrive_2.0.0
[41] ellipsis_0.3.2 backports_1.4.1 annotate_1.76.0 sparseMatrixStats_1.10.0 deldir_1.0-6
[46] vctrs_0.5.1 Cairo_1.6-0 remotes_2.4.2 ROCR_1.0-11 abind_1.4-5
[51] cachem_1.0.6 withr_2.5.0 ggforce_0.4.1 progressr_0.11.0 sctransform_0.3.5
[56] prettyunits_1.1.1 goftest_1.2-3 svglite_2.1.0 cluster_2.1.4 lazyeval_0.2.2
[61] crayon_1.5.2 spatstat.explore_3.0-5 labeling_0.4.2 pkgconfig_2.0.3 tweenr_2.0.2
[66] pkgload_1.3.2 devtools_2.4.5 rlang_1.0.6 globals_0.16.1 lifecycle_1.0.3
[71] miniUI_0.1.1.1 rsvd_1.0.5 modelr_0.1.10 cellranger_1.1.0 polyclip_1.10-4
[76] GSVA_1.46.0 lmtest_0.9-40 graph_1.76.0 Matrix_1.5-3 Rhdf5lib_1.20.0
[81] boot_1.3-28 zoo_1.8-11 reprex_2.0.2 ggridges_0.5.4 GlobalOptions_0.1.2
[86] processx_3.8.0 googlesheets4_1.0.1 png_0.1-7 rjson_0.2.21 bitops_1.0-7
[91] rhdf5filters_1.10.0 KernSmooth_2.23-20 visNetwork_2.1.2 Biostrings_2.66.0 DelayedMatrixStats_1.20.0 [96] blob_1.2.3 shape_1.4.6 parallelly_1.32.1 spatstat.random_3.0-1 beachmat_2.14.0
[101] scales_1.2.1 memoise_2.0.1 GSEABase_1.60.0 magrittr_2.0.3 plyr_1.8.8
[106] ica_1.0-3 zlibbioc_1.44.0 compiler_4.2.2 factoextra_1.0.7 kableExtra_1.3.4
[111] clue_0.3-62 lme4_1.1-31 fitdistrplus_1.1-8 cli_3.4.1 XVector_0.38.0
[116] urlchecker_1.0.1 listenv_0.8.0 patchwork_1.1.2 pbapply_1.6-0 ps_1.7.2
[121] MASS_7.3-58.1 tidyselect_1.2.0 stringi_1.7.8 BiocSingular_1.14.0 ggrepel_0.9.2
[126] tools_4.2.2 timechange_0.1.1 future.apply_1.10.0 parallel_4.2.2 circlize_0.4.15
[131] rstudioapi_0.14 foreach_1.5.2 gridExtra_2.3 farver_2.1.1 Rtsne_0.16
[136] digest_0.6.30 BiocManager_1.30.19 shiny_1.7.3 Rcpp_1.0.9 broom_1.0.1
[141] later_1.3.0 RcppAnnoy_0.0.20 httr_1.4.4 AnnotationDbi_1.60.0 colorspace_2.0-3
[146] rvest_1.0.3 XML_3.99-0.12 fs_1.5.2 tensor_1.5 reticulate_1.26
[151] splines_4.2.2 uwot_0.1.14 spatstat.utils_3.0-1 sp_1.5-1 plotly_4.10.1
[156] sessioninfo_1.2.2 systemfonts_1.0.4 xtable_1.8-4 jsonlite_1.8.3 nloptr_2.0.3
[161] R6_2.5.1 profvis_0.3.7 pillar_1.8.1 htmltools_0.5.3 mime_0.12
[166] glue_1.6.2 fastmap_1.1.0 minqa_1.2.5 reactable_0.3.0 BiocParallel_1.32.1
[171] BiocNeighbors_1.16.0 codetools_0.2-18 pkgbuild_1.3.1 utf8_1.2.2 lattice_0.20-45
[176] spatstat.sparse_3.0-0 leiden_0.4.3 zip_2.2.2 openxlsx_4.2.5.1 survival_3.4-0
[181] rmarkdown_2.18 munsell_0.5.0 rhdf5_2.42.0 GetoptLong_1.0.5 GenomeInfoDbData_1.2.9
[186] UCell_2.2.0 iterators_1.0.14 HDF5Array_1.26.0 haven_2.5.1 reshape2_1.4.4
[191] gtable_0.3.1 msigdbr_7.5.1

mojaveazure commented 1 year ago

You're using a small number of features for your pool; try adjusting the number of control features used