Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading .hdf5 file in sopa? #163

Open
KunHHE opened this issue Dec 13, 2024 · 5 comments
Open

reading .hdf5 file in sopa? #163

KunHHE opened this issue Dec 13, 2024 · 5 comments

Comments

@KunHHE
Copy link

KunHHE commented Dec 13, 2024

Hi @quentinblampey, Can I ask you if the case I have a .hdf5 file of the merscope AnnData (it has been segmented by cellpose but not annotated, and UMAPs are there), do you think it can be read by sopa, and run Tangram directly for cell type annotation? I tried to dun Tangram separately but had some trouble with the process. Thank you very much!

@quentinblampey
Copy link
Collaborator

Hi @KunHHE, can you try to directly use spatialdata_io as below? It should be able to read the Vizgen segmentation. Inside this spatialdata object, you'll have an AnnData object that you can use to run Tangram from sopa.

import spatialdata_io

sdata = spatialdata_io.merscope("/path/to/data")

NB: the new SpatialData version is still not released, so I still can't release sopa==2.0.0

@KunHHE KunHHE closed this as completed Dec 27, 2024
@KunHHE KunHHE reopened this Jan 5, 2025
@KunHHE
Copy link
Author

KunHHE commented Jan 5, 2025

Hi @quentinblampey, sorry, re-opened the issue. Tried to open h5ad using spatialdata-io, but not sure why it ask FileNotFoundError: C:\Users\hekun\Downloads\clustering_output.h5ad\images\micron_to_mosaic_pixel_transform.csv not found.?

(sopa) C:\Users\hekun>python
Python 3.10.16 | packaged by conda-forge | (main, Dec 5 2024, 14:07:43) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import spatialdata_io
C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\dask\dataframe_init_.py:31: FutureWarning: The legacy Dask DataFrame implementation is deprecated and will be removed in a future version. Set the configuration option dataframe.query-planning to True or None to enable the new Dask Dataframe implementation and silence this warning.
warnings.warn(
C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\anndata\utils.py:429: FutureWarning: Importing read_text from anndata is deprecated. Import anndata.io.read_text instead.
warnings.warn(msg, FutureWarning)
sdata = spatialdata_io.merscope("C:/Users/hekun/Downloads/clustering_output.h5ad")
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\spatialdata_io\readers\merscope.py", line 171, in merscope
np.genfromtxt(images_dir / MerscopeKeys.TRANSFORMATION_FILE), input_axes=("x", "y"), output_axes=("x", "y")
File "C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\numpy\lib\npyio.py", line 1980, in genfromtxt
fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\numpy\lib_datasource.py", line 193, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "C:\Users\hekun\miniconda3\envs\sopa\lib\site-packages\numpy\lib_datasource.py", line 533, in open
raise FileNotFoundError(f"{path} not found.")
FileNotFoundError: C:\Users\hekun\Downloads\clustering_output.h5ad\images\micron_to_mosaic_pixel_transform.csv not found.

@quentinblampey
Copy link
Collaborator

Hi @KunHHE, normally the MERSCOPE outputs a micron_to_mosaic_pixel_transform.csv file under the images directory. Here, this file is not existing, so spatialdata-io can't read the data.

Are you sure you transferred the data correctly? You should have this micron_to_mosaic_pixel_transform.csv file

@KunHHE
Copy link
Author

KunHHE commented Jan 7, 2025

Thanks @quentinblampey, I guess my h5ad file doesn't have the images directory when I generate AnnData. But usually AnnData doesn't have other directory except the 'Tables"? Or we can put other directory in the 'uns'?

@quentinblampey
Copy link
Collaborator

I'm talking about the images directory of the MERSCOPE output, it's not related to Sopa or AnnData. That is, the data directory that you provide to Sopa, not the output of Sopa. Could you check that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants