troutpy.pl.point_metric_comparison#
- troutpy.pl.point_metric_comparison(sdata, points_key='transcripts', x_col='cosine_similarity', y_col='cosine_sim_stainings', hue_col='enrichment_class', gene_key='gene', gene_list=None, subsample_fraction=None, table_key='table', structure_table_key='structure_table', source_table_key='source_score', palette_name='30colors', continuous_palette='viridis', s=2.0, alpha=0.3, figsize=(7, 6), title=None, show_consensus=True, seed=42)#
Plot a joint scatter/KDE comparison of two point-level metrics, colored by a third variable.
Builds a
seaborn.JointGridcomparingx_colandy_colfromsdata[points_key], colored or grouped byhue_col. Any ofx_col,y_col, orhue_colnot already present in the points table is looked up fromsdata[source_table_key],sdata[structure_table_key], orsdata[table_key](in that order) viastructure_id/cell_idmappings.- Parameters:
sdata (
SpatialData) – SpatialData object containing the points element and the tables referenced bytable_key,structure_table_key, andsource_table_key.points_key (
str(default:'transcripts')) – Key of the points element insdata.x_col (
str(default:'cosine_similarity')) – Column to plot on the x-axis.y_col (
str(default:'cosine_sim_stainings')) – Column to plot on the y-axis.hue_col (
str(default:'enrichment_class')) – Column used to color/group points. If numeric, points are colored on a continuous scale; otherwise treated as categorical.gene_key (
str(default:'gene')) – Column in the points table containing gene names.gene_list (
Optional[list[str]] (default:None)) – If provided, restrict the plot to points of these genes.subsample_fraction (
Optional[float] (default:None)) – If provided and less than 1, randomly subsample the points to this fraction before plotting.table_key (
str(default:'table')) – Key of the cell-level table insdata, used as a fallback source forx_col/y_col/hue_col.structure_table_key (
str(default:'structure_table')) – Key of the segmentation-free structure table insdata, used as a fallback source forx_col/y_col/hue_colviastructure_id.source_table_key (
str(default:'source_score')) – Key of the source-score table insdata, used as a fallback source forx_col/y_col/hue_col.palette_name (
str(default:'30colors')) – Palette for categoricalhue_colvalues, resolved viatroutpy.pl.get_palette(), or colormap name for numerichue_col.continuous_palette (
str(default:'viridis')) – Fallback continuous colormap used whenpalette_nameis not a valid matplotlib colormap andhue_colis numeric.s (
float(default:2.0)) – Marker size for the scatter plot.alpha (
float(default:0.3)) – Transparency of the scatter points.figsize (
tuple[float,float] (default:(7, 6))) – Size of the figure.title (
Optional[str] (default:None)) – Custom title for the plot. IfNone, a title is generated fromx_col,y_col, andhue_col.show_consensus (
bool(default:True)) – IfTrueand both axes range over roughly[0, 1], draw a diagonal consensus (y = x) reference line.seed (
int(default:42)) – Random seed used for subsampling, ifsubsample_fractionis set.
- Return type:
- Returns:
The joint grid containing the plot.