crested.pl.modisco.clustermap_tomtom_similarities

crested.pl.modisco.clustermap_tomtom_similarities#

crested.pl.modisco.clustermap_tomtom_similarities(sim_matrix, ids, pattern_dict, group_info=None, query_id=None, threshold=None, min_seqlets=0, class_names=None, cmap='viridis', dendrogram_ratio=(0.05, 0.05), logo_width_fraction=0.35, logo_x_padding=0.5, show_pwms=True, save_path=None, width=10, height=10, plot_kws=None, figsize='deprecated')#

Create a Seaborn clustermap of TOMTOM similarity scores with optional PWM logo display and filtering.

Parameters:
  • sim_matrix (ndarray) – 2D square array of TOMTOM similarity scores (-log10 p-values), shape (N, N).

  • ids (list[str]) – List of pattern identifiers corresponding to rows/columns of sim_matrix.

  • pattern_dict (dict[str, dict]) – Dictionary mapping pattern IDs to metadata. Each entry should contain: - ‘n_seqlets’: number of seqlets contributing to the pattern. - ‘contrib_scores’: DataFrame or array used for PWM logo plotting.

  • group_info (list[tuple[list[str], dict[str, str]]] (default: None)) – List of (group_labels, color_map) tuples. Each group_labels list has the same length as ids, and each color_map assigns colors to group values.

  • query_id (str | None (default: None)) – If provided, only show motifs with similarity > threshold to this ID.

  • threshold (float | None (default: None)) – Minimum TOMTOM score for similarity filtering (used only with query_id).

  • min_seqlets (int (default: 0)) – Minimum number of seqlets required for a pattern to be shown.

  • class_names (list[str] | None (default: None)) – If provided, only keep patterns whose class name (parsed as ‘_’.join(id.split(‘_’)[:-3])) is in this list.

  • cmap (str | Colormap (default: 'viridis')) – Colormap to use in the clustermap.

  • dendrogram_ratio (tuple[float, float]) – Ratio of dendrogram size to figure size for rows and columns.

  • logo_width_fraction (float (default: 0.35)) – Width of the PWM logo strip relative to the heatmap width.

  • logo_x_padding (float (default: 0.5)) – Horizontal space between the PWM logos and the heatmap.

  • show_pwms (bool (default: True)) – Whether to display PWM logos to the left of the heatmap.

  • width (int | float (default: 10)) – Figure width.

  • height (int | float (default: 10)) – Figure height.

  • save_path (str | None (default: None)) – If provided, the figure is saved to this path (e.g., as a PNG or PDF).

  • plot_kws (dict | None (default: None)) – Extra keyword arguments passed to clustermap().

Return type:

ClusterGrid

Returns:

sns.matrix.ClusterGrid The Seaborn clustermap object containing the heatmap and dendrograms.