troutpy.pl.spatial_interactions#
- troutpy.pl.spatial_interactions(sdata, layer='extracellular_transcripts_enriched', gene='Arc', gene_key='feature_name', cell_id_key='cell_id', color_target='blue', color_source='red', color_transcript='green', spatial_key='spatial', img=None, img_alpha=None, image_cmap=None, size=8, alpha=0.6, title=None, legend_loc='best', figsize=(10, 10), dpi=100, save=None, **kwargs)#
Generates a scatter plot showing the positions of target cells, source cells, and extracellular RNA transcripts within a spatial omics dataset. The target and source cells are highlighted in different colors, while the RNA transcripts are shown as points at their respective positions. Optionally, a background image (e.g., tissue section) can be displayed.
- Parameters:
sdata (spatialdata.SpatialData) – An AnnData object containing the spatial omics data, including transcript expression and cell positions.
layer (str) – The layer in the AnnData object that contains the extracellular RNA transcript data.
gene (str) – The gene of interest to be visualized in terms of its spatial interaction with source and target cells.
gene_key (str) – The column name in the AnnData object used to identify the gene.
cell_id_key (str) – The column name in the AnnData object used to identify individual cells.
color_target (str) – The color to be used for target cells in the plot.
color_source (str) – The color to be used for source cells in the plot.
color_transcript (str) – The color to be used for the RNA transcripts in the plot.
spatial_key (str) – The key in the AnnData object that stores the spatial coordinates of the cells.
img (str) – A background image to overlay on the plot, such as a tissue section. Can be set to
Noneto omit.img_alpha (float) – The transparency level of the background image. Ignored if
imgisNone.image_cmap (str) – The colormap to be used for the background image, if applicable.
size (float) – The size of the scatter plot points for the cells and transcripts.
alpha (float) – The transparency level for the scatter plot points.
title (str) – The title of the plot. If
None, the gene name is used.legend_loc (str) – The location of the legend in the plot.
figsize (tuple) – The dimensions of the plot in inches.
dpi (int) – The resolution (dots per inch) for the plot.
save (bool) – The path to save the plot image. If
None, the plot is displayed but not saved.kwargs – Any additional arguments passed to the
scatterorimshowfunctions for customizing plot appearance.
- Returns:
None