Spatial transcriptomics without the h5 file
3
0
Entering edit mode
9 months ago

Hello.

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?

Thanks

data spatial single transcriptomics h5 • 876 views
ADD COMMENT
0
Entering edit mode
8 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

ADD COMMENT
0
Entering edit mode
8 months ago
fracarb8 ▴ 830

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.

ADD COMMENT
0
Entering edit mode
6 weeks ago

Hey you can use stlearn package in Python, create an ANN object manually using function

ann_object = st.create_stlearn(count=count_matrix, spatial=coordinate_matrix,library_id="library_name")

You have to give input your count_matrix where rownames are the barcode names and colnames are the gene name. Coordinate matrix will contain the X and Y coordinate of the spatial data. If you want to use seurat write the ANN object into h5ad then convert it into seurat object.

Thanks

ADD COMMENT

Login before adding your answer.

Traffic: 1038 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6