troutpy.pl.distributions_by_cluster#
- troutpy.pl.distributions_by_cluster(sdata, gene_key='gene', cluster_key='kmeans_distribution', groups=None, distance_key='distance', n_bins=20)#
Plot the average normalized distance distribution for each cluster.
Each cluster’s empirical histogram is overlaid with the theoretical Rayleigh distribution expected from purely diffusive transport, fitted globally across all genes. The plot title reports goodness-of-fit statistics (KS test, MAE) comparing the cluster’s distribution to this expected pattern.
- Parameters:
sdata (
SpatialData) – Spatial data object containingsource_scoreandxrna_metadatatables.gene_key (
str(default:'gene')) – Column name that contains the gene names.cluster_key (
str(default:'kmeans_distribution')) – Column insdata["xrna_metadata"].varcontaining cluster assignments.groups (
Optional[list] (default:None)) – Subset of cluster labels to plot. IfNone, all clusters are plotted.distance_key (
str(default:'distance')) – Column name that contains the distance from the source cell.n_bins (
int(default:20)) – Number of bins to use for the histograms.
- Return type:
- Returns:
None