troutpy.pl.spatial_transcripts_source#
- troutpy.pl.spatial_transcripts_source(sdata, cell_color_key='leiden', extra_color_key='leiden', gene_list=None, gene_key='gene', separate_compartments=False, use_roi=False, roi=None, padding=0, point_size=0.1, min_score=0.1, show_edges=False, edge_alpha=0.1, fig_bg_color='white', ambient_color='grey', palette='tab20', shapes_key='cell_boundaries', boundary_linewidth=0.5, boundary_zorder=4)#
Plot transcripts colored by intracellular and extracellular source cell type, overlaid on cell boundaries.
Intracellular (“cell body”) transcripts are colored by
cell_color_keyfromsdata["table"].obs. Extracellular transcripts with anassignment_scoreof at leastmin_score(insdata["source_score"].obs) are considered “halo” transcripts and colored byextra_color_key, taken either directly fromsdata["source_score"].obsor, if not present there, via each transcript’s predicted parent cell insdata["table"].obs. Remaining “ambient” transcripts are plotted inambient_color.- Parameters:
sdata (
SpatialData) – SpatialData object containing the"table"and"source_score"tables, the"transcripts"points element, and the cell boundary shapes.cell_color_key (
str(default:'leiden')) – Column insdata["table"].obsused to color intracellular transcripts.extra_color_key (
str(default:'leiden')) – Column used to color extracellular (“halo”) transcripts, looked up insdata["source_score"].obsor, as a fallback, insdata["table"].obs.gene_list (
Union[str,list[str],None] (default:None)) – Specific gene(s) to isolate. If provided, only transcripts of these genes are plotted.gene_key (
str(default:'gene')) – Column in the transcripts table containing gene names.separate_compartments (
bool(default:False)) – IfTrue, intracellular and extracellular transcripts get separate legend entries/colors ("Cell: X"/"Extra: X"); ifFalse, they share a single"Cluster: X"-style legend.use_roi (
bool(default:False)) – Whether to restrict the plot to the region defined byroi.roi (
Optional[tuple[float,float,float,float]] (default:None)) – Region of interest as(xmin, xmax, ymin, ymax), used ifuse_roiisTrue.padding (
float(default:0)) – Ifroiis not used, crop this many units from each side of the full transcript extent.point_size (
float(default:0.1)) – Base marker size for transcripts; foreground (labeled) transcripts are plotted at twice this size.min_score (
float(default:0.1)) – Minimumassignment_scorefor an extracellular transcript to be considered assigned (“halo”) to a cell.show_edges (
bool(default:False)) – Whether to draw edges connecting halo transcripts to their assigned cell’s centroid.edge_alpha (
float(default:0.1)) – Transparency of the edges, ifshow_edgesisTrue.fig_bg_color (
str(default:'white')) – Background color of the figure and axes.ambient_color (
str(default:'grey')) – Color for unassigned (“ambient”) transcripts.palette (
str(default:'tab20')) – Matplotlib colormap name used to assign colors to categories.shapes_key (
str(default:'cell_boundaries')) – Key of the cell boundary shapes element insdata.boundary_linewidth (
float(default:0.5)) – Line width of the cell boundary outlines.boundary_zorder (
int(default:4)) – Z-order of the cell boundary outlines.
- Return type:
- Returns:
The figure and axes containing the plot, or
(None, None)ifgene_listis provided and no transcripts match.