spateo.plotting.static.interactions =================================== .. py:module:: spateo.plotting.static.interactions .. autoapi-nested-parse:: Plots to visualize results from cell-cell colocalization based analyses, as well as cell-cell communication inference-based analyses. Makes use of dotplot-generating functions Functions --------- .. autoapisummary:: spateo.plotting.static.interactions.ligrec spateo.plotting.static.interactions.plot_connections Module Contents --------------- .. py:function:: ligrec(adata: anndata.AnnData, dict_key: str, source_groups: Union[None, str, List[str]] = None, target_groups: Union[None, str, List[str]] = None, means_range: Tuple[float, float] = (-np.inf, np.inf), pvalue_threshold: float = 1.0, remove_empty_interactions: bool = True, remove_nonsig_interactions: bool = False, dendrogram: Union[None, str] = None, alpha: float = 0.001, swap_axes: bool = False, title: Union[None, str] = None, figsize: Union[None, Tuple[float, float]] = None, save_show_or_return: Literal['save', 'show', 'return', 'both', 'all'] = 'show', save_kwargs: Optional[ligrec.dict] = {}, **kwargs) Dotplot for visualizing results of ligand-receptor interaction analysis For each L:R pair on the dotplot, molecule 1 is sent from the cluster(s) labeled on the top of the plot (or on the right, if 'swap_axes' is True), whereas molecule 2 is the receptor on the cluster(s) labeled on the bottom. :param adata: Object of :class `anndata.AnnData` :param dict_key: Key in .uns to dictionary containing cell-cell communication information. Should contain keys labeled "means" and "pvalues", with values being dataframes for the mean cell type-cell type L:R product and significance values. :param source_groups: Source interaction clusters. If `None`, select all clusters. :param target_groups: Target interaction clusters. If `None`, select all clusters. :param means_range: Only show interactions whose means are within this **closed** interval :param pvalue_threshold: Only show interactions with p-value <= `pvalue_threshold` :param remove_empty_interactions: Remove rows and columns that contain NaN values :param remove_nonsig_interactions: Remove rows and columns that only contain interactions that are larger than `alpha` :param dendrogram: How to cluster based on the p-values. Valid options are: - None (no input) - do not perform clustering. - `'interacting_molecules'` - cluster the interacting molecules. - `'interacting_clusters'` - cluster the interacting clusters. - `'both'` - cluster both rows and columns. Note that in this case, the dendrogram is not shown. :param alpha: Significance threshold. All elements with p-values <= `alpha` will be marked by tori instead of dots. :param swap_axes: Whether to show the cluster combinations as rows and the interacting pairs as columns :param title: Title of the plot :param figsize: The width and height of a figure :param save_show_or_return: Options: "save", "show", "return", "both", "all" - "both" for save and show :param save_kwargs: A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {"path": None, "prefix": 'scatter', "dpi": None, "ext": 'pdf', "transparent": True, "close": True, "verbose": True} as its parameters. But to change any of these parameters, this dictionary can be used to do so. :param kwargs: Keyword arguments for :func `style` or :func `legend` of :class `Dotplot` .. py:function:: plot_connections(adata: anndata.AnnData, cat_key: str, spatial_key: str = 'spatial', n_spatial_neighbors: Union[None, int] = 6, spatial_weights_matrix: Union[None, scipy.sparse.csr_matrix, numpy.ndarray] = None, expr_weights_matrix: Union[None, scipy.sparse.csr_matrix, numpy.ndarray] = None, reverse_expr_plot_orientation: bool = True, ax: Union[None, matplotlib.axes.Axes] = None, figsize: tuple = (3, 3), zero_self_connections: bool = True, normalize_by_self_connections: bool = False, shapes_style: bool = True, label_outline: bool = False, max_scale: float = 0.46, colormap: Union[str, dict, matplotlib.colormap] = 'Spectral', title_str: Union[None, str] = None, title_fontsize: Union[None, float] = None, label_fontsize: Union[None, float] = None, save_show_or_return: Literal['save', 'show', 'return', 'both', 'all'] = 'show', save_kwargs: Optional[dict] = {}) Plot spatial_connections between labels- visualization of how closely labels are colocalized :param adata: AnnData object :param cat_key: Key in .obs containing categorical grouping labels. Colocalization will be assessed for pairwise combinations of these labels. :param spatial_key: Key in .obsm containing coordinates in the physical space. Not used unless 'spatial_weights_matrix' is None, in which case this is required. Defaults to "spatial". :param n_spatial_neighbors: Optional, number of neighbors in the physical space for each cell. Not used unless 'spatial_weights_matrix' is None. :param spatial_weights_matrix: Spatial distance matrix, weighted by distance between spots. If not given, will compute at runtime. :param expr_weights_matrix: Gene expression distance matrix, weighted by distance in transcriptomic or PCA space. If not given, only the spatial distance matrix will be plotted. If given, will plot the spatial distance matrix in the left plot and the gene expression distance matrix in the right plot. :param reverse_expr_plot_orientation: If True, plot the gene expression connections in the form of a lower right triangle. If False, gene expression connections will be an upper left triangle just like the spatial connections. :param ax: Existing axes object, if applicable :param figsize: Width x height of desired figure window in inches :param zero_self_connections: If True, ignores intra-label interactions :param normalize_by_self_connections: Only used if 'zero_self_connections' is False. If True, normalize intra-label connections by the number of spots of that label :param shapes_style: If True plots squares, if False plots heatmap :param label_outline: If True, gives dark outline to axis tick label text :param max_scale: Only used for the case that 'shape_style' is True, gives maximum size of square :param colormap: Specifies colors to use for plotting. If dictionary, keys should be numerical labels corresponding to those of the Label object. :param title_str: Optionally used to give plot a title :param title_fontsize: Size of plot title- only used if 'title_str' is given. :param label_fontsize: Size of labels along the axes of the graph :param save_show_or_return: Whether to save, show or return the figure. If "both", it will save and plot the figure at the same time. If "all", the figure will be saved, displayed and the associated axis and other object will be return. :param save_kwargs: A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {"path": None, "prefix": 'scatter', "dpi": None, "ext": 'pdf', "transparent": True, "close": True, "verbose": True} as its parameters. Otherwise you can provide a dictionary that properly modifies those keys according to your needs. :returns: Returns plot and axis object if 'save_show_or_return' is "all" :rtype: (fig, ax)