smoother.visualization ====================== .. py:module:: smoother.visualization .. autoapi-nested-parse:: Visualization functions for smoother.models.deconv Functions --------- .. autoapisummary:: smoother.visualization.plot_celltype_props smoother.visualization.clr_stable smoother.visualization.ilr_stable smoother.visualization.cluster_features smoother.visualization._get_cost_matrix smoother.visualization.align_clusters smoother.visualization.plot_spatial_clusters smoother.visualization.cluster_and_plot_celltype_props Module Contents --------------- .. py:function:: plot_celltype_props(p_inf, coords, cell_type_names=None, n_col=4, figsize=None) Plot the deconvolution results. :param p_inf: n_spots x n_groups. The inferred cell-type proportions. :param coords: n_spots x 2. The coordinates of the spots. :param cell_type_names: list of str. The names of the cell types. :param n_col: int. The number of columns in the figure. :param figsize: tuple. The size of the figure. .. py:function:: clr_stable(props, epsilon=1e-08) Apply centre log ratio transform (clr) to transform proportions to the real space. :param props: n_spots x n_groups. Rowsum equals to 1 or 0. If 0, the transformed vector will also be the zero vector. .. py:function:: ilr_stable(props, epsilon=1e-08) Apply isometric log ratio transformation (ilr) to transform proportions to the real space. .. py:function:: cluster_features(features, transform='pca', n_neighbors=15, res=1) -> pandas.Series Leiden clustering on the input features. .. py:function:: _get_cost_matrix(clu1, clu2) Helper function to get the cost matrix for aligning two clusterings. .. py:function:: align_clusters(clu_list, ref_ind=None) Align the clusterings in clu_list to the reference clustering. :param clu_list: list of clustering result. :param ref_ind: int. The index of the reference clustering. If None, use the clustering with the largest number of clusters. .. py:function:: plot_spatial_clusters(clu_aligned_list, coords, names=None, n_col=4) Plot clusters. :param clu_aligned_list: list of aligned clusterings. :param coords: n_spots x 2. Coordinates of the spots. :param names: list of str. Names of the deconvolution model. :param n_col: int. Number of columns in the plot. .. py:function:: cluster_and_plot_celltype_props(p_inf_list, coords, names=None, n_col=4, transform='pca', n_neighbors=15, res=1, return_clu=False) Cluster the cell-type proportions and visualize the results. :param p_inf_list: list of cell-type proportions. :param coords: n_spots x 2. Coordinates of the spots. :param names: list of str. Names of the deconvolution model. :param transform: str. Transformation to apply to the cell-type proportions. 'pca', 'clr', 'ilr'. :param n_neighbors: int. Number of neighbors to use for clustering. :param res: float. Resolution for leiden clustering. :param return_clu: bool. Whether to return the clustering results.