Skip to content

speed up _resolve_data in spatial neighbors when working with spatialdata #1199

@grst

Description

@grst

Description of feature

I have a SpatialData object with about 20 samples and in total ~10M cells, stored as shapes.

When calculating gr.spatial_neighbors_radius this takes about 5minutes (3min after #1198). Of these 5 minutes, 1:30min are spent in the _resolve_data function. This means (after the optimization in #1198) 50% of the time is spent on retrieving information from the spatialdata object. Specifically, it seems to be the compute_centroids() function that takes most of the time.

On the one hand, this can surely be optimized. On the other hand, I was wondering if caching would be an appropriate solution here. The centroids are required for all graph-based functions in squidpy and there's no point in recalculating them every time. Mabye they could be added as a points layer to spatialdata?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions