troutpy.pl.spatial_interactions

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)#

Plot the positions of target cells, source cells, and extracellular RNA transcripts for a gene.

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. a tissue section) can be displayed.

Parameters:
  • sdata (SpatialData) – Spatial data object containing the transcript and cell position data.

  • layer (str (default: 'extracellular_transcripts_enriched')) – The layer in sdata.points that contains the extracellular RNA transcript data, with closest_target_cell and closest_source_cell columns.

  • gene (str (default: 'Arc')) – The gene of interest to be visualized in terms of its spatial interaction with source and target cells.

  • gene_key (str (default: 'feature_name')) – The column name used to identify the gene in layer.

  • cell_id_key (str (default: 'cell_id')) – The column name in sdata["table"].obs used to identify individual cells.

  • color_target (str (default: 'blue')) – The color to be used for target cells in the plot.

  • color_source (str (default: 'red')) – The color to be used for source cells in the plot.

  • color_transcript (str (default: 'green')) – The color to be used for the RNA transcripts in the plot.

  • spatial_key (str (default: 'spatial')) – The key in sdata["table"].obsm that stores the spatial coordinates of the cells.

  • img (Union[bool, Sequence, None] (default: None)) – A background image to overlay on the plot, such as a tissue section.

  • img_alpha (Optional[float] (default: None)) – The transparency level of the background image. Ignored if img is None.

  • image_cmap (Optional[Colormap] (default: None)) – The colormap to be used for the background image, if applicable.

  • size (float | Sequence[float] | None (default: 8)) – The size of the scatter plot points for the cells and transcripts.

  • alpha (float (default: 0.6)) – The transparency level for the scatter plot points.

  • title (Union[str, Sequence[str], None] (default: None)) – The title of the plot. If None, the gene name is used.

  • legend_loc (str | None (default: 'best')) – The location of the legend in the plot.

  • figsize (tuple[float, float] (default: (10, 10))) – The dimensions of the plot in inches.

  • dpi (int | None (default: 100)) – The resolution (dots per inch) for the plot.

  • save (Union[str, Path, None] (default: None)) – The path to save the plot image. If None, the plot is displayed but not saved.

  • kwargs – Additional arguments passed to matplotlib.pyplot.scatter() and matplotlib.pyplot.imshow().

Return type:

None

Returns:

None