Skip to content

Commit 6ca0df6

Browse files
committed
add interactive_motif API docs
1 parent fc7cc3d commit 6ca0df6

4 files changed

Lines changed: 63 additions & 7 deletions

File tree

SpatialQuery/spatial_query.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,18 +1537,54 @@ def interactive_motif(
15371537
"""
15381538
Create an interactive Vitessce widget to explore spatial motifs.
15391539
1540-
Builds a minimal AnnData containing only cell type labels and spatial
1541-
coordinates from the SpatialQuery object, writes it to a Zarr store,
1542-
and launches the Vitessce widget with the SpatialQueryPlugin.
1540+
Builds a minimal AnnData containing cell type labels, spatial coordinates,
1541+
and (optionally) gene expression from the SpatialQuery object, writes it
1542+
to a Zarr store, and launches a Vitessce widget with the SpatialQueryPlugin.
1543+
The widget provides interactive panels for spatial visualization, cell type
1544+
selection, motif enrichment analysis, and gene expression exploration.
15431545
15441546
Parameters
15451547
----------
15461548
sp : spatial_query
1547-
An initialized SpatialQuery instance.
1549+
An initialized SpatialQuery instance. If ``build_gene_index=False``
1550+
and ``sp.adata`` is not None, gene expression data will be included
1551+
in the widget for feature-level exploration.
15481552
zarr_path : str
1549-
Path where the Zarr store will be written.
1550-
spatialSpotRadius : float, optional
1551-
Radius for spatial spots in the visualization, by default 1.
1553+
Path where the Zarr store will be written. If the path already exists,
1554+
its contents will be overwritten with a warning.
1555+
spatialSpotRadius : float, default=1
1556+
Radius for spatial spots in the Vitessce visualization. Adjust based
1557+
on data density and spatial coordinate scale.
1558+
1559+
Returns
1560+
-------
1561+
ipywidgets.Widget
1562+
A Vitessce widget that can be displayed in a Jupyter notebook.
1563+
The widget contains the following views:
1564+
1565+
- **Spatial view**: scatter plot of cells colored by cell type
1566+
- **Layer controller**: toggle visibility and appearance of layers
1567+
- **Cell sets**: browse and select cell types
1568+
- **SpatialQuery**: interactive motif enrichment query panel
1569+
- **SpatialQuery Heatmap**: heatmap of motif enrichment results
1570+
- **Feature list**: gene selection panel (only when expression data is available)
1571+
1572+
Notes
1573+
-----
1574+
This function requires the ``vitessce`` Python package (with the
1575+
``SpatialQueryPlugin``) to be installed. Install it via::
1576+
1577+
pip install vitessce[all]
1578+
1579+
The generated widget is designed for use in Jupyter notebooks
1580+
(JupyterLab or Jupyter Notebook).
1581+
1582+
Examples
1583+
--------
1584+
>>> from SpatialQuery.spatial_query import spatial_query, interactive_motif
1585+
>>> sq = spatial_query(adata, spatial_key='X_spatial', label_key='cell_type')
1586+
>>> widget = interactive_motif(sq, zarr_path='./my_data.zarr')
1587+
>>> widget
15521588
"""
15531589
import os
15541590
import warnings

docs/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
66
api/single_data
77
api/multi_data
8+
api/visualization
89
```

docs/api/visualization.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Visualization: interactive_motif
2+
3+
```{toctree}
4+
:hidden:
5+
6+
../generated/SpatialQuery.interactive_motif
7+
```
8+
9+
Interactive exploration of spatial motifs using [Vitessce](https://vitessce.io/).
10+
11+
| Method | Description |
12+
|--------|-------------|
13+
| {func}`~SpatialQuery.spatial_query.interactive_motif` | Launch an interactive Vitessce widget to explore spatial motifs |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SpatialQuery.interactive_motif
2+
==============================
3+
4+
.. currentmodule:: SpatialQuery.spatial_query
5+
6+
.. autofunction:: interactive_motif

0 commit comments

Comments
 (0)