harpy.pl.plot_instance_density#
- harpy.pl.plot_instance_density(sdata, table_name, labels_name=None, spatial_key='spatial', bin_size=100, smooth_sigma=None, cmap='cividis', figsize=(8, 8), colorbar=True, ax=None)#
Plot an instance density heatmap from centroids stored in
sdata.tables[table_name].obsm[spatial_key].- Parameters:
sdata (
SpatialData) –SpatialDataobject.table_name (
str) – Table element to plot fromsdata.tables.labels_name (
str|list[str] |None(default:None)) – Labels element(s) used to select the instances fromtable_namevia the table region key. IfNone, all observations fromtable_nameare used.spatial_key (
str(default:'spatial')) – Key inadata.obsmcontaining instance centroid coordinates.bin_size (
float(default:100)) – Width of a histogram bin in the coordinate units stored inadata.obsm[spatial_key].smooth_sigma (
float|None(default:None)) – Gaussian smoothing sigma applied to the histogram. IfNone, no smoothing is applied.cmap (
str(default:'cividis')) – Colormap passed tomatplotlib.axes.Axes.imshow().figsize (
tuple(default:(8, 8))) – Figure size used whenaxis not provided.colorbar (
bool(default:True)) – IfTrue, add a colorbar to the figure.ax (
Axes|None(default:None)) –matplotlib.axes.Axesobject to plot on. IfNone, a new axes is created viamatplotlib.pyplot.subplots().
- Return type:
- Returns:
:
matplotlib.axes.Axesobject.
Examples
>>> import harpy as hp >>> sdata = hp.datasets.xenium_human_ovarian_cancer( ... subset=True, ... ) >>> hp.pl.plot_instance_density( ... sdata, ... labels_name="cell_labels_global", ... table_name="table_global", ... )