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
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## Version 0.0.10
## Version 0.0.11
- BUGFIX: `to_anndata()` only populates `obsm` with spatial coordinates if the original `SpatialExperiment` has spatial coordinates (PR #53)


## Version 0.0.10
- Add an affine function that computes a `rasterio.Affine` object given a `scale_factor`. This assumes a simple scaling where the origin is (0,0) in the spatial coordinate system corresponding to the top-left pixel (0,0). More complex alignments would require explicit affine transforms.
- Ensure img_raster() consistently returns a PIL.Image.Image.
- Add to_numpy() method.
Expand All @@ -11,30 +14,33 @@
## Version 0.0.9
- Added `to_anndata()` in main `SpatialExperiment` class (PR #50)


## Version 0.0.8
- Set the expected column names for image data slot (PR #46)


## Version 0.0.7
- Added `img_source` function in main SpatialExperiment class and child classes of VirtualSpatialExperiment (PR #36)
- Added `remove_img` function (PR #34)
- Refactored `get_img_idx` for improved maintainability
- Disambiguated `get_img_data` between `_imgutils.py` and `SpatialExperiment.py`
- Moved `SpatialFeatureExperiment` into its own package


## Version 0.0.6
- Added `read_tenx_visium()` function to load 10x Visium data as SpatialExperiment
- Added `combine_columns` function
- Implemented `__eq__` override for `SpatialImage` subclasses

## Version 0.0.5

## Version 0.0.5
- Implementing a placeholder `SpatialFeatureExperiment` class. This version only implements the data structure to hold various geometries but none of the methods except for slicing.

## Version 0.0.3 - 0.0.4

## Version 0.0.3 - 0.0.4
- Streamlining the `SpatialImage` class implementations.

## Version 0.0.1 - 0.0.2

## Version 0.0.1 - 0.0.2
- Initial version of the SpatialExperiment class with the additional slots.
- Allow spatial coordinates to be a numpy array
4 changes: 3 additions & 1 deletion src/spatialexperiment/spatialexperiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,9 @@ def to_anndata(self, include_alternative_experiments: bool = False) -> "anndata.
"tissue_hires_scalef": row["scale_factor"]
} # default to `tissue_hires_scalef` for now

obj.obsm["spatial"] = np.column_stack([self.spatial_coordinates[axis] for axis in self.spatial_coords_names])
if len(self.spatial_coordinates) > 0:
coords_by_axis = [self.spatial_coordinates[axis] for axis in self.spatial_coords_names]
obj.obsm["spatial"] = np.column_stack(coords_by_axis)

return obj, alt_exps

Expand Down
13 changes: 12 additions & 1 deletion tests/test_to_anndata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest
from copy import deepcopy
from pathlib import Path
import pytest
import anndata as ad

from spatialexperiment import SpatialExperiment

__author__ = "keviny2"
__copyright__ = "keviny2"
Expand Down Expand Up @@ -28,6 +31,14 @@ def test_to_anndata(spe):
assert obj.obsm['spatial'].shape == (500, 2)


def test_to_anndata_empty():
tspe = SpatialExperiment()

obj, alt_exps = tspe.to_anndata()

assert isinstance(obj, ad.AnnData)


def test_to_anndata_spatial_key_exists(spe):
tspe = deepcopy(spe)

Expand Down