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
13 changes: 8 additions & 5 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
repository-projects: write
contents: write
pages: write

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -45,8 +50,6 @@ jobs:
run: |
python -m tox -e clean,build

- name: Publish package
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# This uses the trusted publisher workflow so no token is required.
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

A Python package for storing and analyzing spatial-omics experimental data. This package provide the `SpatialFeatureExperiment` class, based on the [R package and class](https://github.com/pachterlab/SpatialFeatureExperiment).

> [!NOTE]
>
> This package is not published to PyPI.

## Install

To get started, install the package from [PyPI](https://pypi.org/project/SpatialFeatureExperiment/)
Expand All @@ -17,6 +13,30 @@ To get started, install the package from [PyPI](https://pypi.org/project/Spatial
pip install spatialfeatureexperiment
```

## Quick Usage

This package uses shapely and geopandas to support the `*_geometries` slots.

```python
from spatialexperiment import SpatialFeatureExperiment
import numpy as np
import geopandas as gpd
from shapely.geometry import Polygon

nrows = 200
ncols = 500
counts = np.random.rand(nrows, ncols)
polys = gpd.GeoSeries(
[
Polygon([(1, -1), (1, 0), (0, 0)]),
Polygon([(3, -1), (4, 0), (3, 1)]),
]
)

colgeoms = {"polygons" : gpd.GeoDataFrame({"geometry": polys})}
tspe = SpatialFeatureExperiment(assays={"spots": counts}, col_geometries=colgeoms)
```

<!-- biocsetup-notes -->

## Note
Expand Down
14 changes: 7 additions & 7 deletions tests/test_pSFE.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from PIL import Image
from spatialexperiment import ProxySpatialFeatureExperiment
from spatialfeatureexperiment import SpatialFeatureExperiment
import numpy as np
import geopandas as gpd
from shapely.geometry import Polygon
Expand All @@ -13,14 +13,14 @@ def test_init_basic():
nrows = 200
ncols = 500
counts = np.random.rand(nrows, ncols)
tspe = ProxySpatialFeatureExperiment(assays={"spots": counts})
tspe = SpatialFeatureExperiment(assays={"spots": counts})

assert isinstance(tspe, ProxySpatialFeatureExperiment)
assert isinstance(tspe, SpatialFeatureExperiment)

def test_init_empty():
tspe = ProxySpatialFeatureExperiment()
tspe = SpatialFeatureExperiment()

assert isinstance(tspe, ProxySpatialFeatureExperiment)
assert isinstance(tspe, SpatialFeatureExperiment)

def test_init_with_col_geoms():
nrows = 200
Expand All @@ -34,6 +34,6 @@ def test_init_with_col_geoms():
)

colgeoms = {"polygons" : gpd.GeoDataFrame({"geometry": polys})}
tspe = ProxySpatialFeatureExperiment(assays={"spots": counts}, col_geometries=colgeoms)
tspe = SpatialFeatureExperiment(assays={"spots": counts}, col_geometries=colgeoms)

assert isinstance(tspe, ProxySpatialFeatureExperiment)
assert isinstance(tspe, SpatialFeatureExperiment)