troutpy.pl.metric_scatter

Contents

troutpy.pl.metric_scatter#

troutpy.pl.metric_scatter(sdata, x, y, size=1, non_control_probes=None, label_top_n_x=0, label_top_n_y=0, label_bottom_n_x=0, label_bottom_n_y=0, title=None, linewidth=0.5, figures_path='', save=False, custom_plot_filename=None, palette='troutpy', group_col='is_control', control_label='Control probes', gene_label='Gene probes', show_control_probes=True)#

Plot a scatter plot of two metrics from sdata["xrna_metadata"].var.

Control and non-control probes are colored differently, and the top/bottom n genes along each axis can be labeled. The figure is saved with Illustrator-editable text (Type 42 fonts) and open x/y axes.

Parameters:
  • sdata (SpatialData) – SpatialData object that contains an xrna_metadata table with a var DataFrame.

  • x (str) – Column in sdata["xrna_metadata"].var to plot on the x-axis.

  • y (str) – Column in sdata["xrna_metadata"].var to plot on the y-axis.

  • size (int (default: 1)) – Marker size.

  • non_control_probes (Optional[list[str]] (default: None)) – If show_control_probes is True, also include these probes even if group_col marks them as controls.

  • label_top_n_x (int (default: 0)) – Number of genes with the highest x values to label.

  • label_top_n_y (int (default: 0)) – Number of genes with the highest y values to label.

  • label_bottom_n_x (int (default: 0)) – Number of genes with the lowest x values to label.

  • label_bottom_n_y (int (default: 0)) – Number of genes with the lowest y values to label.

  • title (Optional[str] (default: None)) – Title for the plot.

  • linewidth (float (default: 0.5)) – Marker edge line width.

  • figures_path (str (default: '')) – Directory path to save the figure.

  • save (bool (default: False)) – Whether to save the figure.

  • custom_plot_filename (Optional[str] (default: None)) – Custom filename for saving the plot.

  • palette (str (default: 'troutpy')) – Two-color palette name, resolved via troutpy.pl.get_palette(). Falls back to a Matplotlib colormap, then to red/blue, if neither is found.

  • group_col (str (default: 'is_control')) – Boolean column in sdata["xrna_metadata"].var distinguishing control probes (True) from gene probes (False).

  • control_label (str (default: 'Control probes')) – Legend label for control probes.

  • gene_label (str (default: 'Gene probes')) – Legend label for gene probes.

  • show_control_probes (bool (default: True)) – Whether to include control probes in the plot.

Return type:

None

Returns:

None