navinlabcode / CellTrek

95 stars 18 forks source link

Failed to visualize the ST data, error returns "Error in SpatialPlot(object = object, group.by = group.by, images = images, : Could not find any spatial image information" #35

Closed 14MBD4 closed 8 months ago

14MBD4 commented 8 months ago

After I successfully load rds file usingh_st <- readRDS("cellbin.gef.rds") and rename it using h_st <- RenameCells(h_st, new.names=make.names(Cells(h_st))), with instruction h_st in the terminal Radian shows as follow:

An object of class Seurat 26758 features across 79270 samples within 1 assay Active assay: RNA (26758 features, 0 variable features) 2 layers present: counts, data 1 dimensional reduction calculated: spatial

_There is something weird when I try to run SpatialDimPlot(h_st)_. The error says:

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

And the error also occurs when I using h_st <- readRDS("tissue.gef.rds") with same terminal returned info


Additional info: The tissuebin and cellbin files are both converted by follow program(h5ad2rdsutil.R):

library(sceasy)

args = commandArgs(trailingOnly = TRUE) source_file = args[1] samename_aim_file = args[2]

sceasy::convertFormat(source_file,from="anndata",to="seurat",outFile=samename_aim_file)

I ran this in terminal by Rscript h5ad2rdsutil.R cellbin.gef.h5ad cellbin.gef.rds and Rscript h5ad2rdsutil.R tissue.gef.h5ad tissue.gef.rds

If there is a need for how h5ad files are generated, here is the program(readGEFutil.py) with stereopy0.13.0b1:

import sys import stereo as st import re import os

assert len(sys.argv) == 4 _,mode,gef_file_path,aim_path = sys.argv assert mode in ['tissuebin','cellbin']

if mode == 'tissuebin' and re.search(r"tissue.gef$",os.path.basename(gef_file_path)) is not None: data = st.io.read_gef(file_path=gef_file_path,bin_size=100) data.tl.raw_checkpoint() adata=st.io.stereo_to_anndata(data,flavor='seurat') adata.write_h5ad(aim_path+'/'+os.path.basename(gef_file_path)+'.h5ad')

if mode == 'cellbin' and re.search(r"cellbin.gef$",os.path.basename(gef_file_path)) is not None: data = st.io.read_gef(file_path=gef_file_path,bin_type='cell_bins') data.tl.raw_checkpoint() adata=st.io.stereo_to_anndata(data,flavor='seurat') adata.write_h5ad(aim_path+'/'+os.path.basename(gef_file_path)+'.h5ad')

I ran this in terminal by python readGEFutil.py cellbin cellbin.gef aim_path/ and python readGEFutil.py tissue.gef aim_path/

14MBD4 commented 8 months ago

I successfully use Rscript annh5ad2rds.R --infile sourcefile --outfile outfile convert the h5ad generated from GEF into rds file. The annh5ad2rds.R is provided by stereopy. It is my guess maybe sceasy::convertFormat(source_file,from="anndata",to="seurat",outFile=samename_aim_file) from sceasy do not support the h5ad generated from GEF format. Better to use stereopy own api will avoid abnormal situations.