Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new spatial foundational types #219

Merged
merged 24 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c7f1c6
Add new spatial datatypes to SOMA
jp-dark Sep 13, 2024
7ccefb6
Update MultiscaleImage docstring and other small updates
jp-dark Sep 13, 2024
462678a
Move docstring updates
jp-dark Sep 13, 2024
5ed68f7
Update python-spec/src/somacore/spatialdata.py
jp-dark Sep 19, 2024
ff83352
Fix docstring for spatialdata read_region
jp-dark Sep 19, 2024
d681d32
Remove SpatialDataFrame from spec
jp-dark Sep 19, 2024
d520396
Rename `spatialdata.py` -> `spatialdata`
jp-dark Sep 24, 2024
616beaf
Add coordinate space to PointCloud and GeometryDataFrame
jp-dark Sep 24, 2024
4985a42
Remove the `extra_coords` param in `read_region`
jp-dark Sep 24, 2024
953512b
Rename param `transform` -> `region_transform` in `read_region`
jp-dark Sep 24, 2024
a881e0c
Match `axis_names` order in `MultiscaleImage` to `image_type` order
jp-dark Sep 24, 2024
b907c53
Fix typo in ValueError
jp-dark Sep 24, 2024
77a3a35
Drop `create_mask` option from `DenseArray.read_region`
jp-dark Sep 24, 2024
89e970b
Merge branch 'main' into dark/spatial-datatypes
jp-dark Sep 24, 2024
d2cb621
Fix shapely type for SpatialRegion
jp-dark Sep 25, 2024
78b980f
Run linters
jp-dark Sep 25, 2024
69c585c
Replace 'image_type' with 'axis_types'
jp-dark Sep 25, 2024
4f36f8e
Fix typo in docstring
jp-dark Sep 26, 2024
4843ba6
Add clarity to docstring
jp-dark Sep 26, 2024
5bd118a
Fix typos and improve clarity in docstrings
jp-dark Sep 26, 2024
0e8ee9b
Rename `read_region` to `read_spatial_region`
jp-dark Sep 26, 2024
76f07c7
Replace `_transformation_` with `_transform_` in method names
jp-dark Sep 26, 2024
e485020
Fix incomplete docstring
jp-dark Sep 26, 2024
531af3d
Expand spatial dataframe docstrings (#230)
aaronwolen Sep 26, 2024
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
Prev Previous commit
Next Next commit
Move docstring updates
jp-dark committed Sep 18, 2024
commit 462678a41a78da4fdb396047ddd86b232cd79894
50 changes: 22 additions & 28 deletions python-spec/src/somacore/spatialdata.py
Original file line number Diff line number Diff line change
@@ -97,22 +97,23 @@ def read_region(
value_filter: Optional[str] = None,
platform_config: Optional[options.PlatformConfig] = None,
) -> "SpatialRead[data.ReadIter[pa.Table]]":
"""Reads a user-defined slice of data into Arrow tables.
"""Reads a data intersecting an user-defined region into a
:class:`SpatialRead` with data in Arrow tables.

TODO: Add details about the requested input region.
TODO: Add details about the output SpatialReadIter.

Args:
region: for each index dimension, which rows to read or a single shape.
Defaults to ``()``, meaning no constraint -- all IDs.
region: The region to query. May be a box in the form
[x_min, y_min, x_max, y_max] (for 2D images), a box in the form
[x_min, y_min, z_min, x_max, y_max, z_max] (for 3D images), or
a shapely Geometry.
column_names: the named columns to read and return.
Defaults to ``None``, meaning no constraint -- all column names.
extra_coords: a name to coordinate mapping non-spatial index columns.
Defaults to selecting entire region for non-spatial coordinates.
transform: coordinate transform to apply to results.
transform: An optional coordinate transform that provides desribes the
Defaults to ``None``, meaning an identity transform.
region_coord_space: the coordinate space of the region being read.
Defaults to ``None``, coordinate space will be infer from transform.
region_coord_space: An optional coordinate space for the region being read.
Defaults to ``None``, coordinate space will be inferred from transform.
batch_size: The size of batched reads.
Defaults to `unbatched`.
partitions: If present, specifies that this is part of
@@ -125,7 +126,7 @@ def read_region(
for the particular SOMA implementation for details.

Returns:
A :class:`ReadIter` of :class:`pa.Table`s.
A :class:`SpatialRead` with :class:`ReadIter` of :class:`pa.Table`s data.

Lifecycle: experimental
"""
@@ -229,20 +230,16 @@ def create(

Args:
uri: The URI where the dataframe will be created.

schema: Arrow schema defining the per-column schema. This schema
must define all columns, including columns to be named as index
columns. If the schema includes types unsupported by the SOMA
implementation, an error will be raised.

index_column_names: A list of column names to use as user-defined index
columns (e.g., ``['x', 'y']``). All named columns must exist in the
schema, and at least one index column name is required.

axis_names: An ordered list of axis column names that
coorespond to the names of axes of the the coordinate space the points
are defined on.

axis_names: An ordered list of axis column names that correspond to the
names of axes of the the coordinate space the points are defined on.
Must be the name of index columns.
domain: An optional sequence of tuples specifying the domain of each
index column. Each tuple should be a pair consisting of the minimum
and maximum values storable in the index column. If omitted entirely,
@@ -299,21 +296,17 @@ def create(

Args:
uri: The URI where the dataframe will be created.

schema: Arrow schema defining the per-column schema. This schema
must define all columns, including columns to be named as index
columns. If the schema includes types unsupported by the SOMA
implementation, an error will be raised.

index_column_names: A list of column names to use as user-defined
index columns (e.g., ``['cell_type', 'tissue_type']``).
All named columns must exist in the schema, and at least one
index column name is required.

axis_names: An ordered list of axis column names that
coorespond to the names of the axes of the coordinate space the
geometries are defined on.

axis_names: An ordered list of axis column names that correspond to the
names of the axes of the coordinate space the geometries are defined
on.
domain: An optional sequence of tuples specifying the domain of each
index column. Two tuples must be provided for the ``soma_geometry``
column which store the width followed by the height. Each tuple should
@@ -425,8 +418,8 @@ def read_region(
result_order: options.ResultOrderStr = _RO_AUTO,
platform_config: Optional[options.PlatformConfig] = None,
) -> "SpatialRead[Union[pa.Tensor, pa.Table]]":
"""Reads a user-defined region into a :class:`SpatialRead` with
:class:`pa.Tensor` or :class:`pa.Table` data.
"""Reads a user-defined region into a :class:`SpatialRead` with data in
either an Arrow tensor or table.

Reads the bounding box of the input region from the requested image level. If
``create_mask=True``, this will return a :class:`SpatialRead` with the image
@@ -444,9 +437,10 @@ def read_region(
to read.
transform: An optional coordinate transform that provides desribes the
transformation from the provided region to the reference level fo this
image.
region_coord_space: An optional coordinate space for the region being
read. The axis names must match the input axis names of the transform.
image. Defaults to ``None``.
region_coord_space: An optional coordinate space for the region being read.
The axis names must match the input axis names of the transform.
Defaults to ``None``, coordinate space will be inferred from transform.
create_mask: If ``True``, return a bitmask for the pixels in the returned
data that intersect the region.
result_order: the order to return results, specified as a