STOmics / Stereopy

A toolkit of spatial transcriptomic analysis.
MIT License
179 stars 59 forks source link

cellbin.gef could not convert to seurat object #268

Closed leogg738 closed 2 months ago

leogg738 commented 2 months ago

I used the newest h5ad2rds.R to convert cellbin.gef, but it did not work. However, the script can convert tissue.gef to seurat object.

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

The legacy packages maptools, rgdal, and rgeos, underpinning the sp package, which was just loaded, will retire in October 2023. Please refer to R-spatial evolution reports for details, especially https://r-spatial.org/r/2023/05/15/evolution4.html. It may be desirable to make the sf package available; package maintainers should consider adding sf to Suggests:. The sp package is now running under evolution status 2 (status 2 uses the sf package in place of rgdal) Attaching SeuratObject 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 X as counts Adding meta.features from 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 gene_exp_leiden to miscellaneous data Adding hvg to miscellaneous data Adding raw_cellname to miscellaneous data Adding raw_counts to miscellaneous data Adding raw_genename to miscellaneous data Adding sn to miscellaneous data [1] "Finished! Converting h5ad to h5seurat file at:" [2] "./seurat_out.h5seurat"
[1] "h5seurat time consuming: 62.705" Validating h5Seurat file Initializing Spatial with data Adding counts for Spatial Adding feature-level metadata for Spatial Error: Missing required datasets 'levels' and 'values' Execution halted

tanliwei-coder commented 2 months ago

Which version stereopy are you using?

leogg738 commented 2 months ago

My stoeropy version is 1.2.0 and My conda environments are below: Package Version


aiohttp 3.9.5 aiosignal 1.3.1 alabaster 0.7.13 angelcommunity 2.0.0 anndata 0.9.2 arboreto 0.1.6 asciitree 0.3.3 asttokens 2.4.1 async-timeout 4.0.3 attrs 23.2.0 Babel 2.14.0 backcall 0.2.0 bimlpa 0.1.2 biopython 1.83 bleach 6.1.0 blosc2 2.0.0 bokeh 2.4.3 boltons 24.0.0 bypy 1.8.4 cdlib 0.3.0 cell-bin 1.3.4.1 certifi 2024.2.2 cffi 1.16.0 cfgv 3.4.0 charset-normalizer 3.3.2 click 8.1.7 cloudpickle 3.0.0 colorcet 3.1.0 coloredlogs 15.0.1 comm 0.2.2 contourpy 1.1.1 ctxcore 0.2.0 cusingler 1.1.0 cycler 0.12.1 Cython 3.0.10 cytoolz 0.12.3 dask 2023.5.0 dask-image 2023.3.0 datashader 0.15.2 datashape 0.5.2 debugpy 1.8.1 decorator 5.1.1 demon 2.0.6 dill 0.3.8 distinctipy 1.3.4 distlib 0.3.8 distributed 2023.5.0 docrep 0.3.2 docutils 0.20.1 dunamai 1.20.0 dynamo-release 1.4.0 dynetx 0.3.2 et-xmlfile 1.1.0 eva-lcd 0.1.1 executing 2.0.1 fastcluster 1.2.6 fasteners 0.19 fbpca 1.0 filelock 3.13.4 flatbuffers 24.3.25 fonttools 4.51.0 frozendict 2.4.2 frozenlist 1.4.1 fsspec 2024.3.1 future 1.0.0 gefpy 1.1.3 geojson 3.1.0 geosketch 1.2 get-annotations 0.1.2 get_version 3.5.4 gtfparse 1.2.1 h5py 3.8.0 harmonypy 0.0.6 holoviews 1.17.1 hotspotsc 1.1.1 humanfriendly 10.0 hvplot 0.9.2 identify 2.5.36 idna 3.7 igraph 0.11.4 imagecodecs 2023.3.16 imageio 2.31.1 imagesize 1.4.1 importlib_metadata 7.1.0 importlib_resources 6.4.0 inflect 7.2.1 interlap 0.2.7 ipykernel 6.29.4 ipython 8.12.3 jedi 0.19.1 Jinja2 3.1.3 joblib 1.4.0 joypy 0.2.6 jupyter_client 8.6.1 jupyter_core 5.7.2 KDEpy 1.1.0 kiwisolver 1.4.5 lazy_loader 0.4 leidenalg 0.10.2 Levenshtein 0.25.1 llvmlite 0.39.1 locket 1.0.0 loompy 3.0.7 louvain 0.8.0 lxml 5.2.1 lz4 4.3.3 Markdown 3.6 markov-clustering 0.0.6.dev0 MarkupSafe 2.1.5 matplotlib 3.7.1 matplotlib-inline 0.1.7 matplotlib-scalebar 0.8.1 more-itertools 10.2.0 mpmath 1.3.0 msgpack 1.0.8 multidict 6.0.5 multipledispatch 1.0.0 multiprocess 0.70.16 multiprocessing_on_dill 3.5.0a4 natsort 7.1.1 nest-asyncio 1.6.0 networkx 3.1 nf1 0.0.4 nodeenv 1.8.0 numba 0.56.4 numcodecs 0.12.1 numdifftools 0.9.41 numexpr 2.8.6 numpy 1.23.5 numpy_groupies 0.9.22 omnipath 1.0.8 onnxruntime 1.15.1 opencv-python 4.8.0.76 openpyxl 3.1.2 packaging 24.0 pandas 1.5.3 panel 0.14.4 param 1.13.0 parso 0.8.4 partd 1.4.1 patsy 0.5.6 pexpect 4.9.0 PhenoGraph 1.5.7 pickleshare 0.7.5 pillow 10.3.0 PIMS 0.6.1 pip 24.0 platformdirs 4.2.1 plotly 5.21.0 pooch 1.8.1 POT 0.8.1.0 pre-commit 3.5.0 prompt-toolkit 3.0.43 protobuf 5.26.1 psutil 5.9.8 ptyprocess 0.7.0 PuLP 2.8.0 pure-eval 0.2.2 py-cpuinfo 9.0.0 pyarrow 16.0.0 pyCirclize 1.4.0 pycparser 2.22 pyct 0.5.0 Pygments 2.17.2 pynndescent 0.5.12 pyparsing 3.1.2 pyscenic 0.12.1 python-dateutil 2.9.0.post0 python-igraph 0.11.4 python-Levenshtein 0.25.1 python-louvain 0.16 pytz 2024.1 pyvips 2.2.1 pyviz_comms 3.0.2 PyWavelets 1.4.1 PyYAML 6.0.1 pyzmq 26.0.2 rapidfuzz 3.8.1 requests 2.31.0 requests-toolbelt 1.0.0 retrying 1.3.4 scanpy 1.9.6 scikit-image 0.21.0 scikit-learn 1.3.0 scipy 1.10.1 seaborn 0.12.2 session_info 1.0.0 setuptools 69.5.1 shapely 2.0.4 six 1.16.0 slicerator 1.1.0 slideio 2.5.0 snowballstemmer 2.2.0 sortedcontainers 2.4.0 spatialpandas 0.4.9 Sphinx 7.1.2 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.1 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.5 SQLAlchemy 1.3.24 squidpy 1.2.2 stack-data 0.6.3 statsmodels 0.14.1 stdlib-list 0.10.0 stereopy 1.2.0 sympy 1.12 tables 3.8.0 tblib 3.0.0 tenacity 8.2.3 texttable 1.7.0 threadpoolctl 3.4.0 thresholdclustering 1.1 tifffile 2023.2.3 toolz 0.12.1 tornado 6.4 tqdm 4.65.0 traitlets 5.14.3 typeguard 4.2.1 typing_extensions 4.11.0 umap-learn 0.5.1 urllib3 2.1.0 validators 0.28.1 virtualenv 20.26.0 wcwidth 0.2.13 webencodings 0.5.1 wheel 0.43.0 wrapt 1.16.0 xarray 0.20.1 yarl 1.9.4 zarr 2.16.1 zict 3.0.0 zipp 3.18.1

tanliwei-coder commented 2 months ago

The environment seems to have nothing wrong, show me the codes with that you used to generate h5ad file.

tanliwei-coder commented 2 months ago

Another possible reason is an incompatible version of R, you can try to do mentioned in issue #261 .

maximelepetit commented 2 months ago

I have the same issue using environment provided in issue #261;

So i install seurat disk without updating packages :

remotes::install_github("mojaveazure/seurat-disk")

adata = st.io.stereo_to_anndata(data,flavor='seurat',output='/mnt/Data1/SpatialTranscriptomics/stereoseq/stereoseq_brain_mouse_001/object/adjusted_seurat_out.h5ad')

Rscript ~/Projects/SpatialTranscriptomics/stereoseq/stereoseq_brain_mouse_001/rscript/h5ad2rds.R --infile ./adjusted_seurat_out.h5ad --outfile ./adjusted_seurat_out.rds

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

The legacy packages maptools, rgdal, and rgeos, underpinning this package will retire shortly. Please refer to R-spatial evolution reports on https://r-spatial.org/r/2023/05/15/evolution4.html for details. This package is now running under evolution status 0 Attaching SeuratObject 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 X as counts Adding meta.features from 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 gene_exp_leiden to miscellaneous data Adding hvg to miscellaneous data Adding rank_genes_groups to miscellaneous data Adding rank_genes_groups_filtered to miscellaneous data Adding raw_cellname to miscellaneous data Adding raw_counts to miscellaneous data Adding raw_genename to miscellaneous data Adding sn to miscellaneous data [1] "Finished! Converting h5ad to h5seurat file at:" [2] "./adjusted_seurat_out.h5seurat"
[1] "h5seurat time consuming: 30.212" Validating h5Seurat file Initializing Spatial with data Adding counts for Spatial Adding feature-level metadata for Spatial Error: Missing required datasets 'levels' and 'values' Execution halted

leogg738 commented 2 months ago

Before I generated 'seurat_out.h5ad',I run the stoeropy basic pipeline, such as qc,pca,umap. And finally, I generated seurat_out.h5ad

adata = st.io.stereo_to_anndata(data,flavor='seurat',output='seurat_out.h5ad')

[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][837][INFO]: Adding sample in adata.obs['orig.ident'].
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][840][INFO]: Adding data.position as adata.obsm['spatial'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][845][INFO]: Adding data.position as adata.obs['x'] and adata.obs['y'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][875][INFO]: Adding data.tl.result['highly_variable_genes'] into adata.var .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][897][INFO]: Adding data.tl.result['pca'] into adata.obsm['X_pca'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][905][INFO]: Adding data.tl.result['neighbors']['connectivities'] into adata.obsp['connectivities'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][906][INFO]: Adding data.tl.result['neighbors']['nn_dist'] into adata.obsp['distances'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][909][INFO]: Adding info into adata.uns['neighbors'].
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][897][INFO]: Adding data.tl.result['umap'] into adata.obsm['X_umap'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][916][INFO]: Adding data.tl.result['leiden'] into adata.obs['leiden'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][922][INFO]: Adding data.tl.result['gene_exp_leiden'] into adata.uns['gene_exp_leiden']
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][948][INFO]: Adding data.tl.raw.exp_matrix as adata.uns['raw_counts'] .
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][980][INFO]: Rename QC info.
[2024-04-26 17:26:03][Stereo][1927118][MainThread][140570591291200][reader][984][INFO]: Finished conversion to anndata.
... storing 'gene type' as categorical
[2024-04-26 17:31:34][Stereo][1927118][MainThread][140570591291200][reader][988][INFO]: Finished output to seurat_out.h5ad

But when I run Rscript, the same error as the above comment.

leogg738 commented 2 months ago

So I directly run below code without the basic workflow.

import stereo as st
import warnings
warnings.filterwarnings('ignore')

# read the GEF file
data_path = './SS200000135TL_D1.tissue.gef'
data = st.io.read_gef(file_path=data_path, bin_size='cell_bins')
data.tl.cal_qc()
data.tl.raw_checkpoint()

# remember to set flavor as seurat
adata = st.io.stereo_to_anndata(data,flavor='seurat',output='seurat_out.h5ad')
Rscript h5ad2rds.R --infile seurat_out1.h5ad --outfile seurat_cellbin.rds

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

The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
     (status 2 uses the sf package in place of rgdal)
Attaching SeuratObject
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 X as counts
Adding meta.features from var
Adding spatial as cell embeddings for spatial
Adding raw_cellname to miscellaneous data
Adding raw_counts to miscellaneous data
Adding raw_genename to miscellaneous data
Adding sn to miscellaneous data
[1] "Finished! Converting h5ad to h5seurat file at:"
[2] "./seurat_out1.h5seurat"                        
[1] "h5seurat time consuming: 3.537"
Validating h5Seurat file
Initializing Spatial with data
Adding counts for Spatial
Adding feature-level metadata for Spatial
Adding reduction spatial
Adding cell embeddings for spatial
Adding miscellaneous information for spatial
Adding command information
Adding cell-level metadata
Warning: Invalid name supplied, making object name syntactically valid. New object name is X_indexareadnbCountnCount_SpatialnFeature_Spatialorig.identpercent.mitoxy; see ?make.names for more details on syntax validity
Adding tool-specific results
Warning message:
Cannot add objects with duplicate keys (offending key: spatial_), setting key to 'spatiallg_' 
[1] "Successfully load h5seurat:" "./seurat_out1.h5seurat"     

Attaching package: ‘rhdf5’

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

    h5version

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

It works!

So I guess the question is that I run the basic workflow before generating h5ad.

maximelepetit commented 2 months ago

@leogg738 Be careful you load tissue.gef and not adjusted.cellbin.gef.

The tissue.gef file only contains square_bin information.

You set bin_size='cell_bins' and not bin_type='cell_bins'

I think bin_size='cell_bins' was not take into account.

So st.io.read_gef is ran with default parameters (according to the API ):

bin_type='bins', bin_size=100

Bests

maximelepetit commented 2 months ago

Following @leogg738 suggestions the issue persist.

When i try to convert square_bin to rds it works.

But when you use cell_bin it fail, the same error occur.

We are really interesting to convert the adjusted_cell_bin.gef file !

Any another suggestions ?

Maxime

leogg738 commented 2 months ago

Sorry for that. I copied the tutorial codes.

My real code is:

import stereo as st
import warnings
warnings.filterwarnings('ignore')

data_path = './051.cellcut/A03684E4.cellbin.gef' #this gef file are generated from SAW6.1.1 without any adjustments.
data = st.io.read_gef(file_path=data_path, bin_type='cell_bins')
data.tl.cal_qc()
data.tl.raw_checkpoint()
data

[2024-04-29 22:07:06][Stereo][2378012][MainThread][140710770722624][reader][1334][INFO]: This is GEF file which contains cell bin infomation.
[2024-04-29 22:07:06][Stereo][2378012][MainThread][140710770722624][reader][1335][INFO]: bin_type: cell_bins
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1341][INFO]: Number of cells: 85671
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1344][INFO]: Number of gene: 25416
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1347][INFO]: Resolution: 500
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1350][INFO]: offsetX: 0
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1353][INFO]: offsetY: 0
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1356][INFO]: Average number of genes: 153.55313110351562
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1359][INFO]: Maximum number of genes: 1782
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1362][INFO]: Average expression: 201.25918579101562
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1365][INFO]: Maximum expression: 3661
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][reader][1181][INFO]: the matrix has 85671 cells, and 25416 genes.
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][st_pipeline][41][INFO]: start to run cal_qc...
version is 0.7.26 
[2024-04-29 22:07:07][Stereo][2378012][MainThread][140710770722624][st_pipeline][44][INFO]: cal_qc end, consume time 0.5398s.
StereoExpData object with n_cells X n_genes = 85671 X 25416
bin_type: cell_bins
offset_x = None
offset_y = None
cells: ['cell_name', 'dnbCount', 'area', 'total_counts', 'n_genes_by_counts', 'pct_counts_mt']
genes: ['gene_name', 'n_cells', 'n_counts', 'mean_umi']
result: []

data.tl.filter_cells(
        min_gene=200,
        min_n_genes_by_counts=3,
        #max_n_genes_by_counts=2500,
        pct_counts_mt=10,
        inplace=True
        )
data

[2024-04-29 22:08:25][Stereo][2378012][MainThread][140710770722624][st_pipeline][41][INFO]: start to run filter_cells...
[2024-04-29 22:08:25][Stereo][2378012][MainThread][140710770722624][st_pipeline][44][INFO]: filter_cells end, consume time 0.4930s.
StereoExpData object with n_cells X n_genes = 35136 X 25416
bin_type: cell_bins
offset_x = None
offset_y = None
cells: ['cell_name', 'dnbCount', 'area', 'total_counts', 'n_genes_by_counts', 'pct_counts_mt']
genes: ['gene_name', 'n_cells', 'n_counts', 'mean_umi']
result: []

adata = st.io.stereo_to_anndata(data,flavor='seurat',output='seurat_out1.h5ad')

[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][837][INFO]: Adding sample in adata.obs['orig.ident'].
[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][840][INFO]: Adding data.position as adata.obsm['spatial'] .
[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][845][INFO]: Adding data.position as adata.obs['x'] and adata.obs['y'] .
[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][948][INFO]: Adding data.tl.raw.exp_matrix as adata.uns['raw_counts'] .
[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][980][INFO]: Rename QC info.
[2024-04-29 22:09:20][Stereo][2378012][MainThread][140710770722624][reader][984][INFO]: Finished conversion to anndata.
[2024-04-29 22:09:24][Stereo][2378012][MainThread][140710770722624][reader][988][INFO]: Finished output to seurat_out1.h5ad
Rscript h5ad2rds.R --infile seurat_out1.h5ad --outfile seurat_cellbin.rds

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

The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
     (status 2 uses the sf package in place of rgdal)
Attaching SeuratObject
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 X as counts
Adding meta.features from var
Adding spatial as cell embeddings for spatial
Adding raw_cellname to miscellaneous data
Adding raw_counts to miscellaneous data
Adding raw_genename to miscellaneous data
Adding sn to miscellaneous data
[1] "Finished! Converting h5ad to h5seurat file at:"
[2] "./seurat_out1.h5seurat"                        
[1] "h5seurat time consuming: 3.537"
Validating h5Seurat file
Initializing Spatial with data
Adding counts for Spatial
Adding feature-level metadata for Spatial
Adding reduction spatial
Adding cell embeddings for spatial
Adding miscellaneous information for spatial
Adding command information
Adding cell-level metadata
Warning: Invalid name supplied, making object name syntactically valid. New object name is X_indexareadnbCountnCount_SpatialnFeature_Spatialorig.identpercent.mitoxy; see ?make.names for more details on syntax validity
Adding tool-specific results
Warning message:
Cannot add objects with duplicate keys (offending key: spatial_), setting key to 'spatiallg_' 
[1] "Successfully load h5seurat:" "./seurat_out1.h5seurat"     

Attaching package: ‘rhdf5’

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

    h5version

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

And then I checked the seurat_cellbin.rds. The spatial info is existed, different from square bin. image

Hope to help you. @maximelepetit

maximelepetit commented 2 months ago

Hi it works !!!

I recap the steps:

  1. On Python :
data_path = './A02994G3.adjusted.cellbin.gef'
data = st.io.read_gef(file_path=data_path, bin_type='cell_bins')
data.tl.cal_qc()
data.tl.filter_cells(
        min_gene=200, 
        min_n_genes_by_counts=3, 
        max_n_genes_by_counts=2000, 
        pct_counts_mt=10, 
        inplace=True
        )

data.tl.raw_checkpoint()
adata = st.io.stereo_to_anndata(data,flavor='seurat',output='./adjusted_seurat_filtered_out.h5ad')
  1. Create environment based on #261 and activate it :
conda env create -n r-env -f env.yml  # Create
conda activate r-env # activate
  1. Open R and install seurat-disk and rhdf5.
    remotes::install_github("mojaveazure/seurat-disk") 
    BiocManager::install("rhdf5")
  2. Go out R terminal and run h5ad2rds.R

Rscript ./rscript/h5ad2rds.R --infile ./adjusted_seurat_filtered_out.h5ad --outfile ./adjusted_seurat_filtered_out.rds

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

The legacy packages maptools, rgdal, and rgeos, underpinning this package will retire shortly. Please refer to R-spatial evolution reports on https://r-spatial.org/r/2023/05/15/evolution4.html for details. This package is now running under evolution status 0 Attaching SeuratObject 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 X as counts Adding meta.features from var Adding spatial as cell embeddings for spatial Adding raw_cellname to miscellaneous data Adding raw_counts to miscellaneous data Adding raw_genename to miscellaneous data Adding sn to miscellaneous data [1] "Finished! Converting h5ad to h5seurat file at:" [2] "./adjusted_seurat_filtered_out.h5seurat"
[1] "h5seurat time consuming: 2.509" Validating h5Seurat file Initializing Spatial with data Adding counts for Spatial Adding feature-level metadata for Spatial Adding reduction spatial Adding cell embeddings for spatial Adding miscellaneous information for spatial Adding command information Adding cell-level metadata Warning: Invalid name supplied, making object name syntactically valid. New object name is X_indexareadnbCountnCount_SpatialnFeatureSpatialorig.identpercent.mitoxy; see ?make.names for more details on syntax validity Adding tool-specific results Warning message: Cannot add objects with duplicate keys (offending key: spatial), setting key to 'spatialpn_' [1] "Successfully load h5seurat:"
[2] "./adjusted_seurat_filtered_out.h5seurat"

Attaching package: ‘rhdf5’

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

h5version

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