lib5c.plotters.enrichment module

Module for plotting visualizations of enrichments of annotations within categories of categorized loops.

lib5c.plotters.enrichment.plot_annotation_vs_annotation_heatmap(annotationmaps, looping_classes, loop_type, axis_order=None, threshold=0, margin=1, vmin=-2.0, vmax=2.0, despine=False, style='dark', **kwargs)[source]

Plot a heatmap of enrichments for a fixed loop category, varying the annotation on either side on the x- and y-axes.

Parameters
  • annotationmaps (dict of annotationmap) –

    A dict describing the annotations. In total, it should have the following structure:

    {
        'annotation_a_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
         },
        'annotation_b_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
        },
        ...
    }
    

    where annotationmaps['annotation_a']['region_r'] should be a list of ints describing the number of 'annotation_a'``s present in each bin of ``'region_r'.

  • looping_classes (dict of np.ndarray with str dtype) – The keys should be region names as strings, the values should be square, symmetric arrays of the same size and shape as the indicated region, with string loop category names in the positions of categorized loops.

  • loop_type (str) – The loop category to hold constant throughout the heatmap.

  • axis_order (list of str, optional) – The annotations to include on each axis, in order. If None, falls back to sorted(annotationmap.keys()).

  • threshold (int) – Bins are defined to contain an annotation if they are “hit” strictly more than threshold times by the annotation.

  • margin (int) – A bin is defined to contain an annotation if any bin within margin bins is “hit” by the annotation. Corresponds to a “margin for error” in the intersection precision.

  • vmin (float) – The lowest fold change to show on the colorbar.

  • vmax (float) – The highest fold change to show on the colorbar.

  • kwargs (kwargs) – Typical plotter kwargs.

Returns

The axis plotted on.

Return type

pyplot axis

lib5c.plotters.enrichment.plot_looptype_vs_annotation_heatmap(annotationmaps, looping_classes, constant_annotation, loop_type_order=None, annotation_order=None, threshold=0, margin=1, vmin=-2.0, vmax=2.0, despine=False, style='dark', **kwargs)[source]

Plot a heatmap of enrichments for one fixed annotation, varying the loop category on the x-axis and the annotation on the other side on the y-axis.

Parameters
  • annotationmaps (dict of annotationmap) –

    A dict describing the annotations. In total, it should have the following structure:

    {
        'annotation_a_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
         },
        'annotation_b_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
        },
        ...
    }
    

    where annotationmaps['annotation_a']['region_r'] should be a list of ints describing the number of 'annotation_a'``s present in each bin of ``'region_r'.

  • looping_classes (dict of np.ndarray with str dtype) – The keys should be region names as strings, the values should be square, symmetric arrays of the same size and shape as the indicated region, with string loop category names in the positions of categorized loops.

  • constant_annotation (str) – The annotation to hold constant throughout the heatmap.

  • loop_type_order (list of str) – The loop categories to include on the x-axis, in order. If None, falls back to the sorted unique categories in looping_classes.

  • annotation_order (list of str, optional) – The annotations to include on the y-axis, in order. If None, falls back to sorted(annotationmap.keys()).

  • threshold (int) – Bins are defined to contain an annotation if they are “hit” strictly more than threshold times by the annotation.

  • margin (int) – A bin is defined to contain an annotation if any bin within margin bins is “hit” by the annotation. Corresponds to a “margin for error” in the intersection precision.

  • vmin (float) – The lowest fold change to show on the colorbar.

  • vmax (float) – The highest fold change to show on the colorbar.

  • kwargs (kwargs) – Typical plotter kwargs.

Returns

The axis plotted on.

Return type

pyplot axis

lib5c.plotters.enrichment.plot_stack_bargraph(annotation_a, annotation_b, loop_types, labels, colors, annotationmaps, looping_classes, threshold=0, margin=1, **kwargs)[source]

Plots a bar graph with loop types arranged on the x-axis and the percentage of times annotation_a is interaction with annotation_b in all the loops of that loop type.

Parameters
  • annotation_a (str) – First annotation you are intereted in.

  • annotation_b (str) – Second annotation you are interested in.

  • loop_types (list of str) – The order in which to arrange the loop types along the x-axis, from left to right. If you exclude a loop type from this list, it will be excluded from the heatmap.

  • labels (list of str) – The labels you want to be assigned on the x-axis to each of the loop types. The label order should correspond to the order of loop_types.

  • colors (list of valid matplotlib colors) – The colors to plot each bar with. The order should correspond to the order of loop_types.

  • annotationmaps (dict of annotationmap) –

    A dict describing the annotations. In total, it should have the following structure:

    {
        'annotation_a_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
         },
        'annotation_b_name': {
            'region_1_name': list of int,
            'region_2_name': list of int,
            ...
        },
        ...
    }
    

    where annotationmaps['annotation_a']['region_r'] should be a list of ints describing the number of 'annotation_a'``s present in each bin of ``'region_r'.

  • looping_classes (dict of np.ndarray with str dtype) – The keys should be region names as strings, the values should be square, symmetric arrays of the same size and shape as the indicated region, with string loop category names in the positions of categorized loops.

  • threshold (int) – Bins are defined to contain an annotation if they are “hit” strictly more than threshold times by the annotation.

  • margin (int) – A bin is defined to contain an annotation if any bin within margin bins is “hit” by the annotation. Corresponds to a “margin for error” in the intersection precision.

  • kwargs (kwargs) – Typical plotter kwargs.

Returns

The axis plotted on.

Return type

pyplot axis