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

best way to extract anndata ( h5ad ) from hdf5 file #330

Open
afshinmoradi opened this issue Sep 2, 2022 · 1 comment
Open

best way to extract anndata ( h5ad ) from hdf5 file #330

afshinmoradi opened this issue Sep 2, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@afshinmoradi
Copy link

Dear,

I run cell segmentation and saved h5 files.
I loaded with bellow command
f= h5py.File('a.h5', "r")
I want to extract annadata or csv from that. Could please let me know what is the best option

I used bellow comment it works
f['counts']['X'][()]

but I got bellow error when I called obs dataset

f['counts']['obs'][()]
Traceback (most recent call last):
File "", line 1, in
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "/scratch/medicine/afshin/app/miniconda3/envs/H5/lib/python3.10/site-packages/h5py/_hl/group.py", line 330, in getitem
raise TypeError("Accessing a group is done with bytes or str, "
TypeError: Accessing a group is done with bytes or str, not <class 'tuple'>

Thanks for your help

@afshinmoradi afshinmoradi added the enhancement New feature or request label Sep 2, 2022
@jacob-rosenthal
Copy link
Collaborator

I suggest using SlideData instead of interacting with the raw h5 file for this. For example, try something like:

wsi = SlideData('a.h5')
counts = wsi.counts

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

No branches or pull requests

2 participants