crested.pl.modisco.class_instances

crested.pl.modisco.class_instances#

crested.pl.modisco.class_instances(pattern_dict, idx, class_representative=False, **kwargs)#

Plot instances of a specific pattern, either the representative pattern per class or all instances for a given pattern index.

Parameters:
  • pattern_dict (dict) – A dictionary containing pattern data. Each key corresponds to a pattern ID, and each value contains instances of the pattern across different classes, along with their contribution scores. Refer to the output of crested.tl.modisco.process_patterns.

  • idx (int) – The index specifying which pattern’s instances to plot. This corresponds to a key in the pattern_dict.

  • class_representative (bool (default: False)) – If True, only the best representative instance of each class is plotted. If False (default), all instances of the pattern within each class are plotted.

  • width – Width of the newly created figure. Default is 8.

  • height – Height of the newly created figure. Default is 2*len(idcs).

  • sharex – Whether to share the x axes of the created plots. Default is False.

  • sharey – Whether to share the y axes of the created plots. Default is False.

  • kwargs – Additional arguments passed to render_plot() to control the final plot output. Please see render_plot() for details. Defaults for class_instances: title=[pattern_dict[str(idx)]["pattern"]["id"] for idx in idcs].

Return type:

tuple[Figure, list[Axes]] | None

Examples

>>> crested.pl.modisco.class_instances(pattern_dict, 0, class_representative=False)
../../_images/modisco_class_instances.png