troutpy.pl.coupled_scatter#
- troutpy.pl.coupled_scatter(sdata, layer='extracellular_transcripts', output_path='', transcript_group='distance_to_source_cell', save=True, format='pdf', xcoord='x', ycoord='y', xcellcoord='x_centroid', ycellcoord='y_centroid', colormap='Blues', size=2, color_cells='red', figsize=(10, 7), vmax=None)#
Plots a scatter plot of transcript locations and cell centroids, coloring the transcripts by a specific feature (e.g., distance to the closest cell) and optionally saving the plot to a file.
- Parameters:
sdata (spatialdata.SpatialData) – A spatial data object that contains transcript and cell information.
layer (str) – The key for the layer in
sdata.pointsthat contains transcript data (default: ‘extracellular_transcripts’).output_path (str) – The directory path where the plot will be saved. If not provided, the plot will not be saved (default: ‘’).
transcript_group (str) – The key in the transcript data (e.g., distance to the source cell) to be used for coloring the scatter plot (default: ‘distance_to_source_cell’).
save (bool) – Whether to save the plot to a file. If
True, the plot is saved tooutput_path(default: True).format (str) – The format for saving the plot (e.g., ‘pdf’, ‘png’). This is only used if
save=True(default: ‘pdf’).xcoord (str) – The column name in the transcript data representing the x-coordinate (default: ‘x’).
ycoord (str) – The column name in the transcript data representing the y-coordinate (default: ‘y’).
xcellcoord (str) – The column name in the cell data representing the x-coordinate of cell centroids (default: ‘x_centroid’).
ycellcoord (str) – The column name in the cell data representing the y-coordinate of cell centroids (default: ‘y_centroid’).
colormap (str) – The colormap to use for coloring the transcripts based on the
transcript_groupvalues (default: ‘Blues’).size (float) – The size of the scatter points for cells and transcripts. Transcripts are scaled down by 0.1 (default: 2).
color_cells (str) – The color to use for the cell centroids (default: ‘red’).
figsize (tuple) – The size of the figure in inches (width, height). This controls the dimensions of the plot (default: (10, 7)).
vmax (float) – The upper limit for the colormap. If provided, this limits the color scale to values below
vmax(default: None).
- Returns:
None
Notes
The transcript data and cell centroid data are extracted from
sdata.The
vmaxparameter allows control over the maximum value of the color scale for better visualization control.The plot is saved in the specified format and at the specified output path if
save=True.