thor.pl.multiple
- thor.pl.multiple(vars_list, img_masks_list, ax=None, vor=None, palette='tab20', full_res_im=None, ROI_tuple=None, img_alpha=1, figsize=(5, 5), dpi=150, show_legend=True, legend_loc='upper left', show_cbar=False, return_fig=False, show=False, **imshow_kwds)[source]
Color the cells or nuclei with multiple variables.
- Parameters:
vars_list (
list
) – List of variable names to color the cells or nuclei.img_masks_list (
list
ofnumpy.ndarray
) – List of image masks filled with the variable values. Each mask should have the same size as full_res_im.ax (
matplotlib.axes.Axes
, optional) – The Axes object to plot the gene masks. IfNone
, a new figure and Axes will be created.vor (
scipy.spatial.Voronoi
, optional) – The Voronoi diagram object.palette (
str
orlist
ortuple
ornumpy.ndarray
, optional) – The color palette to use for coloring variables. Can be a valid matplotlib colormap name, or a list/tuple/array of colors.full_res_im (
numpy.ndarray
, optional) – The full-size image where the gene expression masks should be plotted.ROI_tuple (
tuple
, optional) – A tuple (left, bottom, width, height) representing the region of interest (ROI) where the gene expression masks should be displayed.img_alpha (
float
, optional) – Alpha value (transparency) of the full_res_im if provided. Default is 1 (fully opaque).figsize (
tuple
, optional) – Figure size in inches (width, height). Default is (5, 5).dpi (
int
, optional) – Dots per inch for the figure. Default is 150.show_legend (
bool
, optional) – Whether to show the legend indicating variables. Default isTrue
.legend_loc (
str
, optional) – Location for the legend. Default is ‘upper left’.show_cbar (
bool
, optional) – Whether to show the colorbar. Default isFalse
.return_fig (
bool
, optional) – IfTrue
, return the Figure object. Default isFalse
.show (
bool
, optional) – IfTrue
, display the plot. IfFalse
, return the Axes object without displaying the plot. Default isFalse
.**imshow_kwds (
dict
, optional) – Additional keyword arguments for customizing the imshow function, such as ‘cmap’, ‘vmin’, ‘vmax’, etc.
- Returns:
If return_fig is
False
and show isFalse
, the function returns the Axes object. If return_fig isTrue
, the function returns the Figure object. If show isTrue
, the function displays the plot and returnsNone
.- Return type:
matplotlib.axes.Axes
ormatplotlib.figure.Figure
, optional
Notes
This function plots multiple gene expression masks within a specified region of interest (ROI) or the entire img_masks_list if ROI_tuple is
None
. Each variable’s mask is color-coded using the provided palette.The function supports showing either a legend indicating the variables (show_legend=True) or a single colorbar (show_cbar=True) for the entire plot. Both options cannot be selected simultaneously.
Examples
>>> import numpy as np
>>> # Assuming `img_masks_list` is a list of numpy arrays representing gene expression masks. >>> # Also, `vor` is a Voronoi diagram object, and `full_res_im` is a numpy array containing the full-size image. >>> pl.multiple(["Gene_X", "Gene_Y"], img_masks_list, vor=vor, full_res_im=full_res_im, ROI_tuple=(10, 20, 30, 40))
>>> # Customizing the plot with optional arguments >>> pl.multiple(["Gene_A", "Gene_B"], img_masks_list, show_legend=False, palette=['red', 'blue'], use_global_vmax=False, figsize=(8, 6))