Skip to content
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

Error in Squidpy notebook due to rasterization not handling transformations #291

Open
LucaMarconato opened this issue Jul 13, 2024 · 4 comments

Comments

@LucaMarconato
Copy link
Member

LucaMarconato commented Jul 13, 2024

The Squidpy notebook shows an error liked to rasterizatation. @Sonja-Stockhaus could you please have a look at it? Thanks 😊

This is part of the log:

    300 else:
    301     array_module = np
--> 302 return lambda shape: tuple(c(shape, array_module) for c in creators)
File /mnt/miniconda3/envs/ome/lib/python3.10/site-packages/datashader/compiler.py:302, in <genexpr>(.0)
    300 else:
    301     array_module = np
--> 302 return lambda shape: tuple(c(shape, array_module) for c in creators)
File /mnt/miniconda3/envs/ome/lib/python3.10/site-packages/datashader/reductions.py:785, in by._build_create.<locals>.<lambda>(shape, array_module)
    783 def _build_create(self, required_dshape):
    784     n_cats = len(required_dshape.measure.fields)
--> 785     return lambda shape, array_module: self.reduction._build_create(
    786         required_dshape)(shape + (n_cats,), array_module)
File /mnt/miniconda3/envs/ome/lib/python3.10/site-packages/datashader/reductions.py:472, in Reduction._create_uint32(shape, array_module)
    470 @staticmethod
    471 def _create_uint32(shape, array_module):
--> 472     return array_module.zeros(shape, dtype='u4')
MemoryError: Unable to allocate 74.8 GiB for an array with shape (25783, 35416, 22) and data type uint32
@Sonja-Stockhaus
Copy link
Collaborator

@LucaMarconato I feel like this also has to do with #296 and might be solved with #309 since with that version of the code everything runs for me.

@LucaMarconato
Copy link
Member Author

I just tried: the error disappeared and the plot is fast! There is still a problem with the lims as I get this plot
image
Can you have a look at it as part of the PR please?

@LucaMarconato
Copy link
Member Author

I checked, the extent of the plot is correct. I think that the datashader plot has been made against the original non-transformed coordinates.

@LucaMarconato
Copy link
Member Author

LucaMarconato commented Aug 9, 2024

I confirm that my claim seems to be indeed the source of the issue, in fact a workaround that fixes the plot is to call

sdata['cell_circles'] = sd.transform(sdata['cell_circles'], to_coordinate_system='global')

before making the plot.

I think that a solution is to:

  • assign the correct coordinate transformations to the image element returned by the internal datashader functions
  • ensure that the resolution of the image computed by datashader is computed from the combination of:
    • figure DPI
    • figure size
    • eventually the range given by get_extent()
      and not by the min/max computed from the original data. Probably this is already the case in the implementation, but better to double check.

@LucaMarconato LucaMarconato changed the title Error in Squidpy notebook due to rasterization Error in Squidpy notebook due to rasterization not handling transformations Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants