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

feat: cxg conversion script updates for uns["spatial"] #7023

Merged
merged 43 commits into from
May 21, 2024

Conversation

kaloster
Copy link
Contributor

@kaloster kaloster commented May 10, 2024

Reason for Change

Changes

  • added convert_uns_to_cxg_group() handler for all uns["spatial"] actions as an additional step in make_cxg() script
  • created SpatialDataProcessor class to handle cxg conversion for uns and spatial deep zoom asset generation and upload
  • added unit test coverage

Testing steps

  • using a jupyter notebook - run make_cxg() against a local h5ad - verify generated assets are uploaded to s3 and that the generated cxg includes uns group.
  • verified with different use cases with:
    -- datasets with fullres spatial image
    -- datasets with hires only spatial image
    -- datasets without spatial embedding

Notes for Reviewer

  • the package libvips had to be added to backed and processing Docker in order to get pyvips library (that generates the deep zoom tiles) to work properly
  • the need to store uns["spatial"] in the cxg is to support the mvp implementation of spatial in explorer, where that image is generated on the fly - once deepzoom is launched - the step can be removed from the cxg conversion script

Copy link
Contributor

Deployment Summary

@kaloster kaloster changed the title feat: cxg conversion script updates for uns/spatial feat: cxg conversion script updates for uns["spatial"] May 14, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 97.96748% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 92.02%. Comparing base (94c2cbe) to head (ffa4666).

Files Patch % Lines
backend/layers/processing/utils/spatial.py 95.16% 3 Missing ⚠️
backend/layers/processing/h5ad_data_file.py 88.88% 1 Missing ⚠️
...nd/layers/processing/utils/cxg_generation_utils.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7023      +/-   ##
==========================================
+ Coverage   91.93%   92.02%   +0.08%     
==========================================
  Files         184      186       +2     
  Lines       15615    15852     +237     
==========================================
+ Hits        14356    14588     +232     
- Misses       1259     1264       +5     
Flag Coverage Δ
unittests 92.02% <97.96%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -8,7 +8,7 @@ RUN apt-get update && \
apt-get upgrade -y && \
apt install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y python3.10 python3.10-dev python3.10-venv && \
apt-get update && apt-get install -y python3.10 python3.10-dev python3.10-venv libvips && \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libvips is required in order to get pyvips to run

# Cast 'in_tissue' column values as boolean to make it categorical
# https://github.com/chanzuckerberg/single-cell-explorer/issues/841
if column_name == "in_tissue":
dtype, hints = get_dtype_and_schema_of_array(column_values.astype(bool))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to treat the reported issue for in_tissue boolean column that sometimes stored as int. After casting it as bool it will appear as categorical in explorer

is_valid = (
isinstance(embedding_name, str)
and (embedding_name.startswith("X_") or embedding_name == "spatial")
and len(embedding_name) > 2
Copy link
Contributor Author

@kaloster kaloster May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid embedding name either starts with X_ or equals to spatial

@kaloster kaloster marked this pull request as ready for review May 17, 2024 18:48
Copy link
Contributor

@tihuan tihuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much, Ronen!!

backend/common/utils/cxg_generation_utils.py Show resolved Hide resolved
backend/common/utils/spatial.py Outdated Show resolved Hide resolved
backend/common/utils/spatial.py Outdated Show resolved Hide resolved
backend/common/utils/spatial.py Outdated Show resolved Hide resolved
backend/common/utils/spatial.py Outdated Show resolved Hide resolved
@kaloster kaloster requested a review from Bento007 May 20, 2024 21:16
tests/unit/processing/test_spatial_assets_utils.py Outdated Show resolved Hide resolved
tests/unit/processing/test_spatial_assets_utils.py Outdated Show resolved Hide resolved
tests/unit/processing/test_spatial_assets_utils.py Outdated Show resolved Hide resolved
tests/unit/processing/test_spatial_assets_utils.py Outdated Show resolved Hide resolved
@kaloster kaloster requested a review from Bento007 May 20, 2024 23:47
if embedding_name == "spatial":
embedding_name = f"{embedding_container}/{embedding_name}"
else:
embedding_name = f"{embedding_container}/{embedding_name[2:]}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if "spatial" no need to strip the first 2 characters

@kaloster kaloster enabled auto-merge (squash) May 21, 2024 20:29
@kaloster kaloster disabled auto-merge May 21, 2024 20:35
@kaloster kaloster merged commit c04955e into main May 21, 2024
36 checks passed
@kaloster kaloster deleted the kaloster/cxg-conversion branch May 21, 2024 22:04
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

Successfully merging this pull request may close these issues.

4 participants