spatialdata-plot
spatialdata-plot copied to clipboard
'SpatialData' object has no attribute 'pp'
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.
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()
)
- [ ] @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.