-
Notifications
You must be signed in to change notification settings - Fork 96
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
base: main
Are you sure you want to change the base?
Conversation
… 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
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
src/squidpy/tl/_sliding_window.py
Outdated
%(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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, ( |
There was a problem hiding this comment.
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
.
There was a problem hiding this 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.
src/squidpy/tl/_sliding_window.py
Outdated
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: |
There was a problem hiding this comment.
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.
src/squidpy/tl/_sliding_window.py
Outdated
window_sizes = [] | ||
|
||
if window_size is None: | ||
if max_n_cells is None and n_splits is None: |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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"): | ||
""" |
There was a problem hiding this comment.
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.
IMPORTANT: Please search among the Pull requests before creating one.
Description
How has this been tested?
Closes