Spatial transcriptomics without the h5 file
Entering edit mode
4 months ago


I have been provided with the ​gene expression matrices produced by spaceranger (matrix, feature and barcodes) and also the lower res images generated by spaceranger and the image alignment information (the spatial folder). However I do not have the h5 file generated to be loaded in Load10X function for the analysis. Do you know any way I can load these data for the analysis of Spatial Transcriptomics?

I have read this previous post (Spatial transcriptomics data). I have tried to generate a h5 file with the rhdf5, but when I try to write in the h5 file the matrix I have the following error:

Error in UseMethod("h5writeDataset") : 
  no applicable method for 'h5writeDataset' applied to an object of class "c('dgTMatrix', 'TsparseMatrix', 'dsparseMatrix', 'generalMatrix', 'dMatrix', 'sparseMatrix', 'compMatrix', 'Matrix', 'xMatrix', 'mMatrix', 'replValueSp')"

Any idea about how to proceed?. Is the h5 file needed for the Spatial using the Satija lab tutorial?


data spatial single transcriptomics h5 • 452 views
Entering edit mode
3 months ago
matt_hias • 0

Hey jordi, I didn't find a method to directly write the sparse matrix into a .h5 file. But as workaround you can store the raw values in a .h5 file. Just store x,i,j and Dim in the h5 file and use the sparse matrix constructor with the stored values. I hope I was able to help you Matthias

Entering edit mode
3 months ago
fracarb8 ▴ 760

Load10X_Spatial is a convenient wrapper, but you don't need to use a h5 file. Similar to all the other technologies (e.g. CITE-SEq, RNA-Seq), seurat stores the data inside different slots. If you read the How is the spatial data stored within Seurat section of the documentation, you find that:

In the Seurat object, the spot by gene expression matrix is similar to a typical “RNA” Assay but contains spot level, not single-cell level data.  
The image itself is stored in a new images slot in the Seurat object. The images slot also stores the information necessary to associate spots with their physical position on the tissue image.

You can load your spot matrix (Read10X) and images separately (Read10X_Image), create a seurat object and add the data to the right slots.

I haven't tested it, but it should work.


Login before adding your answer.

Traffic: 2311 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6