# Plotting the tangram imputed spatial data with spatialdata\_plot

**URL:** <https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942>\
**Category:** spatialdata\
**Tags:** integration\
**Created:** [March 11, 2026, 1:09pm UTC](https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942 "2026-03-11T13:09:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdka00001](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mdka00001](https://discourse.scverse.org/u/mdka00001)\
**Post date:** [March 11, 2026, 1:09pm UTC](https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942/1 "2026-03-11T13:09:36Z")

</div>

I am trying to plot the features of my tangram imupted spatial data by using the spatial image and cell segmentation of my reference spatial data. In general, I want to render a plot as below:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/6/6231f5df3d35c7b371d239baf0d1264b079a7e81.png)

However, only replacing the anndata object of the reference .zarr file with the tangram imputed anndata object doesn’t solve the issue. The render\_points only renders the transcripts of the reference data. How can I work my way around this?

Also, is it possible to render plots with scanpy/squidpy using the cell segmentation by only transferring the segmentation data to anndata object of the imputed?

---

<div class="post-metadata">

**Author:** ![ttreis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ttreis/32/1186_2.png) [@ttreis](https://discourse.scverse.org/u/ttreis)\
**Post date:** [March 11, 2026, 1:39pm UTC](https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942/2 "2026-03-11T13:39:20Z")

</div>

Hey @mdka00001, could you share the code of what you’re doing? You’d need to check in the `.uns[“spatialdata_attrs”]` of the adata object whether it actually annotates the element you’re trying to visualise. Check the adata from which you see the points being rendered for reference.

Also, could you elaborate on

> Also, is it possible to render plots with scanpy/squidpy using the cell segmentation by only transferring the segmentation data to anndata object of the imputed?

I don’t fully get what you’re aiming to do.

---

<div class="post-metadata">

**Author:** ![mdka00001](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mdka00001](https://discourse.scverse.org/u/mdka00001)\
**Post date:** [March 11, 2026, 1:54pm UTC](https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942/3 "2026-03-11T13:54:02Z")

</div>

Hi @ttreis . My imputed anndata object also has the following informations:  
{‘region’: ‘cellpose\_boundaries’,  
‘region\_key’: ‘region’,  
‘instance\_key’: ‘instance\_id’}

This is my code to replace the table in sdata with my new imputed anndata:

```auto
from spatialdata.models import TableModel

"""adaata_gene is the imputed AnnData object with the Tangram predictions. 
We will link this to the SpatialData object by ensuring it has the correct metadata and then parsing it with TableModel."""

#Assign metadata columns
adaata_gene.obs['region'] = 'cellpose_boundaries'

#CONVERT TO STRING
adaata_gene.obs['instance_id'] = adaata_gene.obs['cell_id'].astype(str)

#Parse with TableModel
sdata_t2_imputed.table = TableModel.parse(
    adaata_gene,
    region='cellpose_boundaries',
    region_key='region',
    instance_key='instance_id',
    overwrite_metadata=True 
)

```

But I think this doesnt replace the default points that are in the sdata object from reference spatial data.

Regarding the 2nd query, I wanted to know whether there is any alternative to my first approach where I can transfer the cell\_segmentation coordinates from the sdata to the anndata object and render the plots using sq.pl.spatial\_segment?

---

<div class="post-metadata">

**Author:** ![ttreis](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ttreis/32/1186_2.png) [@ttreis](https://discourse.scverse.org/u/ttreis)\
**Post date:** [March 11, 2026, 2:02pm UTC](https://discourse.scverse.org/t/plotting-the-tangram-imputed-spatial-data-with-spatialdata-plot/3942/4 "2026-03-11T14:02:10Z")

</div>

I think your issue is that you’re assinging your result to `sdata.table` - try assigning it either to a key in `sdata.tables[key]` or assign a dict to the tables accessor directly like `sdata.tables = {"my_key": TableModel.parse()}.`

The default `table` accessor in SpatialData has been deprecated for a few versions now. You could also try explicitly specifiyng the `table_name` parameter in `render_points`.

> Regarding the 2nd query, I wanted to know whether there is any alternative to my first approach where I can transfer the cell\_segmentation coordinates from the sdata to the anndata object and render the plots using sq.pl.spatial\_segment?

There might be, but since we’re going to deprecate the native behaviour of `sq.pl.spatial_segment` in favor of internally using `spatialdata-plot` soon, I won’t trace in the code how to do that. You could probably ask your favourite LLM on how to hack that into place if you prefer.
