lib5c.plotters.extendable.cluster_extendable_heatmap module

Module for the ClusterExtendableHeatmap class, which adds cluster outlining functionality for the extendable heatmap system.

class lib5c.plotters.extendable.cluster_extendable_heatmap.ClusterExtendableHeatmap(array, grange_x, grange_y=None, colorscale=None, colormap='obs', norm=None)[source]

Bases: lib5c.plotters.extendable.base_extendable_heatmap.BaseExtendableHeatmap

ExtendableHeatmap mixin class providing cluster outlining functionality.

add_clusters(cluster_array, colors=None, weight='100x', outline_color=None, outline_weight='2x', labels=None, fontsize=7)[source]

Adds clusters to the heatmap surface.

Parameters
  • cluster_array (np.ndarray) – Array of cluster IDs. Should match size and shape of the underlying array this ExtendableHeatmap was constructed with.

  • colors ('random' or single color or list/dict of colors or None) – Pass ‘random’ for random colors, pass a dict mapping cluster IDs to matplotlib colors to outline each cluster in the indicated color, pass None to skip outlining clusters.

  • weight (numeric or str) – Pass a numeric to set the linewidth for the cluster outlines. Pass a string ending in “x” (such as “100x”) to specify the line width as a multiple of the inverse of the number of pixels in the heatmap.

  • outline_color (matplotlib color or None) – Pass a matplotlib color to outline the outlines (e.g. with neon green) to make them stand out more. Pass None to skip adding this extra outline.

  • outline_weight (numeric or str) – ass a numeric to set the linewidth for the outlines of the cluster outlines. Pass a string ending in “x” (such as “2x”) to specify the line width as a multiple of the outline linewidth.

  • labels (True, dict of str, or None) – Pass True to simply label the clusters by their ID. Pass a mapping from cluster IDs to labels to label the clusters with a the labels. Pass None to skip outlining clusters.

  • fontsize (numeric) – The font size to use for cluster labels.

label_cluster(cluster, label, fontsize=7)[source]

Labels a cluster.

Parameters
  • cluster (list of {'x': int, 'y': int} dicts) – The cluster to label.

  • label (str) – The string to label the cluster with.

  • fontsize (numeric) – The fontsize to use for the label.

outline_cluster(cluster, color, linewidth=2)[source]

Outlines a single cluster in the specified color.

Parameters
  • cluster (list of {'x': int, 'y': int} dicts) – The cluster to outline.

  • color (matplotlib color) – The color to outline in.

  • linewidth (numeric) – The linewidth to use.