ALLCools.plot.genome_track._pygenometrack

Modified from pygenometracks LICENSE: https://github.com/deeptools/pyGenomeTracks/blob/master/LICENSE

Module Contents

FORMAT = [%(levelname)s:%(filename)s:%(lineno)s - %(funcName)20s()] %(message)s[source]
log[source]
DEFAULT_TRACK_HEIGHT = 0.5[source]
DEFAULT_FIGURE_WIDTH = 40[source]
DEFAULT_WIDTH_RATIOS = [0.01, 0.9, 0.1][source]
DEFAULT_MARGINS[source]
class MultiDict[source]

Bases: collections.OrderedDict

Class to allow identically named sections in configuration file by appending the section number for example: 1. section name

_unique = 0[source]
__setitem__(self, key, val)[source]

Set self[key] to value.

class PlotTracks(config, fig_width=DEFAULT_FIGURE_WIDTH, fig_height=None, fontsize=None, dpi=None, track_label_width=None, plot_regions=None, plot_width=None)[source]

Bases: object

static get_available_tracks()[source]
get_tracks_height(self, start_region=None, end_region=None)[source]

The main purpose of the following loop is to get the height of each of the tracks because for the Hi-C the height is variable with respect to the range being plotted, the function is called when each plot is going to be printed.

Parameters
  • start_region – start of the region to plot. Only used in case the plot is a Hi-C matrix

  • end_region – end of the region to plot. Only used in case the plot is a Hi-C matrix

Returns:

plot(self, chrom, start, end, file_name=None, title=None, h_align_titles='left', decreasing_x_axis=False)[source]
plot_vlines(self, axis_list, chrom_region, start_region, end_region)[source]

Plots dotted lines from the top of the first plot to the bottom of the last plot at the specified positions.

Parameters

axis_list – list of plotted axis

:param chrom_region chromosome name :param start_region start position :param end_region end position

Returns

None

parse_tracks(self, tracks_file, plot_regions=None)[source]

Parses a configuration file

Parameters
  • tracks_file – file path containing the track configuration

  • plot_regions – a list of tuple [(chrom1, start1, end1), (chrom2, start2, end2)] on which the data should be loaded here the vlines

Returns

array of dictionaries and vlines_file. One dictionary per track

close_files(self)[source]

Close all opened files

static check_file_exists(track_dict, tracks_path, is_hic=False)[source]

Checks if a file or list of files exists. If the file does not exist tries to check if the file may be relative to the track_file path, in such case the path is updated. :param track_dict: dictionary of track values. Should contain

a ‘file’ key containing the path of the file or files to be checked separated by space For example: file1 file2 file3

Parameters
  • tracks_path – path of the tracks file

  • is_hic

Returns

None

static guess_filetype(track_dict, available_tracks)[source]
Parameters
  • track_dict – dictionary of track values with the ‘file’ key containing a string path of the file or files. Only the ending of the last file is used in case when there are more files

  • available_tracks – list of available tracks

Returns

string file type detected

static cm2inch(*tupl)[source]
static print_elapsed(start)[source]
class SpacerTrack(properties_dict)[source]

Bases: pygenometracks.tracks.GenomeTrack.GenomeTrack

The GenomeTrack object is a holder for all tracks that are to be plotted. For example, to plot a bedgraph file a new class that extends GenomeTrack should be created.

It is expected that all GenomeTrack objects have a plot method.

SUPPORTED_ENDINGS = [][source]
TRACK_TYPE = spacer[source]
DEFAULTS_PROPERTIES[source]
NECESSARY_PROPERTIES = [][source]
SYNONYMOUS_PROPERTIES[source]
POSSIBLE_PROPERTIES[source]
BOOLEAN_PROPERTIES = [][source]
STRING_PROPERTIES = ['overlay_previous', 'title', 'file_type'][source]
FLOAT_PROPERTIES[source]
INTEGER_PROPERTIES[source]
plot(self, ax, chrom_region, start_region, end_region)[source]
plot_y_axis(self, ax, plot_ax)[source]

Plot the scale of the y axis with respect to the plot_axis :param ax: axis to use to plot the scale :param plot_axis: the reference axis to get the max and min. :param transform: what was the transformation of the data :param log_pseudocount: :param y_axis: ‘tranformed’ or ‘original’ :param only_at_ticks: False: only min_max are diplayed

True: only ticks values are displayed

Returns:

class XAxisTrack(*args, **kwargs)[source]

Bases: pygenometracks.tracks.GenomeTrack.GenomeTrack

The GenomeTrack object is a holder for all tracks that are to be plotted. For example, to plot a bedgraph file a new class that extends GenomeTrack should be created.

It is expected that all GenomeTrack objects have a plot method.

SUPPORTED_ENDINGS = [][source]
TRACK_TYPE = x_axis[source]
NECESSARY_PROPERTIES = [][source]
DEFAULTS_PROPERTIES[source]
SYNONYMOUS_PROPERTIES[source]
POSSIBLE_PROPERTIES[source]
BOOLEAN_PROPERTIES = [][source]
STRING_PROPERTIES = ['overlay_previous', 'title', 'where', 'file_type'][source]
FLOAT_PROPERTIES[source]
INTEGER_PROPERTIES[source]
plot(self, ax, chrom_region, region_start, region_end)[source]
plot_y_axis(self, ax, plot_ax)[source]

Plot the scale of the y axis with respect to the plot_axis :param ax: axis to use to plot the scale :param plot_axis: the reference axis to get the max and min. :param transform: what was the transformation of the data :param log_pseudocount: :param y_axis: ‘tranformed’ or ‘original’ :param only_at_ticks: False: only min_max are diplayed

True: only ticks values are displayed

Returns:

prepare_config(file_configs, add_spacer=True, spacer_height=0.5)[source]

Prepare pyGenomeTracks config string.

Parameters
  • file_configs – A list of file paths, or a list of file config dicts, containing file path and other config. See pyGenomeTracks documentation for possible parameters.

  • add_spacer – Whether add spacer between tracks

  • spacer_height – spacer height in cm

Returns

Return type

a single config string that can be read by PlotTracks

_prepare_track_config(file_config, track_type, track_class, add_spacer=True, spacer_height=0.5)[source]