-
Notifications
You must be signed in to change notification settings - Fork 0
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
unable to read hdf file in python #3
Comments
Under shoji there are many keys. Try this hdf[”shoji”].keys() |
Thanks for the swift reply. :) this works Although i wrote a quick work around to extract data from h5 file and make scanpy compatible adata. load basic python libraries###import numpy as np read the hdf file using h5py####hdf = h5py.File('/scratch/kgr851/datasets/human_brain_development/linnarsson/HumanFetalBrainPool.h5','r') i think 'Expression' is count matrixmake adata then add other metadata as adata.obs#expr = hdf['shoji']['Expression'][:1665937] extract cell names and gene names and add to adatagenes = np.array(hdf['shoji']['Gene'][:], dtype=str) read columns you are interested in to add as obs####(remeber to keep it small and eqvivalant to number of cells) ( you can also loop it) ###time to add embedding ##### with plt.rc_context({"figure.figsize": [10, 10]}): adata is ready you can save it h5ad formata.write('/scratch/kgr851/datasets/human_brain_development/linnarsson/hbd_atlas.h5ad') you can also save as loom file |
here's another way of reading the gene expression matrix chunk by chunk for a (random) subsample of cells, avoiding the creation of large dense arrays:
|
But it still does not reads the metadata info with it. SO one will have to match index in the end. |
well, you continue as above (but mapping the subcluster IDs is slightly more complicated)
|
Fantastic. :) |
if possible, can you please share the h5ad file that you generated? Don't have the privilege of 1 TB RAM :/ |
Dear Linnarsson lab,
Thank you very much for publishing this fantastic and precious dataset.
However, I am struggling to read the h5 file posted. with both h5py and scanpy. Looks like the problem lies in key (which i presume is 'shoji') of h5 file.
The text was updated successfully, but these errors were encountered: