Skip to content

Commit 407516c

Browse files
Merge pull request #239 from migueLib/cli-2spatialdata
Add CLI for spatialdata_io.
2 parents a5dfb92 + fe30019 commit 407516c

18 files changed

Lines changed: 1088 additions & 34 deletions

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repos:
1010
rev: 24.10.0
1111
hooks:
1212
- id: black
13-
- repo: https://github.com/pre-commit/mirrors-prettier
14-
rev: v4.0.0-alpha.8
13+
- repo: https://github.com/rbubley/mirrors-prettier
14+
rev: v3.4.2
1515
hooks:
1616
- id: prettier
1717
- repo: https://github.com/asottile/blacken-docs

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,18 @@ Technologies that can be read into `SpatialData` objects using third-party libra
8686
This library is community maintained and is not officially endorsed by the aforementioned spatial technology companies. As such, we cannot offer any warranty of the correctness of the representation. Furthermore, we cannot ensure the correctness of the readers for every data version as the technologies evolve and update their formats. If you find a bug or notice a misrepresentation of the data please report it via our [Bug Tracking System](https://github.com/scverse/spatialdata-io/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen) so that it can be addressed either by the maintainers of this library or by the community.
8787

8888
## Solutions to common problems
89+
8990
### Problem: I cannot visualize the data, everything is slow
90-
Solution: after parsing the data with `spatialdata-io` readers, you need to write it to Zarr and read it again. Otherwise the performance advantage given by the SpatialData Zarr format will not available.
91+
92+
Solution: after parsing the data with `spatialdata-io` readers, you need to write it to Zarr and read it again. Otherwise the performance advantage given by the SpatialData Zarr format will not available.
93+
9194
```python
9295
from spatialdata_io import xenium
9396
from spatialdata import read_zarr
9497

95-
sdata = xenium('raw_data')
96-
sdata.write('data.zarr')
97-
sdata = read_zarr('sdata.zarr')
98+
sdata = xenium("raw_data")
99+
sdata.write("data.zarr")
100+
sdata = read_zarr("sdata.zarr")
98101
```
99102

100103
## Citation

docs/api.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# API
22

3+
This section documents the Application Programming Interface (API) for the `spatialdata_io` package.
4+
35
```{eval-rst}
46
.. module:: spatialdata_io
57
```
@@ -10,6 +12,8 @@ I/O for the `spatialdata` project.
1012

1113
### Readers
1214

15+
#### Spatial technologies
16+
1317
```{eval-rst}
1418
.. autosummary::
1519
:toctree: generated
@@ -18,6 +22,7 @@ I/O for the `spatialdata` project.
1822
cosmx
1923
curio
2024
dbit
25+
experimental.iss
2126
mcmicro
2227
merscope
2328
seqfish
@@ -28,15 +33,15 @@ I/O for the `spatialdata` project.
2833
xenium
2934
```
3035

31-
### Experimental readers
36+
#### Data types
3237

3338
```{eval-rst}
34-
.. currentmodule:: spatialdata_io.experimental
35-
3639
.. autosummary::
3740
:toctree: generated
3841
39-
iss
42+
generic
43+
image
44+
geojson
4045
```
4146

4247
### Conversion functions
@@ -47,18 +52,8 @@ I/O for the `spatialdata` project.
4752
.. autosummary::
4853
:toctree: generated
4954
50-
```
51-
52-
### Experimental conversion functions
53-
54-
```{eval-rst}
55-
.. currentmodule:: spatialdata_io.experimental
56-
57-
.. autosummary::
58-
:toctree: generated
59-
60-
from_legacy_anndata
61-
to_legacy_anndata
55+
experimental.from_legacy_anndata
56+
experimental.to_legacy_anndata
6257
```
6358

6459
### Utility functions

docs/cli.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# CLI
2+
3+
This section documents the Command Line Interface (CLI) for the `spatialdata_io` package.
4+
5+
```{eval-rst}
6+
.. click:: spatialdata_io.__main__:cli
7+
:prog: spatialdata_io
8+
:nested: full
9+
```

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"sphinx_autodoc_typehints",
5858
"sphinx.ext.mathjax",
5959
"IPython.sphinxext.ipython_console_highlighting",
60+
"sphinx_click",
6061
*[p.stem for p in (HERE / "extensions").glob("*.py")],
6162
]
6263

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:maxdepth: 1
88
99
api.md
10+
cli.md
1011
changelog.md
1112
template_usage.md
1213
contributing.md

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ urls.Source = "https://github.com/scverse/spatialdata-io"
2323
urls.Home-page = "https://github.com/scverse/spatialdata-io"
2424
dependencies = [
2525
"anndata",
26+
"click",
2627
"numpy",
2728
"scanpy",
2829
"spatialdata>=0.2.6",
@@ -50,6 +51,7 @@ doc = [
5051
"sphinxcontrib-bibtex>=1.0.0",
5152
"sphinx-autodoc-typehints",
5253
"sphinx-design",
54+
"sphinx-click",
5355
# For notebooks
5456
"ipython>=8.6.0",
5557
"sphinx-copybutton",

src/spatialdata_io/__init__.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from importlib.metadata import version
22

3+
from spatialdata_io.converters.generic_to_zarr import generic_to_zarr
34
from spatialdata_io.readers.codex import codex
45
from spatialdata_io.readers.cosmx import cosmx
56
from spatialdata_io.readers.curio import curio
67
from spatialdata_io.readers.dbit import dbit
8+
from spatialdata_io.readers.generic import generic, geojson, image
79
from spatialdata_io.readers.macsima import macsima
810
from spatialdata_io.readers.mcmicro import mcmicro
911
from spatialdata_io.readers.merscope import merscope
@@ -18,22 +20,42 @@
1820
xenium_explorer_selection,
1921
)
2022

21-
__all__ = [
22-
"curio",
23-
"seqfish",
24-
"visium",
25-
"xenium",
23+
_readers_technologies = [
2624
"codex",
2725
"cosmx",
26+
"curio",
27+
"dbit",
28+
"macsima",
2829
"mcmicro",
30+
"merscope",
31+
"seqfish",
2932
"steinbock",
3033
"stereoseq",
31-
"merscope",
32-
"xenium_aligned_image",
33-
"xenium_explorer_selection",
34-
"dbit",
34+
"visium",
3535
"visium_hd",
36-
"macsima",
36+
"xenium",
3737
]
3838

39+
_readers_file_types = [
40+
"generic",
41+
"image",
42+
"geojson",
43+
]
44+
45+
_converters = [
46+
"generic_to_zarr",
47+
]
48+
49+
50+
__all__ = (
51+
[
52+
"xenium_aligned_image",
53+
"xenium_explorer_selection",
54+
]
55+
+ _readers_technologies
56+
+ _readers_file_types
57+
+ _converters
58+
)
59+
60+
3961
__version__ = version("spatialdata-io")

0 commit comments

Comments
 (0)