Problem with plotting spaceranger spatial matrices data

I have a problem with displaying empty figure.

Here is what I did:

So I have 3 outputs from spaceranger: barcodes.tsv.gz, features.tsv.gz, matrix.mtx.gz.
I import them using sc.read_10x_mtx() while passing the folder path.
Then I followed this tutorial: Import spatial data in AnnData and Squidpy — Squidpy main documentation
I got the coordinates that are the last 2 columns of the tissue_positions_list.csv file, which also comes after the run of spaceranger (The file is in spatial folder).

After following the tutorial above I get an empty figure like so, even though I added the coordinates to the obsm: 'spatial':

The works fine by the way.

Help would be highly appreciated! Thanks!

Hi @rinadango ,

thank you for your interest in scverse! Let mne try to answer your question:

  1. try reading the data with — Squidpy main documentation

  2. you might want to check this plotting function as well (but it won’t solve your problem) Plot scatter plot in spatial coordinates — Squidpy main documentation

So I have 3 outputs from spaceranger: barcodes.tsv.gz, features.tsv.gz, matrix.mtx.gz .

you’d also have to read the images and scalefactors in the spatial folder (also output of spaceranger) and put them in the right place in uns (as described in the tutorial you shared or by copying structure in e.g.

import squidpy as sq
adata = sq.datasets.visium_hne_adata()


1 Like

Hello @giovp

As mentioned before I have the barcodes.tsv.gz, features.tsv.gz, matrix.mtx.gz and not the .h5 file. I tried to use the method but it did not work. I get an error asking for .h5.

Just to add, I also tried to plot other data that I know is fine by using the, color="leiden", spot_size=1) and it also gives me an empty plot.


hi @rinadango ,

apologies for late reply. The problem of reading non-h5 files in squidpy indeed persist, will open an issue on the repo.

Regarding plotting, can you try with the newest ?

let me know!

1 Like


thanks for the reply! I have managed to work out the issue in the end :smile:
The previous answer helped with some parts I had trouble with. Again thanks!

1 Like

Hello! May I know how you manage to do that without having a .h5 file at the beginning? Did you generate one by yourself? Would you please share your experience? I am also stuck with it as well… Thanks a lot!!

Hello! Sorry for the late reply.

What I basically did was: I created a custom script that puts these individual files and the corresponding spatial folder automatically in an anndata object, which in turn can be saved as h5ad. Since, in my case, after some digging, I’ve noticed some of the file extensions were weird. The file itself was okay.

Hope this helps!