Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Release notes for `v0.7.1` and earlier are available on the [Releases][] page.
documentation builds, `mypy` type checking of `src` and `tests`, `biome`/`pyproject-fmt`/`zizmor` pre-commit hooks,
and Dependabot updates.

### Fixed

- `visium()`: the circles are built again from the spot coordinates instead of from the raw `tissue_positions` table,
which made the reader raise `TypeError: ShapesModel.parse() does not support the type
<class 'pandas.core.frame.DataFrame'>`.

### Removed

- Support for Python 3.11.
7 changes: 5 additions & 2 deletions src/spatialdata_io/readers/visium.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def visium(

assert isinstance(adata.obs, pd.DataFrame)
adata.obs = pd.merge(adata.obs, coords, how="left", left_index=True, right_index=True)
adata.obsm["spatial"] = adata.obs[[VisiumKeys.SPOTS_X, VisiumKeys.SPOTS_Y]].values
# `coords` above is the raw `tissue_positions` table; the circles are built from the
# spot coordinates in the order of `adata`, so keep them in a separate variable
spot_coords = adata.obs[[VisiumKeys.SPOTS_X, VisiumKeys.SPOTS_Y]].to_numpy()
adata.obsm["spatial"] = spot_coords
adata.obs = pd.DataFrame(adata.obs)
adata.obs.drop(columns=[VisiumKeys.SPOTS_X, VisiumKeys.SPOTS_Y], inplace=True)
adata.obs["spot_id"] = np.arange(len(adata))
Expand Down Expand Up @@ -204,7 +207,7 @@ def visium(
)
shapes = {}
circles = ShapesModel.parse(
coords,
spot_coords,
geometry=0,
radius=scalefactors["spot_diameter_fullres"] / 2.0,
index=adata.obs["spot_id"].copy(),
Expand Down
Loading