satijalab / seurat

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

Warning: Layer counts isn't present in the assay object; returning NULL #9165

Closed SaharBJ closed 1 week ago

SaharBJ commented 2 months ago

sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so; LAPACK version 3.8.0

locale: [1] LC_CTYPE=en_ZA.utf-8 LC_NUMERIC=C [3] LC_TIME=en_ZA.utf-8 LC_COLLATE=en_ZA.utf-8 [5] LC_MONETARY=en_ZA.utf-8 LC_MESSAGES=en_ZA.utf-8 [7] LC_PAPER=en_ZA.utf-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_ZA.utf-8 LC_IDENTIFICATION=C

time zone: Africa/Johannesburg tzcode source: system (glibc)

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

other attached packages: [1] patchwork_1.2.0 ggplot2_3.5.1 [3] EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.24.1 [5] AnnotationFilter_1.24.0 GenomicFeatures_1.52.2 [7] AnnotationDbi_1.62.2 Biobase_2.60.0 [9] GenomicRanges_1.52.1 GenomeInfoDb_1.36.4 [11] IRanges_2.34.1 S4Vectors_0.38.2 [13] BiocGenerics_0.46.0 Seurat_5.0.0 [15] SeuratObject_5.0.2 sp_2.1-4 [17] Signac_1.13.0 withr_3.0.0

loaded via a namespace (and not attached): [1] RcppAnnoy_0.0.22 splines_4.3.0 [3] later_1.3.2 BiocIO_1.10.0 [5] bitops_1.0-8 filelock_1.0.3 [7] tibble_3.2.1 polyclip_1.10-7 [9] XML_3.99-0.16.1 fastDummies_1.7.3 [11] lifecycle_1.0.4 globals_0.16.3 [13] lattice_0.21-8 MASS_7.3-58.4 [15] magrittr_2.0.3 plotly_4.10.4 [17] yaml_2.3.10 httpuv_1.6.15 [19] sctransform_0.4.1 spam_2.10-0 [21] spatstat.sparse_3.1-0 reticulate_1.38.0 [23] cowplot_1.1.3 pbapply_1.7-2 [25] DBI_1.2.2 RColorBrewer_1.1-3 [27] abind_1.4-5 zlibbioc_1.46.0 [29] Rtsne_0.17 purrr_1.0.2 [31] RCurl_1.98-1.14 rappdirs_0.3.3 [33] GenomeInfoDbData_1.2.10 ggrepel_0.9.5 [35] irlba_2.3.5.1 listenv_0.9.1 [37] spatstat.utils_3.0-5 goftest_1.2-3 [39] RSpectra_0.16-2 spatstat.random_3.3-1 [41] fitdistrplus_1.2-1 parallelly_1.38.0 [43] DelayedArray_0.26.7 leiden_0.4.3.1 [45] codetools_0.2-19 RcppRoll_0.3.0 [47] xml2_1.3.6 tidyselect_1.2.1 [49] farver_2.1.2 matrixStats_1.3.0 [51] BiocFileCache_2.8.0 spatstat.explore_3.3-1 [53] GenomicAlignments_1.36.0 jsonlite_1.8.8 [55] progressr_0.14.0 ggridges_0.5.6 [57] survival_3.5-5 tools_4.3.0 [59] progress_1.2.3 ica_1.0-3 [61] Rcpp_1.0.13 glue_1.7.0 [63] gridExtra_2.3 MatrixGenerics_1.12.3 [65] dplyr_1.1.4 fastmap_1.2.0 [67] fansi_1.0.6 digest_0.6.36 [69] R6_2.5.1 mime_0.12 [71] colorspace_2.1-1 scattermore_1.2 [73] tensor_1.5 spatstat.data_3.1-2 [75] biomaRt_2.56.1 RSQLite_2.3.6 [77] utf8_1.2.4 tidyr_1.3.1 [79] generics_0.1.3 data.table_1.15.4 [81] rtracklayer_1.60.1 S4Arrays_1.0.6 [83] prettyunits_1.2.0 httr_1.4.7 [85] htmlwidgets_1.6.4 uwot_0.2.2 [87] pkgconfig_2.0.3 gtable_0.3.5 [89] blob_1.2.4 lmtest_0.9-40 [91] XVector_0.40.0 htmltools_0.5.8.1 [93] dotCall64_1.1-1 ProtGenerics_1.32.0 [95] scales_1.3.0 png_0.1-8 [97] spatstat.univar_3.0-0 reshape2_1.4.4 [99] rjson_0.2.21 nlme_3.1-162 [101] curl_5.2.1 zoo_1.8-12 [103] cachem_1.1.0 stringr_1.5.1 [105] KernSmooth_2.23-20 parallel_4.3.0 [107] miniUI_0.1.1.1 restfulr_0.0.15 [109] pillar_1.9.0 grid_4.3.0 [111] vctrs_0.6.5 RANN_2.6.1 [113] promises_1.3.0 dbplyr_2.5.0 [115] xtable_1.8-4 cluster_2.1.4 [117] cli_3.6.3 compiler_4.3.0 [119] Rsamtools_2.16.0 rlang_1.1.4 [121] crayon_1.5.3 future.apply_1.11.2 [123] labeling_0.4.3 plyr_1.8.9 [125] stringi_1.8.4 viridisLite_0.4.2 [127] deldir_2.0-4 BiocParallel_1.34.2 [129] munsell_0.5.1 Biostrings_2.68.1 [131] lazyeval_0.2.2 spatstat.geom_3.3-2 [133] Matrix_1.6-5 RcppHNSW_0.6.0 [135] hms_1.1.3 bit64_4.0.5 [137] future_1.34.0 KEGGREST_1.40.1 [139] shiny_1.9.0 SummarizedExperiment_1.30.2 [141] ROCR_1.0-11 igraph_2.0.3 [143] memoise_2.0.1 fastmatch_1.1-4 [145] bit_4.0.5

samuel-marsh commented 2 months ago

Hi,

Can you please post the code that you are running and the output error messages in full?

Thanks, Sam

SaharBJ commented 2 months ago

library(withr) library(Signac) library(Seurat, lib = "/scratch/jmlsah001/R/x86_64-pc-linux-gnu-library/4.3") library(EnsDb.Hsapiens.v86) library(ggplot2) library(patchwork) library(SeuratObject, lib = "/scratch/jmlsah001/R/x86_64-pc-linux-gnu-library/4.3")> library(Signac) library(Seurat, lib = "/scratch/jmlsah001/R/x86_64-pc-linux-gnu-library/4.3") Loading required package: SeuratObject Loading required package: sp

Attaching package: ‘SeuratObject’

The following objects are masked from ‘package:base’:

intersect, t

library(EnsDb.Hsapiens.v86) Loading required package: ensembldb Loading required package: BiocGenerics

Attaching package: ‘BiocGenerics’

The following object is masked from ‘package:SeuratObject’:

intersect

The following objects are masked from ‘package:stats’:

IQR, mad, sd, var, xtabs

The following objects are masked from ‘package:base’:

anyDuplicated, aperm, append, as.data.frame, basename, cbind,
colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort,
table, tapply, union, unique, unsplit, which.max, which.min

Loading required package: GenomicRanges Loading required package: stats4 Loading required package: S4Vectors

Attaching package: ‘S4Vectors’

The following object is masked from ‘package:utils’:

findMatches

The following objects are masked from ‘package:base’:

expand.grid, I, unname

Loading required package: IRanges

Attaching package: ‘IRanges’

The following object is masked from ‘package:sp’:

%over%

Loading required package: GenomeInfoDb Loading required package: GenomicFeatures Loading required package: AnnotationDbi Loading required package: Biobase Welcome to Bioconductor

Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: AnnotationFilter

Attaching package: 'ensembldb'

The following object is masked from 'package:stats':

filter

library(ggplot2) library(patchwork) library(SeuratObject, lib = "/scratch/jmlsah001/R/x86_64-pc-linux-gnu-library/> 3") P11 <- readRDS("/scratch/jmlsah001/MYDATA/P11/outputs/P11_integration.rds")

P13 <- readRDS("/scratch/jmlsah001/MYDATA/P13/outputs/P13_integration.rds") P11$dataset <- "P11"

P13$dataset <- "P13"

samples.combined <- merge(P11, P13) Warning: Some cell names are duplicated across objects provided. Renaming to enforce unique cell names. |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows samples.combined <- FindTopFeatures(samples.combined, min.cutoff = 'q0') samples.combined <- RunTFIDF(samples.combined) Performing TF-IDF normalization Warning message: In RunTFIDF.default(object = GetAssayData(object = object, slot = "counts"), : Some features contain 0 total counts samples.combined <- RunSVD(samples.combined) Running SVD Scaling cell embeddings samples.combined <- RunUMAP(samples.combined, reduction = "lsi", dims = 2:30) Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation' This message will be shown once per session 21:57:50 UMAP embedding parameters a = 0.9922 b = 1.112 21:57:50 Read 7292 rows and found 29 numeric columns 21:57:50 Using Annoy for neighbor search, n_neighbors = 30 21:57:50 Building Annoy index with metric = cosine, n_trees = 50 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 21:57:51 Writing NN index file to temp file /tmp/Rtmp5xDpH6/file32fd347d49f09 21:57:51 Searching Annoy index using 1 thread, search_k = 3000 21:57:53 Annoy recall = 100% 21:57:56 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30 21:58:00 Initializing from normalized Laplacian + noise (using RSpectra) 21:58:00 Commencing optimization for 500 epochs, with 275124 positive edges Using method 'umap' 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 21:58:22 Optimization finished p1 <- DimPlot(samples.combined, group.by = "dataset") integration.anchors <- FindIntegrationAnchors(

  • object.list = list(P11, P13),
  • anchor.features = rownames(P11),
  • reduction = "rlsi",
  • dims = 2:30
  • ) Computing within dataset neighborhoods |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=02s Finding all pairwise anchors | | 0 % ~calculating Projecting new data onto SVD Projecting new data onto SVD Finding neighborhoods Finding anchors Found 25 anchors |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=04s Warning message: In CheckDuplicateCellNames(object.list = object.list) : Some cell names are duplicated across objects provided. Renaming to enforce unique cell names. integrated <- IntegrateEmbeddings(
  • anchorset = integration.anchors,
  • reductions = samples.combined[["lsi"]],
  • new.reduction.name = "integrated_lsi",
  • dims.to.integrate = 1:30,
  • k.weight = FALSE
  • ) |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows Warning: Layer counts isn't present in the assay object; returning NULL Warning: Layer counts isn't present in the assay object; returning NULL |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows |======================================================================| 100% Binding matrix rows Merging dataset 2 into 1 Extracting anchors for merged samples Finding integration vectors Finding integration vector weights 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| Integrating data Warning: Layer counts isn't present in the assay object; returning NULL integrated <- RunUMAP(integrated, reduction = "integrated_lsi", dims = 2:30) 22:10:35 UMAP embedding parameters a = 0.9922 b = 1.112 22:10:35 Read 7292 rows and found 29 numeric columns 22:10:35 Using Annoy for neighbor search, n_neighbors = 30 22:10:35 Building Annoy index with metric = cosine, n_trees = 50 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 22:10:36 Writing NN index file to temp file /tmp/Rtmp5xDpH6/file32fd31809143a 22:10:36 Searching Annoy index using 1 thread, search_k = 3000 22:10:39 Annoy recall = 100% 22:10:41 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30 22:10:46 Initializing from normalized Laplacian + noise (using RSpectra) 22:10:46 Commencing optimization for 500 epochs, with 275124 positive edges Using method 'umap' 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 22:11:08 Optimization finished p2 <- DimPlot(integrated, group.by = "dataset") png("/scratch/jmlsah001/MYDATA/dimplot_integration2.png") (p1 + ggtitle("Merged")) | (p2 + ggtitle("Integrated")) dev.off() null device 1
denvercal1234GitHub commented 2 months ago

Hi, @samuel-marsh -- The same issue was reported (open) at https://github.com/satijalab/seurat/issues/8938, which pointed to the recent upgrade of Seurat and SeuratObject.

For me, I also encountered the same issue when using escape package on Seurat object at https://github.com/ncborcherding/escape/issues/107 (roll to the end). Downgrading as suggested did not solve the error associated to this Warning.

When attempted to JoinLayer, another error happened:

> SeuratObj[["RNA"]] <- SeuratObject::JoinLayers(SeuratObj[["RNA"]])
Error in UseMethod(generic = "JoinLayers", object = object) : 
  no applicable method for 'JoinLayers' applied to an object of class "c('Assay', 'KeyMixin')"
> Layers(Tonsil_cd8_cxcr5posneg_T230T240T246.data_filtergene_filtercell_list_IndividualDatasetMERGED)
[1] "counts"     "data"       "scale.data"
methornton commented 2 months ago

Is it because the default assay was set to "SCT"?

methornton commented 2 months ago

Hello! When I change the DefaultAssay to 'RNA'. The error goes away. However, you get a mismatch error, 1: Different cells and/or features from existing assay SCT. So I guess if you do the old methods and then use SCT for integration it should work ok. Kind of a drag if you like the SCT individual data.

SaharBJ commented 2 months ago

Hi - thank you!

I am not sure what you mean? I tried changing the default assay to RNA but this did not work.

Warmly Sahar

On Fri, Aug 2, 2024 at 11:23 PM Matt Thornton @.***> wrote:

Hello! When I change the DefaultAssay to 'RNA'. The error goes away. However, you get a mismatch error, 1: Different cells and/or features from existing assay SCT. So I guess if you do the old methods and then use SCT for integration it should work ok. Kind of a drag if you like the SCT individual data.

— Reply to this email directly, view it on GitHub https://github.com/satijalab/seurat/issues/9165#issuecomment-2266160832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYM3XSIILTPHN4UUFCHNCW3ZPP2FVAVCNFSM6AAAAABLYVYSFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRWGE3DAOBTGI . You are receiving this because you authored the thread.Message ID: @.***>

methornton commented 2 months ago

Hi Sahar There is a function to prepare SCT objects for FindMarkers [PrepSCTFindMarkers] That you may need. This worked for me. Ioaded each object trom rds files.

ws_set <- merge(x = ws9, y = c(ws10, ws11, ws12, ws13, ws14), add.cell.ids = c("WS9", "WS10", "WS11", "WS12", "WS13", "WS14"), project = "WS_KID")
ws_set[["RNA"]] <- split(ws_set[["RNA"]], f = ws_set$orig.ident)
ws_set <- SCTransform(ws_set)
ws_set <- runPCA(ws_set)
ws_set <- RunPCA(ws_set)
ws_set <- RunUMAP(ws_set, dims = 1:30)
ws_set[["nonintegrated.ident"]] <- Idents(object = ws_set)
ws_set <- IntegrateLayers(object = ws_set, method = CCAIntegration, normalization.method = "SCT", verbose = T)
ws_set <- FindNeighbors(ws_set, reduction = "integrated.dr", dims = 1:30)
ws_set <- FindClusters(ws_set, modularity.fxn = 1, resolution = 1.5, method = "igraph", algorithm = 4)
ws_set$orig.ident <- factor(x = ws_set$orig.ident, levels = c("WS9", "WS10", "WS11", "WS12", "WS13", "WS14"))
ws_set <- PrepSCTFindMarkers(ws_set)
ws_set.markers <- FindAllMarkers(ws_set, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
ws_set.markers %>% group_by(cluster) %>% dplyr::filter(avg_log2FC > 1)
ws_set.markers <- as.data.frame(ws_set.markers)

I hope that helps. Good luck!

SaharBJ commented 2 months ago

I am working with snATAC-seq data