Skip to content

Commit a823740

Browse files
committed
add docstrings
1 parent ac47a13 commit a823740

File tree

2 files changed

+111
-62
lines changed

2 files changed

+111
-62
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
"python": ("https://docs.python.org/3", None),
9191
"anndata": ("https://anndata.readthedocs.io/en/stable/", None),
9292
"numpy": ("https://numpy.org/doc/stable/", None),
93+
"matplotlib": ("https://matplotlib.org/stable/", None),
94+
"spatialdata": ("https://scverse-spatialdata.readthedocs.io/en/latest/", None),
9395
}
9496

9597
# List of patterns, relative to source directory, that match files and

src/spatialdata_plot/pl/basic.py

Lines changed: 109 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,46 @@ def render_shapes(
154154
**kwargs: Any,
155155
) -> sd.SpatialData:
156156
"""
157-
Render the shapes contained in the given sd.SpatialData object
157+
Render shapes elements in SpatialData.
158158
159159
Parameters
160160
----------
161-
self :
162-
The sd.SpatialData object.
163-
palette :
164-
A list of colors to use for rendering the images. If `None`, the
165-
default colors will be used.
166-
instance_key :
167-
The name of the column in the table that identifies individual shapes
168-
color_key :
169-
The name of the column in the table to use for coloring shapes.
161+
element
162+
The name of the shapes element to render. If `None`, the first
163+
shapes element in the `SpatialData` object will be used.
164+
color
165+
Key for annotations in :attr:`anndata.AnnData.obs` or variables/genes.
166+
groups
167+
For discrete annotation in ``color``, select which values
168+
to plot (other values are set to NAs).
169+
size
170+
Value to scale circles, if present.
171+
outline
172+
If `True`, a thin border around points/shapes is plotted.
173+
outline_width
174+
Width of the border.
175+
outline_color
176+
Color of the border.
177+
alt_var
178+
Which column to use in :attr:`anndata.AnnData.var` to select alternative ``var_name``.
179+
layer
180+
Key in :attr:`anndata.AnnData.layers` or `None` for :attr:`anndata.AnnData.X`.
181+
palette
182+
Palette for discrete annotations, see :class:`matplotlib.colors.Colormap`.
183+
cmap
184+
Colormap for continuous annotations, see :class:`matplotlib.colors.Colormap`.
185+
norm
186+
Colormap normalization for continuous annotations, see :class:`matplotlib.colors.Normalize`.
187+
na_color
188+
Color to be used for NAs values, if present.
189+
alpha
190+
Alpha value for the shapes.
191+
kwargs
192+
Additional arguments to be passed to cmap and norm.
170193
171194
Returns
172195
-------
173-
sd.SpatialData
174-
The input sd.SpatialData with a command added to the plotting tree
196+
None
175197
"""
176198
sdata = self._copy()
177199
sdata = _verify_plotting_tree(sdata)
@@ -210,25 +232,37 @@ def render_points(
210232
alpha: float = 1.0,
211233
**kwargs: Any,
212234
) -> sd.SpatialData:
213-
"""Render the points contained in the given sd.SpatialData object
235+
"""
236+
Render points elements in SpatialData.
214237
215238
Parameters
216239
----------
217-
self :
218-
The sd.SpatialData object.
219-
palette :
220-
A list of colors to use for rendering the images. If `None`, the
221-
default colors will be used.
222-
instance_key :
223-
The name of the column in the table that identifies individual shapes
224-
color : str or None, optional (default: None)
225-
The name of the column in the table to use for coloring shapes.
240+
element
241+
The name of the points element to render. If `None`, the first
242+
shapes element in the `SpatialData` object will be used.
243+
color
244+
Key for annotations in :attr:`anndata.AnnData.obs` or variables/genes.
245+
groups
246+
For discrete annotation in ``color``, select which values
247+
to plot (other values are set to NAs).
248+
size
249+
Value to scale points.
250+
palette
251+
Palette for discrete annotations, see :class:`matplotlib.colors.Colormap`.
252+
cmap
253+
Colormap for continuous annotations, see :class:`matplotlib.colors.Colormap`.
254+
norm
255+
Colormap normalization for continuous annotations, see :class:`matplotlib.colors.Normalize`.
256+
na_color
257+
Color to be used for NAs values, if present.
258+
alpha
259+
Alpha value for the shapes.
260+
kwargs
261+
Additional arguments to be passed to cmap and norm.
226262
227263
Returns
228264
-------
229-
sd.SpatialData
230-
The input sd.SpatialData with a command added to the plotting tree
231-
265+
None
232266
"""
233267
sdata = self._copy()
234268
sdata = _verify_plotting_tree(sdata)
@@ -261,24 +295,30 @@ def render_images(
261295
alpha: float = 1.0,
262296
**kwargs: Any,
263297
) -> sd.SpatialData:
264-
"""Render the images contained in the given sd.SpatialData object
298+
"""
299+
Render image elements in SpatialData.
265300
266301
Parameters
267302
----------
268-
self :
269-
The sd.SpatialData object.
270-
palette :
271-
A list of colors to use for rendering the images. If `None`, the
272-
default colors will be used.
273-
trans_fun :
274-
A function to apply to the images before rendering. If `None`, no
275-
function will be applied.
303+
element
304+
The name of the image element to render. If `None`, the first
305+
shapes element in the `SpatialData` object will be used.
306+
channel
307+
To select which channel to plot (all by default).
308+
cmap
309+
Colormap for continuous annotations, see :class:`matplotlib.colors.Colormap`.
310+
norm
311+
Colormap normalization for continuous annotations, see :class:`matplotlib.colors.Normalize`.
312+
na_color
313+
Color to be used for NAs values, if present.
314+
alpha
315+
Alpha value for the shapes.
316+
kwargs
317+
Additional arguments to be passed to cmap and norm.
276318
277319
Returns
278320
-------
279-
sd.SpatialData
280-
The input sd.SpatialData with a command added to the plotting tree
281-
321+
None
282322
"""
283323
sdata = self._copy()
284324
sdata = _verify_plotting_tree(sdata)
@@ -315,37 +355,44 @@ def render_labels(
315355
alpha: float = 1.0,
316356
**kwargs: Any,
317357
) -> sd.SpatialData:
318-
"""Render the labels contained in the given sd.SpatialData object
358+
"""
359+
Render labels elements in SpatialData.
319360
320361
Parameters
321362
----------
322-
self :
323-
sd.SpatialData
324-
instance_key :
325-
The name of the column in the table that identifies individual labels
363+
element
364+
The name of the labels element to render. If `None`, the first
365+
labels element in the `SpatialData` object will be used.
366+
color
367+
Key for annotations in :attr:`anndata.AnnData.obs` or variables/genes.
368+
groups
369+
For discrete annotation in ``color``, select which values
370+
to plot (other values are set to NAs).
371+
contour_px
372+
Draw contour of specified width for each segment. If `None`, fills
373+
entire segment, see :func:`skimage.morphology.erosion`.
374+
outline
375+
Whether to plot boundaries around segmentation masks.
376+
alt_var
377+
Which column to use in :attr:`anndata.AnnData.var` to select alternative ``var_name``.
378+
layer
379+
Key in :attr:`anndata.AnnData.layers` or `None` for :attr:`anndata.AnnData.X`.
380+
palette
381+
Palette for discrete annotations, see :class:`matplotlib.colors.Colormap`.
382+
cmap
383+
Colormap for continuous annotations, see :class:`matplotlib.colors.Colormap`.
384+
norm
385+
Colormap normalization for continuous annotations, see :class:`matplotlib.colors.Normalize`.
386+
na_color
387+
Color to be used for NAs values, if present.
388+
alpha
389+
Alpha value for the labels.
390+
kwargs
391+
Additional arguments to be passed to cmap and norm.
326392
327393
Returns
328394
-------
329-
sd.SpatialData
330-
The input sd.SpatialData with a command added to the plotting tree
331-
332-
Raises
333-
------
334-
TypeError
335-
If any of the parameters have an invalid type.
336-
ValueError
337-
If any of the parameters have an invalid value.
338-
If the provided instance_key or color_key is not a valid table column.
339-
If the provided mode is not one of 'thick', 'inner', 'outer', or
340-
'subpixel'.
341-
342-
Notes
343-
-----
344-
This function plots cell labels for a spatialdata object. The cell labels are
345-
based on a column in the table, and can optionally be colored based on another
346-
column in the table. The resulting plot can be customized by specifying the
347-
alpha, color, and rendering mode of the labels, as well as whether to add a
348-
legend to the plot.
395+
None
349396
"""
350397
if (
351398
color is not None

0 commit comments

Comments
 (0)