Conversation
…into niche_definitions
for more information, see https://pre-commit.ci
…into niche_definitions
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
This was referenced Jun 12, 2024
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
LLehner
commented
Mar 13, 2025
| inplace, | ||
| ) | ||
|
|
||
| if resolutions is None: |
Member
Author
There was a problem hiding this comment.
Why not set this as default right away?
| if resolutions is None: | ||
| resolutions = [0.5] | ||
|
|
||
| if distance is None: |
| elif libraries is not None and len(libraries) > 0: | ||
| return [f"{base_column}_{lib}" for lib in libraries] | ||
|
|
||
| # For neighborhood and utag, we need to handle resolutions |
Member
Author
There was a problem hiding this comment.
Would do this with if-else block maybe
src/squidpy/gr/_niche.py
Outdated
| groups: str | None, | ||
| n_neighbors: int | None, | ||
| resolutions: float | list[float], | ||
| subset_groups: list[str] | None, |
Member
Author
There was a problem hiding this comment.
why remove this completely? It serves a different purpose than masking. This was also described in the original tutorial. E.g. a mask allows to restrict niche calculation to specific cell types but they can have neighbors outside the masked region. Subsetting means only observations within that subset are considered as neighbors.
src/squidpy/gr/_niche.py
Outdated
|
|
||
| def _get_utag_niches( | ||
| adata: AnnData, | ||
| subset_groups: list[str] | None, |
Member
Author
There was a problem hiding this comment.
Here subsetting serves the same purpose as before.
| if library_key not in data.tables[table_key].obs.columns: | ||
| raise ValueError(f"'library_key' must be a column in 'adata.obs', got {library_key}") | ||
|
|
||
| if n_neighbors is not None and not isinstance(n_neighbors, int): |
Member
Author
There was a problem hiding this comment.
Why check these separately?
| for param_name in param_specs["unused"]: | ||
| param_value = param_dict.get(param_name) | ||
|
|
||
| # Special handling for boolean parameters with default values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a function that calculates niches using different strategies. The initial function calculates niches based on neighborhood profiles similar to here.
This PR will get updated with methods discussed in #789.