# Problem with plotting spaceranger spatial matrices data

**URL:** <https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583>\
**Category:** squidpy\
**Created:** [June 29, 2022, 1:27pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583 "2022-06-29T13:27:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rinadango](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/rinadango/32/293_2.png) [@rinadango](https://discourse.scverse.org/u/rinadango)\
**Post date:** [June 29, 2022, 1:27pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/1 "2022-06-29T13:27:33Z")

</div>

I have a problem with `sc.pl.spatial()` 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](https://squidpy.readthedocs.io/en/stable/auto_tutorials/tutorial_read_spatial.html)  
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'`:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/e1ace2da5232a256ce6df62ab3d1f4a3eee8bdc9.png)

The `sc.pl.umap()` works fine by the way.

Help would be highly appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![giovp](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/giovp/32/153_2.png) [@giovp](https://discourse.scverse.org/u/giovp)\
**Post date:** [June 29, 2022, 1:40pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/2 "2022-06-29T13:40:06Z")

</div>

Hi @rinadango ,

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

1. try reading the data with [squidpy.read.visium — squidpy documentation](https://squidpy.readthedocs.io/en/latest/api/squidpy.read.visium.html#squidpy.read.visium)

2. you might want to check this plotting function as well (but it won’t solve your problem) [https://squidpy.readthedocs.io/en/latest/auto\_examples/plotting/plot\_scatter.html](https://squidpy.readthedocs.io/en/latest/auto_examples/plotting/plot_scatter.html)

3. 

> 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.

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

```

HTH!

---

<div class="post-metadata">

**Author:** ![rinadango](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/rinadango/32/293_2.png) [@rinadango](https://discourse.scverse.org/u/rinadango)\
**Post date:** [June 30, 2022, 10:50am UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/3 "2022-06-30T10:50:55Z")

</div>

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 `squidpy.read.visium()` 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 `sc.pl.spatial(adata, color="leiden", spot_size=1)` and it also gives me an empty plot.

Thanks!

---

<div class="post-metadata">

**Author:** ![giovp](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/giovp/32/153_2.png) [@giovp](https://discourse.scverse.org/u/giovp)\
**Post date:** [August 8, 2022, 7:35am UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/4 "2022-08-08T07:35:32Z")

</div>

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 [`sq.pl.spatial_scatter`](https://squidpy.readthedocs.io/en/latest/api/squidpy.pl.spatial_scatter.html) ?

let me know!

---

<div class="post-metadata">

**Author:** ![rinadango](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/rinadango/32/293_2.png) [@rinadango](https://discourse.scverse.org/u/rinadango)\
**Post date:** [August 8, 2022, 12:48pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/5 "2022-08-08T12:48:37Z")

</div>

Hello,

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

---

<div class="post-metadata">

**Author:** ![RYY0722](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ryy0722/32/485_2.png) [@RYY0722](https://discourse.scverse.org/u/RYY0722)\
**Post date:** [December 30, 2022, 12:44pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/6 "2022-12-30T12:44:36Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![rinadango](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/rinadango/32/293_2.png) [@rinadango](https://discourse.scverse.org/u/rinadango)\
**Post date:** [January 16, 2023, 1:45pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/7 "2023-01-16T13:45:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![yuanyuanzhu0908](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/yuanyuanzhu0908/32/720_2.png) [@yuanyuanzhu0908](https://discourse.scverse.org/u/yuanyuanzhu0908)\
**Post date:** [June 23, 2023, 3:54pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/8 "2023-06-23T15:54:40Z")

</div>

Can you please share your code? I am also stuck with no h5 file.

---

<div class="post-metadata">

**Author:** ![rinadango](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/rinadango/32/293_2.png) [@rinadango](https://discourse.scverse.org/u/rinadango)\
**Post date:** [July 5, 2023, 12:37pm UTC](https://discourse.scverse.org/t/problem-with-plotting-spaceranger-spatial-matrices-data/583/9 "2023-07-05T12:37:14Z")

</div>

Hey @yuanyuanzhu0908 sorry for such a late reply.  
Sure, here is the [repo to the code](https://github.com/rinadango/STDataAnalysis). Hopefully it helps! 😄
