troutpy.pl.urna_vs_source_score

troutpy.pl.urna_vs_source_score#

troutpy.pl.urna_vs_source_score(sdata, y_var='extracellular_proportion', y_label=None, title=None, grid=False, saving_path=None, lfc_thresh=2, x_thresh=None, y_thresh=None, top_x_genes=None, bottom_x_genes=None, top_y_genes=None, bottom_y_genes=None, color='#1ad6b4', point_size=2, figsize=(6, 6), xlim=(0.5, 1.1), ylim=None, filename=None)#

Plot a per-gene Y-axis variable from xrna_metadata.var against the mean source score.

Genes are first filtered by logfoldchange_over_noise and can optionally be labeled based on coordinate thresholds and/or rank (top/bottom genes along either axis).

Parameters:
  • sdata (SpatialData) – Spatial data object containing source_score and xrna_metadata tables.

  • y_var (str (default: 'extracellular_proportion')) – Column name from sdata["xrna_metadata"].var to plot on the y-axis.

  • y_label (Optional[str] (default: None)) – Custom label for the y-axis. If None, defaults to "uRNA proportion" for "extracellular_proportion", otherwise defaults to y_var.

  • title (Optional[str] (default: None)) – Title to display at the top of the plot.

  • grid (bool (default: False)) – Whether to show background grid lines.

  • saving_path (Optional[str] (default: None)) – Directory to save the plot in. If None, the plot is not saved.

  • lfc_thresh (float (default: 2)) – Minimum logfoldchange_over_noise for a gene to be included.

  • x_thresh (Optional[float] (default: None)) – If set, genes with a mean source score below this value are labeled.

  • y_thresh (Optional[float] (default: None)) – If set, genes with y_var above this value are labeled.

  • top_x_genes (Optional[int] (default: None)) – Number of genes with the highest mean source score to label.

  • bottom_x_genes (Optional[int] (default: None)) – Number of genes with the lowest mean source score to label.

  • top_y_genes (Optional[int] (default: None)) – Number of genes with the highest y_var to label.

  • bottom_y_genes (Optional[int] (default: None)) – Number of genes with the lowest y_var to label.

  • color (str (default: '#1ad6b4')) – Color of the scatter points.

  • point_size (float (default: 2)) – Size of the scatter points.

  • figsize (tuple[float, float] (default: (6, 6))) – Size of the figure.

  • xlim (tuple[float, float] | None (default: (0.5, 1.1))) – x-axis limits.

  • ylim (Optional[tuple[float, float]] (default: None)) – y-axis limits.

  • filename (Optional[str] (default: None)) – Filename to save the plot as. Defaults to f"scatter_{y_var}_vs_source_score.pdf".

Return type:

None

Returns:

None