-
Notifications
You must be signed in to change notification settings - Fork 29
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
Empty color values in images after polygon_query from Xenium data #117
Comments
Hi, I think this could be due to a bug of Can you please try the latest Please notice that you may need to also use the latest |
Thanks for the update. Answering point by point.
This is actually correct, because the initial image has one channel, so there is only
Below I will suggest a way to make the plot being shown. After this, can you please check if the plot is empty also with the new installation? If
The new APIs doesn't require to have
This is unexpected. Can you please share some code/data to reproduce? We used queries to crop Xenium data multiple times and we didn't have problems. A reproducible example would help understand what is happening please.
The problem may be due to using the raw data with Dask. Please try to save the data with
|
Thanks so much for clarification! I selected a region (circled). The coordinates are coordinates.csv For installation, For polygon-query
Looks points and shapes are still not included. I tried to save it to but I got a ValueError. Thanks so much of your help!! Bo |
Thank you for the additional details. I have tried visualizing the data using The reason why the polygon is off (and thus doesn't overlap any shape) is that the polygon coordinates that are saved using Xenium Explorer are in a different coordinate system. The fix is very easy, and is implemented in this function:
The function is not very visible, apologies for that; @quentinblampey and I curated a new tutorial for Xenium data that uses this function and shows additional use cases. I'll add a link of the tutorial to the docs. The rechunking behavior is instead a bug; a quick fix is to use this code after the query operation: from spatialdata._utils import multiscale_spatial_image_from_data_tree
from dask.array.core import Array as DaskArray
from multiscale_spatial_image import MultiscaleSpatialImage
def rechunk(msi: MultiscaleSpatialImage) -> DaskArray:
for scale in msi.keys():
msi[scale]["image"].data = msi[scale]["image"].data.rechunk()
rechunk(query_result["morphology_focus"])
rechunk(query_result["morphology_mip"]) I will open a PR for that. |
This is very helpful. Thanks a lot! I assume this should work. My current notebook kernel died and I tried to reinstall NotImplementedErrorNotImplementedError Traceback (most recent call last) Cell In[4], [line 1](vscode-notebook-cell:?execution_count=4&line=1) ----> [1](vscode-notebook-cell:?execution_count=4&line=1) spdata_test = spatialdata_io.xenium('[/Users/bzhao2/Downloads/Xenium_V1_hPancreas_Cancer_Add_on_FFPE_outs](https://file+.vscode-resource.vscode-cdn.net/Users/bzhao2/Downloads/Xenium_V1_hPancreas_Cancer_Add_on_FFPE_outs)') [2](vscode-notebook-cell:?execution_count=4&line=2) polygon = spatialdata_io.xenium_explorer_selection("[/Users/bzhao2/Downloads/selected_region/coordinates.csv](https://file+.vscode-resource.vscode-cdn.net/Users/bzhao2/Downloads/selected_region/coordinates.csv)") [4](vscode-notebook-cell:?execution_count=4&line=4) query_sdata = sdata_test.query.polygon(polygon, target_coordinate_system="global")File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/_utils.py:46, in deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/readers/xenium.py:132, in xenium(path, n_jobs, cells_as_circles, nucleus_boundaries, transcripts, morphology_mip, morphology_focus, imread_kwargs, image_models_kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/readers/xenium.py:189, in _get_points(path, specs) File ~/miniconda3/envs/single-cell/lib/python3.10/functools.py:926, in singledispatchmethod.get.._method(*args, **kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata/models/models.py:507, in PointsModel.parse(cls, data, **kwargs) NotImplementedError: The versions are I created a new Conda environment, but the errors persists. It seems the author of dask just released this new version I downgraded ValueErrorNotImplementedError Traceback (most recent call last) Cell In[4], line 1 ----> 1 spdata_test = spatialdata_io.xenium('/Users/bzhao2/Downloads/Xenium_V1_hPancreas_Cancer_Add_on_FFPE_outs') 2 polygon = spatialdata_io.xenium_explorer_selection("/Users/bzhao2/Downloads/selected_region/coordinates.csv") 4 query_sdata = sdata_test.query.polygon(polygon, target_coordinate_system="global") File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/_utils.py:46, in deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/readers/xenium.py:132, in xenium(path, n_jobs, cells_as_circles, nucleus_boundaries, transcripts, morphology_mip, morphology_focus, imread_kwargs, image_models_kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata_io/readers/xenium.py:189, in _get_points(path, specs) File ~/miniconda3/envs/single-cell/lib/python3.10/functools.py:926, in singledispatchmethod.get.._method(*args, **kwargs) File ~/miniconda3/envs/single-cell/lib/python3.10/site-packages/spatialdata/models/models.py:507, in PointsModel.parse(cls, data, **kwargs) NotImplementedError: Thanks so much for your help! |
Exactly, Dask now uses Anyway I am a bit surprised that you get the second error after a downgrade. Can you please set a breakpoint/put a You should get a |
Hi @Bo-UT, we are soon pushing a new release of SpatialData in which for now we have constrained the version of dask being used until we have adjusted the code base to work with the new |
Great to hear that it worked!
Anyway when the |
Hi,
I have multiple samples in the same FOV in Xenium data. I am trying to subset each sample with
polygon_query
.Then I plot the image
cropped.pl.render_images('morphology_mip').pl.show()
, but no data show up in the plot.Here is the data from
cropped.images
. Thec
is just 0.Can you please point out what's the problem there?
Thank you!!
Bo
The text was updated successfully, but these errors were encountered: