mechanochat.plotting.spatial_domain_comm_plot#

mechanochat.plotting.spatial_domain_comm_plot(sem: SEM2, df_pvalue: DataFrame, cluster_key: str, ax: Axes | None = None, threshold: float = 0.05, loop_angle_default: float = 0, node_size: float = 1.8, loop_size: float = 3.5, arror_size: float = 25, arrowstyle=ArrowStyle('-|>', head_width=0.2), color='black', edge_width: float = 3.2, node_line_width: float = 1) → Axes[source]#

Draw the significant communication between spatial domains on top of the tissue.

Every spatial domain is drawn as a square node placed on the cell of that domain closest to its centroid, and a significant ordered pair gets an arrow between the two nodes; a significant diagonal entry gets a self-loop, oriented away from the other edges of that node.

Parameters:
  • sem (SEM2) – Subcellular element method object. Requires sem.adata.obs[cluster_key], sem.adata.obs[f’{cluster_key}_mc’] (the spatial domain of each cell) and sem.adata.uns[f’{cluster_key}_colors’]

  • df_pvalue (pandas.DataFrame) – Square p-value matrix indexed by spatial domain, e.g. adata.uns[…][‘communication_pvalue’]. Rows are targets, columns are sources

  • cluster_key (str) – Key of the cell type annotation in .obs; the node colors are taken from it

  • ax (Axes, optional) – Target matplotlib axes object. Creates new figure if None

  • threshold (float, default 0.05) – Significance threshold; only the pairs below it are drawn

  • loop_angle_default (float, default 0) – Angle (radians) of the self-loop of a node with no other edge

  • node_size (float, default 1.8) – Side length of the node squares, in spatial units

  • loop_size (float, default 3.5) – Area controlling the radius of the self-loops

  • arror_size (float, default 25) – Arrow head size (mutation_scale of FancyArrowPatch)

  • arrowstyle (ArrowStyle) – Arrow head style. Default ArrowStyle('-|>', head_width=0.2)

  • color (color, default 'black') – Color of the edges and arrow heads

  • edge_width (float, default 3.2) – Line width of the edges

  • node_line_width (float, default 1) – Line width of the node borders

Returns:

ax (Axes)

Notes

Domains with fewer than 5 cells are skipped.