spatialdata-plot icon indicating copy to clipboard operation
spatialdata-plot copied to clipboard

'SpatialData' object has no attribute 'pp'

Open lg907 opened this issue 1 year ago • 2 comments

Hello, I am attempting to follow the 10x Visium example notebook (https://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks/examples/technology_visium.html#technology-focus-10x-genomics-visium) and are encountering issues when attempting to colour the visium spots by gene expression.

Running:

(
    visium_sdata.pp.get_elements("ST8059050")
    .pl.render_images(elements="ST8059050_hires_image")
    .pl.render_shapes(elements="ST8059050", color="mt-Co3")
    .pl.show()
)

Gives the following output:

AttributeError                            Traceback (most recent call last)

visium_sdata.pp.get_elements("ST8059050")
.pl.render_images(elements="ST8059050_hires_image")
.pl.render_shapes(elements="ST8059050", color="mt-Co3")
.pl.show()

All previous code worked and gave outputs consistent with the example notebook.

I am using spatialdata 0.2.3 with python 3.11.10 on MacOS.

lg907 avatar Oct 01 '24 13:10 lg907

Hi, to fix please replace .pp.get_elements() with .subset(), and please ensure you pass a list to subset().

So your code becomes:

(
    visium_sdata.subset(["ST8059050"])
    .pl.render_images(elements="ST8059050_hires_image")
    .pl.render_shapes(elements="ST8059050", color="mt-Co3")
    .pl.show()
)

LucaMarconato avatar Oct 01 '24 15:10 LucaMarconato

  • [ ] @timtreis can you please make a quick PR that reinstates .pp.get_elements() and automatically calls .subset(), saying that the .pp.get_elements() is now deprecated and will be removed in one next release? Thanks.

LucaMarconato avatar Oct 01 '24 15:10 LucaMarconato