harpy.pl.plot_transcript_density#
- harpy.pl.plot_transcript_density(sdata, bin_size, points_name, name_gene_column='gene', genes=None, z_plane=None, smooth_sigma=None, cmap='cividis', frac=None, figsize=(8, 8), crd=None, to_coordinate_system='global', colorbar=True, ax=None)#
Plot a transcript density heatmap from a
SpatialDataobject.- Parameters:
sdata (
SpatialData) –SpatialDataobject.bin_size (
float) – Width of a histogram bin in the units ofto_coordinate_system.points_name (
str) – Points element to plot fromsdata.points.name_gene_column (
str|None(default:'gene')) – Column in thepoints_namethat stores gene identities.genes (
str|list[str] |None(default:None)) – Gene or list of genes to visualize. IfNone, all points are used.z_plane (
int|float|None(default:None)) – If provided, filter the points element to rows withz == z_plane. This requires a"z"column on the points element.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().frac (
float|None(default:None)) – Fraction of points to randomly sample for plotting. IfNone, all points inpoints_nameare visualized.figsize (
tuple(default:(8, 8))) – Figure size used whenaxis not provided.crd (
tuple[int,int,int,int] |None(default:None)) – The coordinates for the region of interest in the format(xmin, xmax, ymin, ymax), in the coordinate systemto_coordinate_system.to_coordinate_system (
str(default:'global')) – Coordinate system in whichcrd,bin_size, and the plotted axes are interpreted.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_transcript_density( ... sdata, ... points_name="transcripts_global", ... to_coordinate_system="global_micron", ... bin_size=10, ... )