Skip to content

Conversation

@julienmortier
Copy link
Collaborator

@julienmortier julienmortier commented Oct 27, 2025

This PR contains functions for several basic operations for spatial data analysis:

hp.sh.filter_by_morphology: Allows filtering a shapes layer based on morphological features (area, perimeter, circularity, ...). Can be used to clean cells after segmentation.

hp.sh.filter_by_shapes: Allows filtering a shapes layer based on a secondary shapes layer containing region annotation. Can be used to clean cells/polygons occurring in artifacts, outside of the tissue, etc..

hp.tb.filter_numerical: Allows filtering a table layer based on a numerical column in .obs. This is a generalization of hp.tb.filter_on_size.

hp.tb.filter_categorical: Allows filtering a table layer based on a categorical column in .obs.

hp.assign_cells_to_shapes: Allows determining whether a cell occurs in a region annotation. Creates a column or multiple columns in .obs.

hp.tb.compute_distance_to_shapes: Allows computing distances per cell to polygons in a shapes layer. Multiple modes are included to support different use-cases. E.g. computing distance of cell to nearest polygon, computing distances to all centroids of all polygons, ...

hp.sh.prep_region_annotations: Prepares region annotations in a shapes layer for hp.sh.filter_by_morphology, hp.tb.assign_cells_to_shapes and hp.tb.compute_distance_to_shapes.

These functions were tested for shapes and table layers occurring in the same coordinate space and no transformations were required. More challenging use-cases still need to be tested/supported.

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.

2 participants