Use the correct image for scatter plots with alternate spatial bases #1032
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The current assumption in the spatial scatter plotting code is that any alternate spatial bases (i.e. non-default
spatial_key
s) will use the images stored in the default spatial basis (adata.uns["spatial"]
). My workflow involves creating an alternate spatial basis (adata.obsm["spatial_rot"]
) with transformed images (to align the spatial orientations of different libraries) stored in its own spatial uns key (adata.uns["spatial_rot"]
), and this assumption means I have to explicitly retrieve and pass in images to thespatial_scatter
function, which is inelegant.I am unsure if this way of using alternate spatial bases is standard or desired by others, but from my perspective, if you're using an modified spatial basis, then the images should also be modified, because the spatial basis and the background images should be expected to line up. Additionally, alternate spatial bases are required (by the
Key.uns.library_mapping
function, called just above my change) to have animages
dict, so it seems unreasonable to have images and then not use them, regardless of the workflow.I am not sure if scale factors etc. are properly retrieved for alternate spatial bases; my workflow does not touch the scale factors.
How has this been tested?
I have run this against my own dataset, testing against the default basis
adata.obsm["spatial"]
and my custom alternate basisadata.obsm["spatial_rot"]
with modified images. Specifically,adata.uns["spatial_rot"]
is a deep copy ofadata.uns["spatial"]
, with the images replaced with my transformed images.