satijalab / seurat

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

Load10X_Spatial 'Slide1' missing #4885

Closed pschnepp closed 3 years ago

pschnepp commented 3 years ago

I'm working with some Visium files after processing with SpaceRanger. However, when I try to load my data into Seurat using Load10X_Spatial(), I'm getting an error. Any idea on how to fix this error would be greatly appreciated.

Slide1-A<-Load10X_Spatial("/path/to/data/",filename = "filtered_feature_bc_matrix.h5",assay = "Spatial",filter.matrix = T,slice = "slice2")
Error in Slide1 - A <- Load10X_Spatial("/path/to/data/",  : 
  object 'Slide1' not found
In addition: Warning message:
In sparseMatrix(i = indices[] + 1, p = indptr[], x = as.numeric(x = counts[]),  :
  'giveCsparse' has been deprecated; setting 'repr = "T"' for you

I've tried playing around with the slice option (and also letting it be the default 'slice1') but I keep getting this error.

I've also tried to follow the work around with the Slide-Seq dataset from the Seurat vignette. However, when I try to plot nFeature_Spatial over the image, I can see the spots but no tissue image underneath. Not sure where I'm missing adding in that image, But I've include my code where I changed the Slide-Seq code to fit my 10X dataset. Any idea where the image should be attached or what I'm missing would be greatly appreciated.

test.data<-Read10X("/path/to/data/filtered_feature_bc_matrix/")
Slide_test<-CreateSeuratObject(test.data,assay = "Spatial",project = "Slide1-a")
positions<-read.csv("/path/to/data/spatial/tissue_positions_list.csv",row.names = 1,header = F)
positions<-positions[,2:3]
colnames(positions)<-c("imagerow","imagecol")
sfactors<-scalefactors(spot = 211.67412999999993, hires = 0.06336533, fiducial = 341.93515, lowres =  0.0190096)
test_image<-new(Class = "VisiumV1",assay = "Spatial",coordinates = positions,scale.factors = sfactors,image = readPNG("/path/to/data/tissue_lowres_image.png"),spot.radius = 0.0190096/5)
common.cells<-intersect(Cells(x=Slide_test),rownames(test_image@coordinates))
image.data<-test_image[common.cells]
DefaultAssay(Slide_test)<-"Spatial"
Slide_test@images$image<-image.data
SpatialFeaturePlot(Slide_test,features = "nFeature_Spatial")

Here's my SessionInfo()

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /sw/arcts/centos7/stacks/gcc/8.2.0/R/4.0.3/lib64/R/lib/libRblas.so
LAPACK: /sw/arcts/centos7/stacks/gcc/8.2.0/R/4.0.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    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] ssHippo.SeuratData_3.1.4 SeuratData_0.2.1         png_0.1-7                hdf5r_1.3.3             
[5] SeuratObject_4.0.2       Seurat_4.0.1            

loaded via a namespace (and not attached):
  [1] nlme_3.1-149          matrixStats_0.59.0    spatstat.sparse_2.0-0 bit64_4.0.5           RcppAnnoy_0.0.18     
  [6] RColorBrewer_1.1-2    httr_1.4.2            sctransform_0.3.2     tools_4.0.3           utf8_1.2.1           
 [11] R6_2.5.0              irlba_2.3.3           rpart_4.1-15          KernSmooth_2.23-17    uwot_0.1.10          
 [16] mgcv_1.8-33           lazyeval_0.2.2        colorspace_2.0-1      tidyselect_1.1.1      gridExtra_2.3        
 [21] bit_4.0.4             compiler_4.0.3        cli_3.0.1             plotly_4.9.3          labeling_0.4.2       
 [26] scales_1.1.1          lmtest_0.9-38         spatstat.data_2.1-0   ggridges_0.5.3        pbapply_1.4-3        
 [31] rappdirs_0.3.3        goftest_1.2-2         stringr_1.4.0         digest_0.6.27         spatstat.utils_2.1-0 
 [36] pkgconfig_2.0.3       htmltools_0.5.1.1     parallelly_1.25.0     fastmap_1.1.0         htmlwidgets_1.5.3    
 [41] rlang_0.4.11          rstudioapi_0.13       shiny_1.6.0           farver_2.1.0          generics_0.1.0       
 [46] zoo_1.8-9             jsonlite_1.7.2        ica_1.0-2             dplyr_1.0.6           magrittr_2.0.1       
 [51] patchwork_1.1.1       Matrix_1.3-4          Rcpp_1.0.6            munsell_0.5.0         fansi_0.4.2          
 [56] abind_1.4-5           reticulate_1.20       lifecycle_1.0.0       stringi_1.6.2         MASS_7.3-53          
 [61] Rtsne_0.15            plyr_1.8.6            grid_4.0.3            parallel_4.0.3        listenv_0.8.0        
 [66] promises_1.2.0.1      ggrepel_0.9.1         crayon_1.4.1          miniUI_0.1.1.1        deldir_0.2-10        
 [71] lattice_0.20-41       cowplot_1.1.1         splines_4.0.3         tensor_1.5            pillar_1.6.1         
 [76] igraph_1.2.6          spatstat.geom_2.1-0   future.apply_1.7.0    reshape2_1.4.4        codetools_0.2-16     
 [81] leiden_0.3.7          glue_1.4.2            data.table_1.14.0     vctrs_0.3.8           httpuv_1.6.1         
 [86] gtable_0.3.0          RANN_2.6.1            purrr_0.3.4           spatstat.core_2.1-2   polyclip_1.10-0      
 [91] tidyr_1.1.3           scattermore_0.7       future_1.21.0         ggplot2_3.3.3         mime_0.10            
 [96] xtable_1.8-4          later_1.2.0           survival_3.2-7        viridisLite_0.4.0     tibble_3.1.2         
[101] cluster_2.1.0         globals_0.14.0        fitdistrplus_1.1-5    ellipsis_0.3.2        ROCR_1.0-11   
samuel-marsh commented 3 years ago

Hi,

Not member of the dev team but hopefully can be helpful. The reason for the error you are describing is due to syntax/naming in R. You can't have - in variable name because R takes that as a minus sign. If you change the name to Slide1_A then it should resolve that error.

Best, Sam

pschnepp commented 3 years ago

Thanks so much Sam! I didn't realize the '-' sign in the name would cause the issue. It's working now. Thanks!

samuel-marsh commented 3 years ago

Happy to help!