EIYBrowse.tracks.interactions module¶
The tracks.interactions module contains a panel for displaying heatmaps of interactions data. This is best for dense interaction data, where many loci are measured against many loci e.g. 5C or Hi-C data.
-
class
EIYBrowse.tracks.interactions.SquareInteractionsTrack(datafile, name=None, name_rotate=False, **imshow_kwargs)¶ Bases:
EIYBrowse.tracks.base.FileTrackTrack for displaying 3D interactions data (e.g. Hi-C) across a genomic region as a square matrix
Create a new interactions track
Parameters: - datafile – Object providing access to the interactions data
- normalizer (
matplotlib.colors.Normalize) – Normalizer to scale the matrix data between 0 and 1 - cmap (
matplotlib.colors.Colormap) – Colormap to convert matrix values into colors - imshow_kwargs – Optional keyword arguments to be passed to
matplotlib.pylab.imshow() - name (str) – Optional name label
- name_rotate (bool) – Whether to rotate the name label 90 degrees
-
classmethod
from_config_dict(cmap=None, norm=None, **kwargs)¶ Before calling parent’s
from_config_dict()method, check whether cmap or norm parameters are dictionaries. If they are, handle them separately to create the appropriate objects to pass (eventually) to imshow.Parameters: - cmap (dict) – Dictionary of options which will be expanded and
passed to
colormap_from_config()to create an object of typeColormap - norm (dict) – Dictionary of options which will be expanded and
passed to
normalizer_from_config()to create an object of typeNormalize
- cmap (dict) – Dictionary of options which will be expanded and
passed to
-
get_config(region, browser)¶ Calculate how many rows of height need to be requested. Since we will return a square matrix, we need to be the same height as our width.
Parameters: - region (
pybedtools.Interval) – Genomic region to plot - browser (
Browser) – Browser object calling get_config function
- region (
-
class
EIYBrowse.tracks.interactions.TriangularInteractionsTrack(datafile, name=None, name_rotate=False, flip=False, **imshow_kwargs)¶ Bases:
EIYBrowse.tracks.interactions.SquareInteractionsTrackTrack for displaying 3D interactions data (e.g. Hi-C) across a genomic region as a triangular matrix - i.e. by rotating the matrix by 45 degrees and moving the diagonal of the matrix to the x-axis.
Create a new interactions track
Parameters: - datafile – Object providing access to the interactions data
- normalizer (
matplotlib.colors.Normalize) – Normalizer to scale the matrix data between 0 and 1 - cmap (
matplotlib.colors.Colormap) – Colormap to convert matrix values into colors - imshow_kwargs – Optional keyword arguments to be passed to
matplotlib.pylab.imshow() - name (str) – Optional name label
- name_rotate (bool) – Whether to rotate the name label 90 degrees
- flip (bool) – Whether the matrix should extend downwards from the x axis (default is upwards from the axis).
-
get_config(region, browser)¶ Calculate how many rows of height need to be requested. Since we will return a triangular matrix, we need to be half as high as our width.
Parameters: - region (
pybedtools.Interval) – Genomic region to plot - browser (
Browser) – Browser object calling get_config function
- region (
-
EIYBrowse.tracks.interactions.colormap_from_config(name='jet', over_color=None, under_color=None, nan_color=None)¶ Unpack properties of the colormap which can be set in the config file.
Essentially get a
ColorMapobject from it’s string name and manually set the over, under and bad colors if specified.Parameters: - name (str) – Name of the colormap to use
- over_color (str) – Color to use when the matrix value is higher than the maximum allowed value (given by the vmax attribute of norm)
- under_color (str) – Color to use when the matrix value is lower than the minumum allowed value (given by the vmin attribute of norm)
- nan_color (str) – Color to use when the matrix value is not a number
-
EIYBrowse.tracks.interactions.get_quantile_scaled_normalizer(norm_class=<Mock name='mock.colors.Normalize' id='139811650077712'>, quantile=5)¶ Given a subclass of Normalize, return a new class which sets vmin and vmax by the quantiles of the given array, rather than the minimum or maximum. The quantiles are symmetric, so the lower quantile qmin is equal to quantile or 100. - quantile, whichever is smaller.
In other words, the quantile can be specified as either 5. or 95. with the same result.
Parameters: - norm_class (class) – Subclass of
Normalizeto inherit from - quantile (float) – Either the upper or lower quantile (clipping is done symmetrically, so either can be specified.
- norm_class (class) – Subclass of
-
EIYBrowse.tracks.interactions.normalizer_from_config(method='linear', quantile_scaled=None, **norm_args)¶ Unpack properties of the color normalizer which can be set in the config file.
Essentially get a
Normalizeobject from it’s string name and convert it to a quantile normalizer using theget_quantile_scaled_normalizer()class factory if requested.Parameters: - method (str) – Name of the normalizer to use. Can be any of ‘linear’, ‘log’, ‘symmetric_log’, ‘boundary’ or (in matplotlib versions >= 1.4) ‘power_law’
- quantile_scaled (float or None) – If Norm, scale the matrix to the min/max of the data, or by the constants vmin/vmax if specified in norm_args. If a number from 0 to 100, scale the matrix by the xth and 100-xth quantile of the data (e.g. if 5. is given, scale by the 5th and 95th quantiles)
- norm_args (dict) – Any additional parameters to pass to pass to the
Normalizeconstructor
-
EIYBrowse.tracks.interactions.rotate_heatmap(data, flip=False)¶ Rotate a symmetrical matrix 45 degrees and move diagonal to the x-axis
After this transformation, the heatmap will appear as a triangle, with genomic location on the x-axis only.
These heatmaps can be easier to line up with other genomic data (e.g. gene positions or ChIP-seq peaks).
Parameters: - data (
array) – Input array heatmap - flip (bool) – Whether the triangle should point downwards from the axis (default is upwards).
- data (