satijalab / seurat

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

Issue with RunBanksy and SpatialDimPlot #9303

Closed tingchiafelix closed 1 month ago

tingchiafelix commented 2 months ago

Hi, I’m new to processing 10x Visium HD data and have been following the Seurat Visium HD workflow without any issues until I reached the "RunBanksy" step. At this point, I received a warning message: “Layer counts isn't present in the assay object; returning NULL.”

I found a related discussion in ticket #8938 about this warning, but it doesn't specifically address "RunBanksy." I'm unsure if this will lead to any problems, though RunPCA, FindNeighbors, and FindClusters seem to work without errors.

However, when I tried to run "SpatialDimPlot," I encountered an error: "ERROR while rich displaying an object: Error in Ops.data.frame(guide_loc, panel_loc)."

I came across a potential solution in a ggplot2 ticket (https://github.com/tidyverse/ggplot2/issues/5619), which suggested setting specific versions of ggplot2 and patchwork, but this didn’t resolve the issue for me.

I’ve included my script and the error messages below. Any suggestions or insights would be greatly appreciated!

object <- RunBanksy(object,
  lambda = 0.8, verbose = TRUE,
  assay = "Spatial", slot = "data", features = "variable",
  k_geom = 50
)

################
Creating Banksy matrix

Scaling BANKSY matrix. Do not call ScaleData on assay BANKSY

Setting default assay to BANKSY

Warning message:
“Layer counts isn't present in the assay object; returning NULL”
################
DefaultAssay(object) <- "BANKSY"
object <- RunPCA(object, assay = "BANKSY", reduction.name = "pca.banksy", features = rownames(object), npcs = 30)
object <- FindNeighbors(object, reduction = "pca.banksy", dims = 1:30)
object <- FindClusters(object, cluster.name = "banksy_cluster", resolution = 0.5)

#################
Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 234204
Number of edges: 5358313

Running Louvain algorithm...
Maximum modularity in 10 random starts: 0.9564
Number of communities: 42
Elapsed time: 42 seconds
#################
Idents(object) <- "banksy_cluster"
p <- SpatialDimPlot(object, group.by = "banksy_cluster", label = T, repel = T, label.size = 4)
p

###############
Scale for fill is already present.
Adding another scale for fill, which will replace the existing scale.
ERROR while rich displaying an object: Error in Ops.data.frame(guide_loc, panel_loc): ‘==’ only defined for equally-sized data frames
################

SessionInfo()

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

other attached packages:
 [1] cowplot_1.1.2               scater_1.30.1              
 [3] scuttle_1.12.0              SpatialExperiment_1.12.0   
 [5] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0
 [7] Biobase_2.62.0              GenomicRanges_1.54.1       
 [9] GenomeInfoDb_1.38.8         IRanges_2.36.0             
[11] S4Vectors_0.40.2            BiocGenerics_0.48.1        
[13] MatrixGenerics_1.14.0       matrixStats_1.3.0          
[15] SeuratWrappers_0.3.5        Banksy_0.99.13             
[17] dplyr_1.1.4                 patchwork_1.1.3            
[19] ggplot2_3.5.1               Seurat_5.1.0               
[21] SeuratObject_5.0.2          sp_2.1-2                   

loaded via a namespace (and not attached):
  [1] RcppHungarian_0.3         RcppAnnoy_0.0.21         
  [3] splines_4.3.3             later_1.3.2              
  [5] pbdZMQ_0.3-11             bitops_1.0-7             
  [7] tibble_3.2.1              R.oo_1.26.0              
  [9] polyclip_1.10-6           fastDummies_1.7.3        
 [11] lifecycle_1.0.4           aricode_1.0.3            
 [13] globals_0.16.3            lattice_0.22-6           
 [15] MASS_7.3-60.0.1           magrittr_2.0.3           
 [17] plotly_4.10.4             remotes_2.5.0            
 [19] httpuv_1.6.12             sctransform_0.4.1        
 [21] spam_2.10-0               spatstat.sparse_3.0-3    
 [23] reticulate_1.34.0         pbapply_1.7-2            
 [25] RColorBrewer_1.1-3        abind_1.4-5              
 [27] zlibbioc_1.48.2           Rtsne_0.17               
 [29] purrr_1.0.2               R.utils_2.12.3           
 [31] RCurl_1.98-1.14           GenomeInfoDbData_1.2.11  
 [33] ggrepel_0.9.4             irlba_2.3.5.1            
 [35] listenv_0.9.1             spatstat.utils_3.0-4     
 [37] goftest_1.2-3             RSpectra_0.16-1          
 [39] spatstat.random_3.2-2     fitdistrplus_1.1-11      
 [41] parallelly_1.38.0         DelayedMatrixStats_1.24.0
 [43] leiden_0.4.3.1            codetools_0.2-20         
 [45] DelayedArray_0.28.0       tidyselect_1.2.1         
 [47] farver_2.1.2              viridis_0.6.5            
 [49] ScaledMatrix_1.10.0       base64enc_0.1-3          
 [51] spatstat.explore_3.2-5    jsonlite_1.8.8           
 [53] BiocNeighbors_1.20.0      progressr_0.14.0         
 [55] ggridges_0.5.5            survival_3.7-0           
 [57] dbscan_1.2-0              tools_4.3.3              
 [59] ica_1.0-3                 Rcpp_1.0.12              
 [61] glue_1.7.0                gridExtra_2.3            
 [63] SparseArray_1.2.4         IRdisplay_1.1            
 [65] withr_3.0.0               BiocManager_1.30.23      
 [67] fastmap_1.2.0             fansi_1.0.6              
 [69] digest_0.6.36             rsvd_1.0.5               
 [71] R6_2.5.1                  mime_0.12                
 [73] colorspace_2.1-0          scattermore_1.2          
 [75] sccore_1.0.5              tensor_1.5               
 [77] spatstat.data_3.0-3       R.methodsS3_1.8.2        
 [79] utf8_1.2.4                tidyr_1.3.1              
 [81] generics_0.1.3            data.table_1.15.4        
 [83] httr_1.4.7                htmlwidgets_1.6.4        
 [85] S4Arrays_1.2.1            uwot_0.1.16              
 [87] pkgconfig_2.0.3           gtable_0.3.5             
 [89] lmtest_0.9-40             XVector_0.42.0           
 [91] htmltools_0.5.7           dotCall64_1.1-1          
 [93] scales_1.3.0              png_0.1-8                
 [95] reshape2_1.4.4            rjson_0.2.21             
 [97] uuid_1.2-1                nlme_3.1-165             
 [99] repr_1.1.7                zoo_1.8-12               
[101] stringr_1.5.1             KernSmooth_2.23-24       
[103] vipor_0.4.7               parallel_4.3.3           
[105] miniUI_0.1.1.1            pillar_1.9.0             
[107] grid_4.3.3                vctrs_0.6.4              
[109] RANN_2.6.1                promises_1.3.0           
[111] BiocSingular_1.18.0       beachmat_2.18.1          
[113] xtable_1.8-4              cluster_2.1.6            
[115] beeswarm_0.4.0            evaluate_0.24.0          
[117] magick_2.8.3              cli_3.6.3                
[119] compiler_4.3.3            rlang_1.1.2              
[121] crayon_1.5.3              future.apply_1.11.2      
[123] labeling_0.4.3            mclust_6.1.1             
[125] ggbeeswarm_0.7.2          plyr_1.8.9               
[127] stringi_1.8.1             viridisLite_0.4.2        
[129] deldir_2.0-4              BiocParallel_1.36.0      
[131] munsell_0.5.1             lazyeval_0.2.2           
[133] spatstat.geom_3.2-7       Matrix_1.6-5             
[135] IRkernel_1.3.2            RcppHNSW_0.5.0           
[137] sparseMatrixStats_1.14.0  future_1.34.0            
[139] shiny_1.8.1.1             ROCR_1.0-11              
[141] leidenAlg_1.1.3           igraph_1.6.0             
Bram-Bussin commented 2 months ago

I ran into the same issue, have you resolved it?

tingchiafelix commented 2 months ago

Unfortunately, I haven't found a solution yet.

liyiwang0725 commented 2 months ago

I meet the same issue, have you solved it now?

Bram-Bussin commented 2 months ago

No, not yet

rmc0106 commented 2 months ago

I am facing the same issue after running DimPlot(): Error in Ops.data.frame(guide_loc, panel_loc) : ‘==’ only defined for equally-sized data frames

jpfry327 commented 1 month ago

I had this same issue within Seurat, and both updating ggplot2 and updating patchwork via remotes::install_github("thomasp85/patchwork") worked for me.

liyiwang0725 commented 1 month ago

I had this same issue within Seurat, and both updating ggplot2 and updating patchwork via remotes::install_github("thomasp85/patchwork") worked for me.

Thank you so much! It also worked for me.

samuel-marsh commented 1 month ago

Sounds like this is resolved with updating to newer versions of ggplot2 and patchwork. Closing issue.