-
Notifications
You must be signed in to change notification settings - Fork 17
Fix but render_shapes()
when coordinate system "global" not present
#446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
=======================================
Coverage 85.21% 85.21%
=======================================
Files 8 8
Lines 1759 1759
=======================================
Hits 1499 1499
Misses 260 260
🚀 New features to boost your workflow:
|
@@ -195,7 +195,7 @@ def _render_shapes( | |||
) | |||
|
|||
plot_width, plot_height, x_ext, y_ext, factor = _get_extent_and_range_for_datashader_canvas( | |||
transformed_element, coordinate_system, ax, fig_params | |||
transformed_element, "global", ax, fig_params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melonora why "global"
here? What if "global"
is not used in the dataset that is being plotted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melonora why was this merged? I think Lucas concern is valid here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already talked with Luca (sorry tagging does not work on github app) and it is due to the recent change in which global is not required. This caused errors for datasets not having global. However, here the element first gets transformed and after transform the default cs in case nothing is passed on is global. Hence, second call always uses global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But shouldn't we preserve whatever name the user gave the cs? I think we reuse that as the default title for a CS when plotting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will have another look when I am at my laptop again. Note that the 'coordinate_system' parameter itself is not being altered here. The point is that after the transform there is no other cs but global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very end of basic.py we're assigning these as titles here:
if title is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just as a last follow up, this is not an issue as the title is still correspondent to the coordinate system used. I would have to follow up but it could be that the coordinate system argument in the second call where now the value by default is "global" can be deprecated.
For now just as final proof of the visium hd example in the notebooks. The following code snippet before was failing:
import spatialdata as sd
import spatialdata_plot
import matplotlib.pyplot as plt
sdata = sd.read_zarr("visium_hd.zarr")
plt.figure(figsize=(10, 10))
ax = plt.gca()
gene_name = "AA986860"
sdata.pl.render_shapes("Visium_HD_Mouse_Small_Intestine_square_016um", color=gene_name, method="datashader").pl.show(
coordinate_systems="Visium_HD_Mouse_Small_Intestine", ax=ax
)
However, this PR fixes the issue of having the wrong coordinate system as argument in the second call and gives you this plot:
render_shapes()
when coordinate system "global" not present
closes: #447
In render shapes, when using datashader, all transforms were obtained instead of the transform to the coordinate system which is supposed to be rendered. This was a problem for the visium notebook when trying the following code snippet:
After fixing that, the transform was applied and again parsed by
ShapesModel
. This ensured that after that one can only have ashape
with coordinate systemglobal
. This means that the following should always use coordinate systemglobal
: