Skip to content

fix #375: auto-convert StereoExpData to AnnData in spatial_alignment#432

Draft
cursor[bot] wants to merge 1 commit intomainfrom
cursorautomated-issue-resolution-3a3c
Draft

fix #375: auto-convert StereoExpData to AnnData in spatial_alignment#432
cursor[bot] wants to merge 1 commit intomainfrom
cursorautomated-issue-resolution-3a3c

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Mar 26, 2026

Summary

The SpatialAlignment.main() method raises TypeError: The input data should be an object of AnnBasedStereoExpData when called via ms_data.tl.spatial_alignment() on MSData integrated from GEF files. The root cause is a strict isinstance check on line 62 of stereo/algorithm/spatial_alignment/main.py that rejects plain StereoExpData objects. The AnnBasedStereoExpData type is only needed to access .adata, but the already-imported stereo_to_anndata function can produce this from any StereoExpData.

Changes

  • stereo/algorithm/spatial_alignment/main.py: Replaced the TypeError-raising type gate with an auto-conversion branch. If the input is AnnBasedStereoExpData, uses .adata directly; otherwise, converts via stereo_to_anndata() with split_batches=False. All downstream result storage continues to use self.stereo_exp_data.

Verification

  • AST syntax check passed
  • Import chain verified (stereo_to_anndata already imported in file)

Classification

  • Type: bug
  • Confidence: high
  • Severity: medium

Closes #375

Open in Web View Automation 

Instead of raising TypeError when input is not AnnBasedStereoExpData,
automatically convert plain StereoExpData to AnnData using the
already-imported stereo_to_anndata function. This allows
spatial_alignment to work with MSData integrated from GEF files.

Co-authored-by: wanruiwen-genomics-cn <wanruiwen-genomics-cn@users.noreply.github.com>
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.

TypeError: The input data should be an object of AnnBasedStereoExpData. from stereopy spatial_alignment

1 participant