satijalab / seurat

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

FindAllMarkers returns empty object #9265

Open brianFSM opened 2 months ago

brianFSM commented 2 months ago

I've got an object with 5 samples, and I'm using Seurat v5. I ran sctransform, integrated, scaled, and clustered the object. However, when I go to run FIndAllMarkers it runs in less than a second, returns no warnings or errors, and generates an empty object for me (i.e. no DE genes).

I suspect it has something to do with layers, but I can't for the life of me figure it out. I had a helluva time getting sctransform and integration to work, and I'm still not sure that I did it correctly. I can't find an example in any of the vignettes on how to properly import multiple matrix files (NOT h5, my setup doesn't support h5).

I've printed out the ident table to confirm that I'm working within the proper ident (the resolution selection from clustering). I try switching idents to orig.ident (sample name) and get the same behavior from FindAllMarkers (i.e. runs in a second and generates an empty object)

Here is my code:

d10x.data <- lapply(ids, function(sample.name){
    tenx.matrix.path <- file.path(dataset.path,sample.name,"outs/raw_feature_bc_matrix")
    d10x <- Read10X(tenx.matrix.path)
})

experiment.data <- do.call("cbind", d10x.data)

experiment.aggregate <- CreateSeuratObject(
  experiment.data,
  project = experiment.name,
  min.cells = 0,
  min.features = 300,
  names.field = 2,
  names.delim = "\\-")

###########################
# I filter for mt genes, etc
###########################

experiment.aggregate[["RNA"]] <- split(experiment.aggregate[["RNA"]],
                                     f = experiment.aggregate$orig.ident)

######################################################
# When I run the sctransform/integration process on the ifnb data
# I get a lot more info printed out about what's going on. When I run it on MY
# data I just get a series of progress bars.
######################################################

experiment.aggregate <- SCTransform(experiment.aggregate, 
                             vars.to.regress = regression.vars.1)

experiment.aggregate <- RunPCA(experiment.aggregate,  
                        npcs = 50,  
                        verbose = F)

experiment.aggregate <- RunUMAP(experiment.aggregate,  
                         dims = 1:50)

options(future.globals.maxSize = 9e+09)

experiment.aggregate@active.assay = "SCT"

experiment.aggregate <- IntegrateLayers( 
    object = experiment.aggregate, 
    method = CCAIntegration, 
    normalization.method = "SCT", 
    verbose = F 
    )

###########################
# I calculate cell cycle vars
###########################

experiment.aggregate <- ScaleData(experiment.aggregate, 
                                  vars.to.regress = cell.cycle.vars,
                                  do.scale = FALSE)

experiment.aggregate <- FindNeighbors(experiment.aggregate,
                                      reduction="integrated.dr", 
                                      dims = use.pcs) 

experiment.aggregate <- FindClusters(
    object = experiment.aggregate,
    resolution = seq(0.10,0.8,0.1),
    verbose = FALSE
)

DefaultAssay(experiment.aggregate) <- "SCT"
Idents(experiment.aggregate) <- resolution.selection

PrepSCTFindMarkers(experiment.aggregate, 
                   assay = "SCT", 
                   verbose = TRUE)

markers_all <- FindAllMarkers(
    object = experiment.aggregate, 
    only.pos = TRUE,
    min.pct = 0,
    thresh.use = 0,
    logfc.threshold = 0
)

experiment.aggregate

An object of class Seurat 54125 features across 104654 samples within 2 assays Active assay: SCT (23072 features, 3000 variable features) 3 layers present: counts, data, scale.data 1 other assay present: RNA 4 dimensional reductions calculated: pca, umap, integrated.dr, tsne

sessionInfo()

R version 4.2.3 (2023-03-15) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default BLAS: /hpc/software/R/4.2.3/lib64/R/lib/libRblas.so LAPACK: /hpc/software/R/4.2.3/lib64/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 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 LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] cowplot_1.1.3 ROCR_1.0-11 KernSmooth_2.23-20 sctransform_0.4.1 fields_16.2 viridisLite_0.4.2 spam_2.10-0
[8] DoubletFinder_2.0.4 future_1.33.2 ifnb.SeuratData_3.1.0 patchwork_1.2.0 SeuratData_0.2.2.9001 yaml_2.3.9 dplyr_1.1.4
[15] kableExtra_1.4.0 ggplot2_3.5.1 Seurat_5.1.0 SeuratObject_5.0.2 sp_2.1-4

loaded via a namespace (and not attached): [1] systemfonts_1.0.4 plyr_1.8.9 igraph_1.4.2 lazyeval_0.2.2 splines_4.2.3 RcppHNSW_0.6.0
[7] listenv_0.9.1 scattermore_1.2 GenomeInfoDb_1.34.9 digest_0.6.36 htmltools_0.5.8.1 fansi_1.0.6
[13] magrittr_2.0.3 tensor_1.5 cluster_2.1.6 remotes_2.4.2 globals_0.16.3 matrixStats_1.1.0
[19] svglite_2.1.3 spatstat.sparse_3.1-0 colorspace_2.1-0 rappdirs_0.3.3 ggrepel_0.9.5 textshaping_0.3.6
[25] xfun_0.45 crayon_1.5.3 RCurl_1.98-1.12 jsonlite_1.8.8 progressr_0.14.0 spatstat.data_3.1-2
[31] survival_3.7-0 zoo_1.8-12 glue_1.7.0 polyclip_1.10-6 gtable_0.3.5 zlibbioc_1.44.0
[37] XVector_0.38.0 leiden_0.4.3.1 DelayedArray_0.24.0 future.apply_1.11.2 maps_3.4.2 BiocGenerics_0.44.0
[43] abind_1.4-5 scales_1.3.0 spatstat.random_3.2-3 miniUI_0.1.1.1 Rcpp_1.0.12 xtable_1.8-4
[49] reticulate_1.38.0 dotCall64_1.1-1 stats4_4.2.3 htmlwidgets_1.6.4 httr_1.4.7 RColorBrewer_1.1-3
[55] ica_1.0-3 farver_2.1.2 pkgconfig_2.0.3 sass_0.4.9 uwot_0.2.2 deldir_2.0-4
[61] utf8_1.2.4 labeling_0.4.2 tidyselect_1.2.1 rlang_1.1.4 reshape2_1.4.4 later_1.3.2
[67] cachem_1.0.8 munsell_0.5.0 tools_4.2.3 cli_3.6.3 generics_0.1.3 ggridges_0.5.6
[73] evaluate_0.24.0 stringr_1.5.1 fastmap_1.1.1 ragg_1.3.2 goftest_1.2-3 knitr_1.48
[79] fitdistrplus_1.1-11 purrr_1.0.2 RANN_2.6.1 pbapply_1.7-2 nlme_3.1-165 sparseMatrixStats_1.10.0
[85] mime_0.12 ggrastr_1.0.2 xml2_1.3.4 compiler_4.2.3 rstudioapi_0.16.0 beeswarm_0.4.0
[91] plotly_4.10.4 png_0.1-8 spatstat.utils_3.0-5 tibble_3.2.1 bslib_0.7.0 glmGamPoi_1.10.2
[97] stringi_1.8.4 highr_0.11 RSpectra_0.16-1 lattice_0.20-45 Matrix_1.6-5 vctrs_0.6.5
[103] pillar_1.9.0 lifecycle_1.0.4 jquerylib_0.1.4 spatstat.geom_3.2-9 lmtest_0.9-40 RcppAnnoy_0.0.22
[109] data.table_1.15.4 bitops_1.0-7 irlba_2.3.5.1 httpuv_1.6.15 GenomicRanges_1.50.2 R6_2.5.1
[115] promises_1.3.0 gridExtra_2.3 vipor_0.4.7 IRanges_2.32.0 parallelly_1.37.1 codetools_0.2-19
[121] fastDummies_1.7.3 MASS_7.3-60.0.1 SummarizedExperiment_1.28.0 withr_3.0.0 S4Vectors_0.36.2 GenomeInfoDbData_1.2.9
[127] grid_4.2.3 tidyr_1.3.1 rmarkdown_2.27 DelayedMatrixStats_1.20.0 MatrixGenerics_1.10.0 Cairo_1.6-0
[133] Rtsne_0.17 spatstat.explore_3.2-7 Biobase_2.58.0 shiny_1.8.1.1 ggbeeswarm_0.7.2

mmccorkindale commented 1 week ago

Hi @brianFSM,

Did you ever figure this out? I am having a similar issue, but can't see where I'm going wrong.

I also had to use options(future.globals.maxSize = x) to get SCTransform to run, so I'm thinking this could be the issue.

Best wishes,

Michael

brianFSM commented 1 week ago

Hey @mmccorkindale

Sorry, I haven't had a chance to troubleshoot this issue yet. I ended up switching to v4 and working through it that way.

jonoave commented 1 week ago

Hi, I'm having encountering a similar issue as well with FIndAllMarkers

mmccorkindale commented 1 week ago

I have also reverted back to v4 and the same code is now working - this would be my suggestion until a v5 solution is posted.

Best wishes,

Michael

jonoave commented 1 week ago

Hi @mmccorkindale ,

Thanks for your reply, actually I just wanted to add that I encountered this bug too. I managed to resolve following the suggestion here:

https://github.com/satijalab/seurat/issues/6592

Adding this before running FindAllMarkers worked for me;

object <- PrepSCTFindMarkers(object, assay = "SCT", verbose = TRUE)