troutpy.pl.celltype_contact_matrix#
- troutpy.pl.celltype_contact_matrix(mat, sdata=None, kind='heatmap', cell_type_key='leiden', cmap='BuPu', vmin=None, vmax=None, dendrogram_ratio=0.1, title='Cell-type contact matrix', palette='tab20', **kwargs)#
Plot a cell type x cell type contact matrix as a heatmap or chord diagram.
- Parameters:
mat (
DataFrame) – Square contact matrix, as returned bytroutpy.tl.celltype_contact_matrix(), with rows as source cell types and columns as neighbour cell types.sdata (
Optional[SpatialData] (default:None)) – If provided, cell-type colors are taken fromsdata["table"].uns[cell_type_key + "_colors"]. Otherwise,paletteis used as a fallback.kind (
str(default:'heatmap')) – Type of plot, either"heatmap"(seaborn.clustermap()) or"chord"(mpl_chord_diagram.chord_diagram()).cell_type_key (
str(default:'leiden')) – Key insdata["table"].obs/.unsused to resolve per-cell-type colors.cmap (
str(default:'BuPu')) – Colormap for the heatmap.vmin (
Optional[float] (default:None)) – Min value for colormap scaling.vmax (
Optional[float] (default:None)) – Max value for colormap scaling.dendrogram_ratio (
float(default:0.1)) – Passed toseaborn.clustermap().title (
str(default:'Cell-type contact matrix')) – Figure title.palette (
str(default:'tab20')) – Matplotlib colormap name used as a fallback whensdataisNoneor has no stored colors forcell_type_key.kwargs – Additional arguments passed to
seaborn.clustermap()ormpl_chord_diagram.chord_diagram().
- Returns:
For
kind="heatmap", theseaborn.matrix.ClusterGrid. Forkind="chord", thematplotlib.figure.Figure.