liana.pl.annulus#
- liana.pl.annulus(adata, spatial_key='spatial', radius_step=20.0, annulus_steps=1, extend_first_annulus=True, n_rings=10, seed=1337, figure_size=(6, 6), return_fig=True)#
Visualise concentric annuli around a randomly chosen cell on a tissue section.
Useful for inspecting the local neighbourhood structure and choosing sensible
radius_step/annulus_stepsparameters before running spatial statistics (e.g. cross-PCF or LRIC).- Parameters:
- adata
AnnData Annotated data object.
- spatial_key
str(default:'spatial') Key in
adata.obsmthat contains the spatial coordinates.- radius_step
float(default:20.0) Step size between successive ring inner radii (in the same units as the spatial coordinates, e.g. µm).
- annulus_steps
int(default:1) Ring width of each annulus, in units of
radius_step(width =annulus_steps * radius_step).1(default) gives disjoint annuli that tile the range without gaps or overlap;> 1gives overlapping annuli – aannulus_steps-wide moving window over the same tiles, i.e. a smoothedg(r).- extend_first_annulus
bool(default:True) If
True(default), draw the innermost ring from radius 0 (spanning[0, (1 + annulus_steps) * radius_step)) to mirror the merged first bin used byliana.mt.lric/liana.mt.cross_pcf.Falsestarts the first ring atradius_step.- n_rings
int(default:10) Number of concentric rings to draw.
- seed
int(default:1337) Random seed for reproducibility.
- figure_size
tuple[float,float] (default:(6, 6)) Figure x,y size
- return_fig
bool(default:True) boolwhether to return the fig object.
- adata
- Return type:
- Returns:
The resulting figure, unless
return_figisFalse.- Raises:
KeyError – If
spatial_keyis not found inadata.obsm.
Examples
Draws the annuli that
liana.mt.cross_pcfandliana.mt.lricbin distances into, around one seeded random cell, with the number of cells falling in each ring. Use it to sanity-checkradius_stepandannulus_stepsagainst the density of the tissue:>>> import liana as li >>> adata = li.ds.generate_toy_spatial() >>> fig = li.pl.annulus(adata, radius_step=200, n_rings=4)