Skip to content

Conversation

@jaspreetishar
Copy link
Contributor

This PR includes a few minor changes across the pre and qc modules:

  1. In pre/init.py, fixed the order of function calls in add_custom_segmentation.
  2. Took this opportunity to make some small fixes in the qc module as well.
  3. In pre/boundary_tile.py, updated the logic to retain cell geometries in micron space instead of overriding them. This is necessary to compute average cell area in the qc module.

The changes have been tested by successfully running the following notebooks:

  1. BNB_Streamlined_Pre_processing_Xenium_V1_Human_Pancreas_FFPE.ipynb
  2. Custom_Segmentation.ipynb
  3. Segmentation_QC.ipynb

@jaspreetishar jaspreetishar requested a review from cornhundred July 8, 2025 21:43
@cornhundred cornhundred requested a review from Copilot July 8, 2025 21:55

This comment was marked as outdated.

Copy link
Collaborator

@cornhundred cornhundred left a comment

Choose a reason for hiding this comment

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

Looks good. I just asked for a bit of clarification. Can you also merge in the changes from main?

It would be great to turn this notebook, Xenium_V1_human_Pancreas_FFPE_outs.zip, into an automated test but the file sizes are too large.

Copy link
Collaborator

@cornhundred cornhundred left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, I just requested a small change to one of the files. You can add some unit tests if you think it makes sense otherwise you can merge.

@cornhundred cornhundred requested a review from Copilot July 14, 2025 17:31

This comment was marked as outdated.

@cornhundred cornhundred requested a review from huanlity July 15, 2025 14:08
@huanlity
Copy link
Contributor

Great work! I will look in more detail later, but I have successfully verified the three notebooks with some adjustments.

The Segmentation_QC.ipynb threw an error:
FileNotFoundError: [Errno 2] No such file or directory: 'data/raw/Xenium_V1_human_Pancreas_FFPE_outs/micron_to_image_transform.csv'

I believe this file is generated in pre and saved in the landscape folder and not the raw data folder. If you need it to qc raw data without the need to pre-process. You can simply add this line to your notebook:

dega.pre.write_xenium_transform(base_path, base_path)

@huanlity
Copy link
Contributor

Another required file is missing: segmentation_parameters.json in the raw data folder. To avoid manually moving files around, you can create it in the QC notebook instantly or even write a quick function to do it if you see it being used frequently in the future.

This is the content in the json:
{ "technology": "Xenium", "segmentation_approach": "default", "dataset_name": "xenium_pancreas" }

I suggest something like this: def write_default_seg_json(technology, dataset)

@huanlity
Copy link
Contributor

Underscore this helper function or remove the function and just implement it in the code as a one-liner.

def get_largest_polygon(geometry): # TODO: underscore

@jaspreetishar jaspreetishar requested a review from huanlity July 16, 2025 14:46
@huanlity
Copy link
Contributor

@jaspreetishar All three notebooks worked on my end. One final question: is this Unknown technology expected?

segmentation_parameters.json does not exist, creating one...
Unknown technology: None

Copy link
Contributor

@huanlity huanlity left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@cornhundred cornhundred requested a review from Copilot July 17, 2025 14:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements fixes across pre-processing and quality control modules to address custom segmentation landscape files issues. The changes ensure proper handling of cell geometries in micron space and correct function call ordering.

  • Fixed function call ordering in add_custom_segmentation to ensure proper gene metadata handling
  • Updated cell geometry handling to retain micron space coordinates for accurate QC calculations
  • Improved parameter handling and file path resolution across QC and pre-processing modules

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
src/celldega/qc/init.py Enhanced QC module with better parameter handling, geometry processing, and data visualization improvements
src/celldega/pre/run_pre_processing.py Added transformation matrix copying for MERSCOPE and fixed cluster creation logic
src/celldega/pre/boundary_tile.py Updated to retain cell geometries in micron space and improved path handling
src/celldega/pre/init.py Fixed function call ordering in custom segmentation and improved DZI file handling

@jaspreetishar jaspreetishar merged commit b139d78 into main Jul 17, 2025
10 checks passed
@jaspreetishar jaspreetishar deleted the DEGA-290-custom-segmentation-landscape-files-fix branch July 17, 2025 17:37
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