OverlaidTracks

Contents

OverlaidTracks#

class alphagenome.visualization.plot_components.OverlaidTracks(tdata, colors=None, cmap='viridis', track_height=1.0, ylabel_template='{name}:{strand}', ylabel_horizontal=True, shared_y_scale=False, global_ylims=None, yticks=None, yticklabels=None, alpha=0.8, order_tdata_by_mean=True, max_num_tracks=50, legend_loc='upper right', **kwargs)[source]#

Component for visualizing overlaid track pairs, such as REF/ALT tracks.

Initializes the OverlaidTracks component.

Parameters:
  • tdata (Mapping[str, TrackData]) – A dictionary mapping track names to TrackData objects.

  • colors (Mapping[str, str] | None (default: None)) – An optional dictionary mapping track names to colors.

  • cmap (str | None (default: 'viridis')) – The colormap to use if colors is not provided.

  • track_height (float (default: 1.0)) – The height of each track.

  • ylabel_template (str (default: '{name}:{strand}')) – A template for the y-axis labels.

  • ylabel_horizontal (bool (default: True)) – Whether to make the y-axis labels horizontal.

  • shared_y_scale (bool (default: False)) – Whether to use the same y-axis scale for all tracks. This is inferred from the min/max data values across all tracks.

  • global_ylims (tuple[float, float] | None (default: None)) – Optional global y-axis limits (min and max).

  • yticks (Sequence[float] | None (default: None)) – Optional set y-axis tick values manually. If not provided, the tick values will be automatically determined. If provided, the length of yticks must match the length of yticklabels.

  • yticklabels (Sequence[str] | None (default: None)) – Optional set y-axis tick labels manually. If not provided, the tick values will be automatically determined. If provided, the length of yticklabels must match the length of yticks.

  • alpha (float (default: 0.8)) – The transparency of the tracks.

  • order_tdata_by_mean (bool (default: True)) – Whether to order the tracks by their mean value (in descending order).

  • max_num_tracks (int (default: 50)) – The maximum number of tracks to plot.

  • legend_loc (str | None (default: 'upper right')) – The location of the legend (such as ‘upper left’ or ‘best’). See the matplotlib Axes legend documentation for more details and options. If None, no legend is shown.

  • **kwargs – Additional keyword arguments to pass to the plotting function.

Raises:

ValueError – If the shapes or metadata of the track data do not match, or if the number of tracks exceeds max_num_tracks, or if the track data has more than one positional axis, or if the interval is not set, or if colors are passed but do not match the track data names.

Methods

get_ax_height(axis_index)

Returns the height of the axis.

plot_ax(ax, axis_index, interval)

Plots the overlaid tracks on the given axis.