STOmics / Stereopy

A toolkit of spatial transcriptomic analysis.
MIT License
193 stars 64 forks source link

Error in SpatialPlot(object = object, features = features, images = images, : Could not find any spatial image information #288

Closed MatteoRiva95 closed 4 months ago

MatteoRiva95 commented 4 months ago

Hello everyone,

I am trying to visualize the file SS200000135TL_D1.h5ad (https://db.cngb.org/stomics/datasets/STDS0000234) in Rstudio using Seurat. In order to be clear, what I did is:

1) Download the .h5ad file from the link above 2) Following the tutorial page https://stereopy.readthedocs.io/en/latest/Tutorials/Format_Conversion.html , I wanted to convert the .h5ad file in a .rds file in order to see it in RStudio and work with it using Seurat 3) I ran the command Rscript h5ad2rds.R --infile --outfile and I obtained the file SS200000135TL_D1.rds. Here is the output message:

Attaching package: ‘dplyr’

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

filter, lag

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

intersect, setdiff, setequal, union

Loading required package: SeuratObject Loading required package: sp

Attaching package: ‘SeuratObject’

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

%||%, intersect, t

Attaching package: ‘Seurat’

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

%||%

Registered S3 method overwritten by 'SeuratDisk': method from as.sparse.H5Group Seurat Warning: Unknown file type: h5ad Creating h5Seurat file for version 3.1.5.9900 Adding X as data Adding raw/X as counts Adding meta.features from raw/var Adding X_pca as cell embeddings for pca Adding X_umap as cell embeddings for umap Adding spatial as cell embeddings for spatial Adding sn to miscellaneous data [1] "Finished! Converting h5ad to h5seurat file at:" [2] "./SS200000135TLD1.h5seurat" [1] "h5seurat time consuming: 1.978" Validating h5Seurat file Initializing Spatial with data Adding counts for Spatial Adding feature-level metadata for Spatial Adding reduction pca Adding cell embeddings for pca Adding miscellaneous information for pca Adding reduction spatial Adding cell embeddings for spatial Adding miscellaneous information for spatial Adding reduction umap Adding cell embeddings for umap Adding miscellaneous information for umap Adding command information Adding cell-level metadata Adding tool-specific results Warning message: Key ‘spatial’ taken, using ‘lxkaz_’ instead [1] "Successfully load h5seurat:" "./SS200000135TL_D1.h5seurat"

Attaching package: ‘rhdf5’

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

h5version

[1] "rds time consuming: 11.011" [1] "Start to saveRDS..." [1] "Finished RDS."

4) Here comes the issue: when I try to visualize this .rds file with a simple Seurat::SpatialFeaturePlot (stereo.seq, features="n_genes_by_counts") + theme(legend.position="right") (taken from the spatial tutorial in Seurat), it gives me back this error

Error in SpatialPlot(object = object, features = features, images = images, : Could not find any spatial image information

What am I missing? Do you know how to see this spatial .rds file? Am I giving the wrong features parameter?

Thank you so much in advance for your help!

tanliwei-genomics-cn commented 4 months ago

Sorry, our data files don't contain image, so the converted RDS will also have no image, I am not familiar with Seurat, I don't know whether SpatialPlot can be ran without image, I am so sorry.

MatteoRiva95 commented 4 months ago

@tanliwei-genomics-cn Thank you for your fast and kind reply!

Just a question: do you mean that this particular .h5ad file does not have an image or instead that all Stereo-Seq output files (also .gem and .gef) do not have an image?

Finally, could you kindly tell me where I can find .gem or .gef example files? I searched for them in the past days, but I found only .h5ad file from https://db.cngb.org/stomics/datasets/

tanliwei-genomics-cn commented 4 months ago

Yes, Stereo-Seq files GEM and GEF are the source data of our analysis, currently, there are no any images in them, h5ad is converted from GEM or GEF and then RDS is converted from this h5ad, so the h5ad and rds also have no image.

You can get GEM and GEF example file from our network disk, going into Stereopy_Demo_Data/Demo_MouseBrain you can see what you want.

lvmt commented 4 months ago

格式转换出现无法成功

我用SAW流程分析得到的gef https://stereopy.readthedocs.io/en/latest/Tutorials/Format_Conversion.html

按照上述教程,先将gef文件转为h5ad,这一步可以成功

但是h5ad2rds报错,错误情况如下所示

Attaching SeuratObject
Seurat v4 was just loaded with SeuratObject v5; disabling v5 assays and
validation routines, and ensuring assays work in strict v3/v4
compatibility mode
Registered S3 method overwritten by 'SeuratDisk':
  method            from  
  as.sparse.H5Group Seurat
Error in as.vector(x, "character") : 
  cannot coerce type 'environment' to vector of type 'character'
Calls: <Anonymous> ... sprintf -> paste -> as.character -> as.character.default
Execution halted