satijalab / seurat

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

Error Running scRNA-seq/scATAC-seq Vignette - Error in vapply(X = keyed.objects, FUN = function(x) { : values must be length 1, but FUN(X[[1]]) result is length 0 #6743

Closed felixm3 closed 1 year ago

felixm3 commented 1 year ago

Hello,

I’m trying to run the vignette “Integrating scRNA-seq and scATAC-seq data” https://satijalab.org/seurat/articles/atacseq_integration_vignette.html

I’m able to load both modalities.

However, when I run the next two lines:


# repeat QC steps performed in the WNN vignette
pbmc.rna <- subset(pbmc.rna, seurat_annotations != "filtered")
pbmc.atac <- subset(pbmc.atac, seurat_annotations != "filtered")

The pbcm.rna line runs fine but the pbmc.atac line has the error:

pbmc.atac <- subset(pbmc.atac, seurat_annotations != "filtered") Error in vapply(X = keyed.objects, FUN = function(x) { : values must be length 1, but FUN(X[[1]]) result is length 0

The traceback is:


10. vapply(X = keyed.objects, FUN = function(x) {
return(Key(object = object[[x]]))
}, FUN.VALUE = character(length = 1L), USE.NAMES = FALSE)
9. Key.Seurat(object = object)
8. Key(object = object)
7. FetchData.Seurat(object = object, vars = unique(x = expr.char[vars.use]), 
cells = cells, slot = slot)
6. FetchData(object = object, vars = unique(x = expr.char[vars.use]), 
cells = cells, slot = slot)
5. WhichCells.Seurat(object = x, cells = cells, idents = idents, 
expression = subset, return.null = TRUE, ...)
4. WhichCells(object = x, cells = cells, idents = idents, expression = subset, 
return.null = TRUE, ...)
3. subset.Seurat(pbmc.atac, seurat_annotations != "filtered")
2. subset(pbmc.atac, seurat_annotations != "filtered")
1. subset(pbmc.atac, seurat_annotations != "filtered")

Minimal Reproducible example


library(Seurat)
library(SeuratData)
library(Signac)
library(EnsDb.Hsapiens.v86)
library(ggplot2)
library(cowplot)

# load both modalities
pbmc.rna <- LoadData("pbmcMultiome", "pbmc.rna")
pbmc.atac <- LoadData("pbmcMultiome", "pbmc.atac")

# repeat QC steps performed in the WNN vignette
pbmc.rna <- subset(pbmc.rna, seurat_annotations != "filtered")
pbmc.atac <- subset(pbmc.atac, seurat_annotations != "filtered")

Operating system: macOS Monterey v12.6.1

Output of sessionInfo()

R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Big Sur/Monterey 10.16

Matrix products: default
LAPACK: /Users/felix.mbuga/opt/anaconda3/envs/rstud/lib/libopenblasp-r0.3.20.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] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] pbmcMultiome.SeuratData_0.1.2 pbmc3k.SeuratData_3.1.4      
 [3] ifnb.SeuratData_3.1.0         SeuratData_0.2.2             
 [5] cowplot_1.1.1                 ggplot2_3.4.0                
 [7] EnsDb.Hsapiens.v86_2.99.0     ensembldb_2.18.4             
 [9] AnnotationFilter_1.18.0       GenomicFeatures_1.46.5       
[11] AnnotationDbi_1.56.2          Biobase_2.54.0               
[13] GenomicRanges_1.46.1          GenomeInfoDb_1.30.1          
[15] IRanges_2.28.0                S4Vectors_0.32.4             
[17] BiocGenerics_0.40.0           Signac_1.8.0                 
[19] sp_1.5-0                      SeuratObject_4.1.2           
[21] Seurat_4.2.0                 

loaded via a namespace (and not attached):
  [1] rappdirs_0.3.3                rtracklayer_1.54.0           
  [3] scattermore_0.8               tidyr_1.2.1                  
  [5] bit64_4.0.5                   knitr_1.40                   
  [7] irlba_2.3.5.1                 DelayedArray_0.20.0          
  [9] data.table_1.14.4             rpart_4.1.16                 
 [11] KEGGREST_1.34.0               RCurl_1.98-1.9               
 [13] generics_0.1.3                ScaledMatrix_1.2.0           
 [15] RSQLite_2.2.18                RANN_2.6.1                   
 [17] proxy_0.4-27                  future_1.29.0                
 [19] bit_4.0.4                     tzdb_0.3.0                   
 [21] msigdbi_1.0.0                 spatstat.data_2.2-0          
 [23] xml2_1.3.3                    httpuv_1.6.6                 
 [25] SummarizedExperiment_1.24.0   assertthat_0.2.1             
 [27] viridis_0.6.2                 xfun_0.33                    
 [29] celldex_1.4.0                 hms_1.1.2                    
 [31] jquerylib_0.1.4               babelgene_22.9               
 [33] evaluate_0.16                 promises_1.2.0.1             
 [35] restfulr_0.0.15               fansi_1.0.3                  
 [37] progress_1.2.2                caTools_1.18.2               
 [39] dbplyr_2.2.1                  igraph_1.3.5                 
 [41] DBI_1.1.3                     htmlwidgets_1.5.4            
 [43] spatstat.geom_2.4-0           purrr_0.3.5                  
 [45] ellipsis_0.3.2                dplyr_1.0.10                 
 [47] annotate_1.72.0               biomaRt_2.50.3               
 [49] deldir_1.0-6                  sparseMatrixStats_1.6.0      
 [51] MatrixGenerics_1.6.0          vctrs_0.5.0                  
 [53] SingleCellExperiment_1.16.0   ROCR_1.0-11                  
 [55] abind_1.4-5                   withr_2.5.0                  
 [57] cachem_1.0.6                  progressr_0.11.0             
 [59] googleVis_0.7.0               sctransform_0.3.5            
 [61] GenomicAlignments_1.30.0      prettyunits_1.1.1            
 [63] goftest_1.2-3                 cluster_2.1.4                
 [65] ExperimentHub_2.2.1           ape_5.6-2                    
 [67] lazyeval_0.2.2                crayon_1.5.2                 
 [69] pkgconfig_2.0.3               ProtGenerics_1.26.0          
 [71] nlme_3.1-159                  vipor_0.4.5                  
 [73] rlang_1.0.6                   globals_0.16.1               
 [75] lifecycle_1.0.3               miniUI_0.1.1.1               
 [77] colourpicker_1.2.0            filelock_1.0.2               
 [79] BiocFileCache_2.2.1           rsvd_1.0.5                   
 [81] AnnotationHub_3.2.2           randomForest_4.7-1.1         
 [83] polyclip_1.10-0               GSVA_1.42.0                  
 [85] matrixStats_0.62.0            lmtest_0.9-40                
 [87] shinyFiles_0.9.3              graph_1.72.0                 
 [89] Matrix_1.5-1                  Rhdf5lib_1.16.0              
 [91] zoo_1.8-11                    beeswarm_0.4.0               
 [93] SingleR_1.8.1                 ggridges_0.5.3               
 [95] rjson_0.2.21                  png_0.1-7                    
 [97] viridisLite_0.4.1             bitops_1.0-7                 
 [99] shinydashboard_0.7.2          KernSmooth_2.23-20           
[101] rhdf5filters_1.6.0            Biostrings_2.62.0            
[103] blob_1.2.3                    DelayedMatrixStats_1.16.0    
[105] stringr_1.4.1                 qvalue_2.26.0                
[107] parallelly_1.32.1             spatstat.random_2.2-0        
[109] readr_2.1.3                   beachmat_2.10.0              
[111] scales_1.2.1                  memoise_2.0.1                
[113] GSEABase_1.56.0               magrittr_2.0.3               
[115] plyr_1.8.8                    ica_1.0-3                    
[117] gplots_3.1.3                  zlibbioc_1.40.0              
[119] compiler_4.1.3                BiocIO_1.4.0                 
[121] RColorBrewer_1.1-3            fitdistrplus_1.1-8           
[123] Rsamtools_2.10.0              cli_3.4.1                    
[125] XVector_0.34.0                listenv_0.8.0                
[127] patchwork_1.1.2               pbapply_1.5-0                
[129] MASS_7.3-58.1                 mgcv_1.8-40                  
[131] tidyselect_1.2.0              stringi_1.7.8                
[133] yaml_2.3.6                    BiocSingular_1.10.0          
[135] ggrepel_0.9.1                 grid_4.1.3                   
[137] sass_0.4.2                    fastmatch_1.1-3              
[139] tools_4.1.3                   future.apply_1.10.0          
[141] parallel_4.1.3                rstudioapi_0.14              
[143] SCINA_1.2.0                   gridExtra_2.3                
[145] Rtsne_0.16                    digest_0.6.30                
[147] BiocManager_1.30.18           rgeos_0.5-9                  
[149] shiny_1.7.3                   Rcpp_1.0.9                   
[151] scuttle_1.4.0                 BiocVersion_3.14.0           
[153] later_1.3.0                   harmony_0.1.1                
[155] RcppAnnoy_0.0.19              shinyWidgets_0.7.4           
[157] httr_1.4.4                    colorspace_2.0-3             
[159] fs_1.5.2                      XML_3.99-0.12                
[161] tensor_1.5                    reticulate_1.26              
[163] splines_4.1.3                 RcppRoll_0.3.0               
[165] uwot_0.1.14                   spatstat.utils_2.3-1         
[167] scater_1.22.0                 plotly_4.10.1                
[169] xtable_1.8-4                  jsonlite_1.8.3               
[171] scmap_1.16.0                  R6_2.5.1                     
[173] pillar_1.8.1                  htmltools_0.5.3              
[175] mime_0.12                     glue_1.6.2                   
[177] fastmap_1.1.0                 DT_0.26                      
[179] BiocParallel_1.28.3           BiocNeighbors_1.12.0         
[181] class_7.3-20                  interactiveDisplayBase_1.32.0
[183] codetools_0.2-18              utf8_1.2.2                   
[185] lattice_0.20-45               bslib_0.4.1                  
[187] spatstat.sparse_2.1-1         tibble_3.1.8                 
[189] cerebroApp_1.3.1              curl_4.3.3                   
[191] ggbeeswarm_0.6.0              leiden_0.4.3                 
[193] gtools_3.9.3                  shinyjs_2.1.0                
[195] survival_3.4-0                rmarkdown_2.16               
[197] munsell_0.5.0                 e1071_1.7-11                 
[199] rhdf5_2.38.1                  GenomeInfoDbData_1.2.7       
[201] HDF5Array_1.22.1              shinycssloaders_1.0.0        
[203] reshape2_1.4.4                gtable_0.3.1                 
[205] msigdbr_7.5.1                 spatstat.core_2.4-4          

R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
timoast commented 1 year ago

This is due to a missing key in the ATAC object stored in SeuratData. @mojaveazure maybe we can update this?

In the meantime, it can be fixed by running UpdateSeuratObject():

pbmc.atac <- UpdateSeuratObject(pbmc.atac)
AustinHartman commented 1 year ago

pbmcMultiome has been updated in SeuratData - please make sure to first remove the dataset before installing the updated object

RemoveData("pbmcMultiome")
InstallData("pbmcMultiome")
felixm3 commented 1 year ago

This works now.

Thanks!

JeremyCCChen commented 1 year ago

ANOTHER EXPERIENCE

I got the same error mentioned in the issue title when I ran SCTransform on a S4 and a S3 Seurat subject. But luckily, running UpdateSeuratObject as @timoast commented before running SCTransform fixed the error.

This is due to a missing key in the ATAC object stored in SeuratData. @mojaveazure maybe we can update this?

In the meantime, it can be fixed by running UpdateSeuratObject():

pbmc.atac <- UpdateSeuratObject(pbmc.atac)