lib5c.plotters.extendable.snp_extendable_heatmap module

Module for the SNPExtendableHeatmap class, which adds SNP track plotting functionality for the extendable heatmap system.

class lib5c.plotters.extendable.snp_extendable_heatmap.SNPExtendableHeatmap(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 SNP track plotting functionality.

add_snp_track(snps, loc='bottom', size='3%', pad=0.0, name='snp', axis_limits=(0, 1), snp_height=0.5, colors=None, track_label=None)[source]

Adds one SNP track along either the x- or y-axis of the heatmap.

Parameters
  • snps (list of dict) –

    Each dict should represent a SNP and should have at least the following keys:

    {
        'chrom' : str,
        'start' : int,
        'end'   : int
    }
    

    If color-coding SNPs, include a ‘name’ or ‘id’ key.

  • loc ({'top', 'bottom', 'left', 'right'}) – Which side of the heatmap to add the new SNP track to.

  • size (str) – The size of the new axis as a percentage of the main heatmap width. Should be passed as a string ending in ‘%’.

  • pad (float) – The padding to use between the existing parts of the figure and the newly added axis.

  • name (str) – The name for the new axis. This name will be prefixed with the orientation of the track (‘vertical’ or ‘horizontal’).

  • axis_limits (tuple of float) – Limits for the non-genomic axis of the SNP track.

  • snp_height (float) – Height of SNP arrowheads in same units as axis_limits.

  • colors (dict, optional) – Maps SNP ids or names to color names. Defaults to black if not passed or if a SNP’s name or id are not found in the dict.

  • track_label (str, optional) – Pass a string to label the track.

Returns

The newly added SNP track axis.

Return type

pyplot axis

add_snp_tracks(snps, size='3%', pad=0.0, axis_limits=(0, 1), snp_height=0.5, name='snp', colors=None, track_label=None)[source]

Adds SNP tracks for a single set of SNPs to both the bottom and left side of the heatmap by calling add_snp_track() twice.

Parameters
  • snps (list of dict) –

    Each dict should represent a SNP and should have at least the following keys:

    {
        'chrom' : str,
        'start' : int,
        'end'   : int
    }
    

    If color-coding SNPs, include a ‘name’ or ‘id’ key.

  • size (str) – The size of the new axis as a percentage of the main heatmap width. Should be passed as a string ending in ‘%’.

  • pad (float) – The padding to use between the existing parts of the figure and the newly added axis.

  • axis_limits (tuple of float) – Limits for the non-genomic axis of the SNP track.

  • snp_height (float) – Height of SNP arrowheads in same units as axis_limits.

  • name (str) – The name for the new axis. This name will be prefixed with the orientation of the track (‘vertical’ or ‘horizontal’).

  • colors (dict, optional) – Maps SNP ids or names to color names. Defaults to black if not passed or if a SNP’s name or id are not found in the dict.

  • track_label (str, optional) – Pass a string to label the track.

Returns

The newly added SNP track axes.

Return type

list of pyplot axes