crested.pl.modisco.clustermap_tf_motif

crested.pl.modisco.clustermap_tf_motif#

crested.pl.modisco.clustermap_tf_motif(data, heatmap_dim='gex', dot_dim='contrib', class_labels=None, subset_classes=None, pattern_labels=None, cluster_rows=True, cluster_columns=True, cbar_pad=0.05, row_class_mapping=None, row_class_palette=None, row_class_legend=True, col_species_mapping=None, species_palette=None, species_legend=False, imshow_kws=None, scatter_kws=None, fig_size='deprecated', **kwargs)#

Generate a heatmap where one modality is represented as color, and the other as dot size.

Parameters:
  • data (ndarray) – 3D numpy array with shape (len(classes), #patterns, 2).

  • heatmap_dim (str (default: 'gex')) – Either ‘gex’ or ‘contrib’, indicating which third dimension to use for heatmap colors.

  • dot_dim (str (default: 'contrib')) – Either ‘gex’ or ‘contrib’, indicating which third dimension to use for dot sizes.

  • class_labels (list[str] | None (default: None)) – Labels for the classes.

  • subset_classes (list[str] | None (default: None)) – Subset of classes to include in the heatmap. Rows in data are filtered accordingly.

  • pattern_labels (list[str] | None (default: None)) – Labels for the patterns.

  • cluster_rows (bool (default: True)) – Whether to cluster the rows (classes). Default is True.

  • cluster_columns (bool (default: True)) – Whether to cluster the columns (patterns). Default is True.

  • cbar_pad (float (default: 0.05)) – Horizontal padding between heatmap and colorbar in figure coordinates.

  • row_class_mapping (dict[str, str] | None (default: None)) – Optional mapping of class label (row) to a higher-level class/group name, drawn as a categorical color strip flush against the right edge of the heatmap. Cell-type labels are moved outboard of the strip. Rows missing from the mapping are labeled "NA".

  • row_class_palette (dict[str, str] | None (default: None)) – Optional mapping of group name (the values of row_class_mapping) to a color. If None, a qualitative palette (tab20) is assigned automatically.

  • row_class_legend (bool (default: True)) – Whether to draw a legend for the row class strip. Default is True.

  • col_species_mapping (dict[str, list[str]] | None (default: None)) – Optional mapping of column label (pattern_labels entry, e.g. "EBF2_pattern_0") to the list of species in which that TF-motif column is found, e.g. {"EBF2_pattern_0": ["Mouse", "Macaque", "Human"], "EGR1_pattern_38": ["Mouse"]}. Drawn as a vertical stack of cells above the heatmap, one row per species (fixed order from species_palette), coloured where the column is present in that species and blank where absent. A column found in all three species shows three colours; one found only in mouse shows just the mouse cell.

  • species_palette (dict[str, str] | None (default: None)) – Mapping of species name to colour, e.g. {"Human": "#377eb8", "Macaque": "#4daf4a", "Mouse": "#ff8c00"}. Its key order sets the top-to-bottom order of the species stack. Keys must match the species strings in col_species_mapping. If None, a tab10 palette is assigned in first-appearance order.

  • species_legend (bool (default: False)) – How the species stack is labelled. False (default) labels each row inline on the strip (self-documenting, no separate legend). True drops the inline row labels and draws a “Species” legend instead. The two are mutually exclusive to avoid redundant labelling.

  • imshow_kws (dict | None (default: None)) – Extra arguments for ax.imshow. Default is {'cmap': 'coolwarm', 'aspect': 'auto'}.

  • scatter_kws (dict | None (default: None)) – Extra arguments for ax.scatter. Default is {'c': "black", 'alpha': 0.6, 'edgecolor': "none"}

  • width – Width of the newly created figure. Default is max(20, data.shape[1]//4).

  • height – Height of the newly created figure. Default is data.shape[0]//2.

  • kwargs – Additional arguments passed to render_plot() to control the final plot output. Please see render_plot() for details.

Return type:

tuple[Figure, list[Axes]] | None

Examples

>>> clustermap_tf_motif(
...     data,
...     heatmap_dim="gex",
...     dot_dim="contrib",
...     class_labels=classes,
...     pattern_labels=patterns,
...     cluster_rows=True,
...     cluster_columns=True,
... )