squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

Add parameter to `sliding_window` to end up with windows of (approximately) same number of cells

Open timtreis opened this issue 1 year ago • 2 comments

Could add a heuristic that tries to optimise the number of cells per window (and unassigned cells) so that on average, most windows have a number of cells assigned that is as close as possible to what the user specified.

timtreis avatar Nov 04 '24 15:11 timtreis

Hi Tim, I agree this would be a really useful feature. More specifically, we could add the following parameters:

  • max_nr_cells: int = None.
    • If not None, it calculates the window_size such that the number of cells in a sliding window is <= max_nr_cells (e.i. 1k).

Considering that given multiple library_key's the FOVs have different sizes or densities we could introduce a separate parameter that differentiates between whether the window sizes should be equal across all library_key's or not. For example:

  • window_size_per_library_key: 'equal', 'unique'
    • 'equal': calculate one window size for all library_keys
    • 'unique': calculate a unique window size for all library keys

FrancescaDr avatar Nov 15 '24 12:11 FrancescaDr

Hi @timtreis and @FrancescaDr , I'll work on this.

mossishahi avatar Nov 15 '24 13:11 mossishahi