troutpy.pl.gene_distribution_from_source

troutpy.pl.gene_distribution_from_source#

troutpy.pl.gene_distribution_from_source(sdata, cool_pattern, gene_key='gene', distance_key='distance', bins=30, bar_color='lightblue', n_cols=3)#

Plot the diffusion distance distribution of specified genes as subplots in a grid.

Each subplot shows the empirical histogram of distances for one gene, overlaid with the Rayleigh distribution fitted globally (across all genes) and the Rayleigh distribution fitted to that gene alone.

Parameters:
  • sdata (SpatialData) – The spatial dataset containing gene expression and diffusion data.

  • cool_pattern (list[str]) – List of gene names to analyze.

  • gene_key (str (default: 'gene')) – Column name for gene features.

  • distance_key (str (default: 'distance')) – Column name for distance values.

  • bins (int (default: 30)) – Number of bins for the histogram.

  • bar_color (str (default: 'lightblue')) – Color of the histogram bars.

  • n_cols (int (default: 3)) – Number of columns in the subplot grid.

Return type:

None

Returns:

None

Raises:

ValueError – If no valid distance values, or none of cool_pattern, are found in the dataset.