feat: stalign with a fit apply pattern. #1195
Open
selmanozleyen wants to merge 132 commits into
Open
Conversation
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
for more information, see https://pre-commit.ci
…leyen/squidpy into feat/spatial_neighbours
timtreis
reviewed
Jun 16, 2026
timtreis
reviewed
Jun 16, 2026
| # element we register a transform on so `output_mode="copy"` leaves the input untouched. | ||
| element = sd_deepcopy(element) | ||
| getattr(out, etype)[name] = element | ||
| set_transformation(element, sd_affine, to_coordinate_system=target_cs) |
Member
There was a problem hiding this comment.
breaks if the element already has a transformation, you need to Sequence them
existing = get_transformation(element, to_coordinate_system=moving_cs)
set_transformation(element, Sequence([existing, sd_affine]), to_coordinate_system=target_cs)
timtreis
reviewed
Jun 16, 2026
| radius = int(np.ceil(float(np.max(blur_values)) * 4.0)) | ||
| denom = 2.0 * (dx * blur_values * 2.0) ** 2 | ||
|
|
||
| for x_i, y_i in zip(x, y, strict=False): |
Member
There was a problem hiding this comment.
How many points do we have? Should probably rasterize
timtreis
reviewed
Jun 16, 2026
| p: float = 2.0, | ||
| expand: float = 2.0, | ||
| nt: int = 3, | ||
| niter: int = 5000, |
Member
There was a problem hiding this comment.
Can we do some form of early stopping or do we always have to train for 5k steps? Might be too much/too little depending on data
timtreis
reviewed
Jun 16, 2026
| return data_ref.tables[ref_key], sdata_query.tables[query_key], sdata_query, query_key | ||
|
|
||
|
|
||
| def get_coords(adata: AnnData, spatial_key: str) -> np.ndarray: |
Member
There was a problem hiding this comment.
Claude:
get_coords materializes coords up to 3× per align() (_io.py:71; called at _api.py:83,84 and again _io.py:97). np.asarray(..., dtype=float) forces a float64 copy each time. Thread the already-computed query_xy into writeback_obs and avoid the forced upcast when the array is already suitable.
timtreis
reviewed
Jun 16, 2026
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Continuation of #1162