Skip to content

Sliding window improvements #931

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mossishahi
Copy link
Collaborator

IMPORTANT: Please search among the Pull requests before creating one.

Description

How has this been tested?

Closes

mossishahi and others added 5 commits November 20, 2024 19:20
… to minimize the partial uncovered area

- aligned_min_x and aligned_min_y added to _calculate_window_corners function to remove partial regions at the beginning of the slides
- max_n_cells, n_splits, and split_line parameters added to the sliding_window function
%(library_key)s
coord_columns: Tuple[str, str]
Tuple of column names in `adata.obs` that specify the coordinates (x, y), e.i. ('globalX', 'globalY')
window_size: int
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust the description: include option of tuple

Copy link
Contributor

Choose a reason for hiding this comment

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

Overall there are some function parameters that are not described in the doctoring. Please make sure to include documentation for all.

if overlap < 0:
raise ValueError("Overlap must be non-negative.")

if isinstance(adata, SpatialData):
adata = adata.table

assert max_n_cells is None or n_splits is None, (
Copy link
Contributor

Choose a reason for hiding this comment

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

Also: assert that not all window_size, max_n_cells and n_splits are None.

Copy link
Contributor

@FrancescaDr FrancescaDr left a comment

Choose a reason for hiding this comment

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

Hi @mossishahi, thanks for the implementation. Please don't forget to add tests for all the functions that you added. I also recommend to check out the squidpy contribution guidelines to make sure the code and docstrings are correctly formatted.

if library_key is not None and library_key not in adata.obs:
raise ValueError(f"Library key '{library_key}' not found in adata.obs")

libraries = [None] if library_key is None else adata.obs[library_key].unique()
if library_key is None and "fov" not in adata.obs.columns:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call it temp_fov for temporal_fov and remove it at the end of the code.

window_sizes = []

if window_size is None:
if max_n_cells is None and n_splits is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Earlier you added a check that this case does not exists, so I suggest to remove this.

drop_partial_windows: bool = False,
square: bool = False,
window_size_per_library_key: str = "equal",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add explanation to code string.

@@ -157,6 +224,7 @@ def sliding_window(

if overlap == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

Also enable drop_partial_windows for the case of no overlap.



def _optimize_tile_size(L, W, A_min=None, A_max=None, square=False, split_line="v"):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Adjust doctoring to squidpy/scverse style guide.

@timtreis timtreis marked this pull request as draft March 6, 2025 14:46
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.

3 participants