monkeybread.plot.ligand_receptor_embedding_zoom

monkeybread.plot.ligand_receptor_embedding_zoom(adata, lr_pair, cell_to_neighbor, color, basis='X_spatial', left_pct=None, top_pct=None, width_pct=None, height_pct=None, palette=None, cmap_name='magma_r', encode_lw=True, max_lw=3.0, max_lw_scale_unzoom=0.1, lr_colorbar=True, axs=None, show=True, **kwargs)

Plot the ligand-receptor co-expression score between pairs of neighboring cells. A line is drawn between each pair of neighbors cells where that line is colored according to the magnitude of their ligand-receptor co-expression score.

The ligand-receptor score is described in [HBB+22]. For a given pair of cells, it is expressed as sqrt(l*r) where l is the expression of the ligand and r is the expression of the receptor.

This function plots the full tissue slice as well as a specified zoomed-in region of the tissue by calling monkeybread.plot.embedding_zoom().

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • cell_to_neighbor (Dict[str, Set[str]]) – A mapping of each cell to its neighbors, as calculated by monkeybread.calc.cell_neighbors().

  • lr_pair (Tuple[str, str]) – A ligand-receptor pair where the ligand is expressed in the cells that act as keys in the cell_to_neighbor dictonary argument and the receptor is is expressed in the cells that are values in the cell_to_neighbor dictonary argument.

  • color (str) – Column in adata.obs used to color cells.

  • basis (Optional[str] (default: 'X_spatial')) – Coordinates in adata.obsm[{basis}] to use. Defaults to spatial.

  • left_pct (Optional[float] (default: None)) – The fraction of the plot width to use as the left bound of the zoomed-in rectangle (e.g. 0.1 represents 10% from the left of the plot)

  • top_pct (Optional[float] (default: None)) – The fraction of the plot height to use as the upper bound of the zoomed-in rectangle (e.g. 0.3 represents 30% from the top of the plot)

  • width_pct (Optional[float] (default: None)) – The fraction of the plot width to use for the zoomed-in rectangle (e.g., 0.5 represents a width half of the original plot)

  • height_pct (Optional[float] (default: None)) – The fraction of the plot height to use for the zoomed-in rectangle (e.g., 0.25 represents a height 25% of the original plot)

  • palette (Optional[str] (default: None)) – Palette used to color cells

  • cmap_name (Optional[str] (default: 'magma_r')) – Colormap used to color lines connecting cells to their neighbors

  • encode_lw (Optional[bool] (default: True)) – Draw the width of each line connecting neighboring cells according to the magnitude of their ligand-receptor score. Neighboring cells with a low ligand-receptor co-expression score will be connected by a thinly drawn line whereas a pair of cells with a high ligand-receptor co-expression score will be connected by a thickly drawn line. If False, all lines will be drawn with equal thickness defined by the max_lw argument.

  • max_lw (Optional[float] (default: 3.0)) – If encode_lw = True, this is thickness of the line connecting the pair of cells with maximum ligand-receptor score. If encode_lw = False, this is the thickness connecting all pairs of neighboring cells.

  • lr_colorbar (Optional[bool] (default: True)) – If True draw a colorbar depicting the ligand-receptor scores. If False, hide this colorbar

  • show (Optional[bool] (default: True)) – Whether to show the plot or return the Axes object.

  • kwargs – Keyword arguments that will be passed to monkeybread.plot.embedding_zoom().

Return type:

Optional[Tuple[Figure, Axes]]

Returns:

: If show = True, returns nothing. Otherwise, returns the Figure and Axes containing the figure

Example

https://raw.githubusercontent.com/immunitastx/monkeybread/main/docs/_static/ligand_receptor_score_embedding_zoom.png