scverse / spatialdata-plot

Static plotting for spatialdata
BSD 3-Clause "New" or "Revised" License
31 stars 13 forks source link

'SpatialData' object has no attribute 'pp' #366

Open lg907 opened 4 days ago

lg907 commented 4 days ago

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.

LucaMarconato commented 4 days ago

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 commented 4 days ago