gnomad.utils.plotting

gnomad.utils.plotting.new_show(t[, n, ...])

gnomad.utils.plotting.plot_hail_hist(hist_data)

Plot histogram from Hail hist aggregation.

gnomad.utils.plotting.plot_multi_hail_hist(...)

Plot multiple histograms on the same plot.

gnomad.utils.plotting.plot_hail_hist_cumulative(...)

Plot cumulative histogram from Hail hist aggregation.

gnomad.utils.plotting.plot_hail_hist_both(...)

gnomad.utils.plotting.set_font_size(p[, ...])

gnomad.utils.plotting.linear_and_log_tabs(...)

gnomad.utils.plotting.plot_hail_file_metadata(t_path)

Take path to hail Table or MatrixTable (gs://bucket/path/hail.mt), output Grid or Tabs, respectively.

gnomad.utils.plotting.scale_file_sizes(...)

gnomad.utils.plotting.get_rows_data(rows_files)

gnomad.utils.plotting.pair_plot(data[, ...])

Plot each column of data against each other and returns a grid of plots.

gnomad.utils.plotting.new_show(t, n=10, width=140, truncate=40, types=True)[source]
gnomad.utils.plotting.plot_hail_hist(hist_data, title='Plot', log=False, fill_color='#033649', outlier_fill_color='#036564', line_color='#033649', hover_mode='mouse', hide_zeros=False)[source]

Plot histogram from Hail hist aggregation.

hist_data can (and should) come straight from ht.aggregate(hl.agg.hist(ht.data, start, end, bins))

Parameters:
  • hist_data (Struct) – Data to plot

  • title (str) – Plot title

  • log (bool) – Whether the y-axis should be log

  • fill_color (str) – Color to fill the histogram bars that fall within the hist boundaries

  • outlier_fill_color (str) – Color to fill the histogram bars that fall outside the hist boundaries

  • line_color (str) – Color of the lines around the histogram bars

  • hover_mode (str) – Hover mode; one of ‘mouse’ (default), ‘vline’ or ‘hline’

  • hide_zeros (bool) – Remove hist bars with 0 count

Return type:

figure

Returns:

Histogram plot

gnomad.utils.plotting.plot_multi_hail_hist(hist_data, title='Plot', log=False, fill_color=None, outlier_fill_color=None, line_color='#033649', hover_mode='mouse', hide_zeros=False, alpha=None)[source]

Plot multiple histograms on the same plot.

Each histogram can (and should) come straight from ht.aggregate(hl.agg.hist(ht.data, start, end, bins))

Example usage:

plot_multi_hail_hist(ht.aggregate(hl.agg.group_by(ht.pop, hl.agg.hist(ht.data, start, end, bins))))
Parameters:
  • hist_data (Dict[str, Struct]) – Data to plot

  • title (str) – Plot title

  • log (bool) – Whether the y-axis should be log

  • fill_color (Dict[str, str]) – Color to fill the histogram bars that fall within the hist boundaries

  • outlier_fill_color (Dict[str, str]) – Color to fill the histogram bars that fall outside the hist boundaries

  • line_color (str) – Color of the lines around the histogram bars

  • hover_mode (str) – Hover mode; one of ‘mouse’ (default), ‘vline’ or ‘hline’

  • hide_zeros (bool) – Remove hist bars with 0 count

  • alpha (float) – Alpha value (if None, then 1.0/len(hist_data) is used)

Return type:

figure

Returns:

Histogram plot

gnomad.utils.plotting.plot_hail_hist_cumulative(hist_data, title='Plot', normalize=True, line_color='#036564', line_width=3, log=False, hover_mode='mouse')[source]

Plot cumulative histogram from Hail hist aggregation.

hist_data can (and should) come straight from ht.aggregate(hl.agg.hist(ht.data, start, end, bins))

Parameters:
  • hist_data (Struct) – Data to plot

  • title (str) – Plot title

  • normalize (bool) – Whether to normalize the data (0,1)

  • line_color (str) – Color of the line

  • line_width (int) – Width of the line

  • log (bool) – Whether the y-axis should be log

  • hover_mode (str) – Hover mode; one of ‘mouse’ (default), ‘vline’ or ‘hline’

Return type:

figure

Returns:

Histogram plot

gnomad.utils.plotting.plot_hail_hist_both(hist_data, title, normalize=True, log=False)[source]
Parameters:
  • hist_data (Struct) –

  • title (str) –

  • normalize (bool) –

  • log (bool) –

gnomad.utils.plotting.set_font_size(p, font_size='12pt')[source]
Parameters:

font_size (str) –

gnomad.utils.plotting.linear_and_log_tabs(plot_func, **kwargs)[source]
Parameters:

plot_func (Callable) –

Return type:

Tabs

gnomad.utils.plotting.plot_hail_file_metadata(t_path)[source]

Take path to hail Table or MatrixTable (gs://bucket/path/hail.mt), output Grid or Tabs, respectively.

Or if an unordered Table is provided, a Figure with file sizes is output. If metadata file or rows directory is missing, returns None.

Parameters:

t_path (str) –

Return type:

Union[Grid, Tabs, figure, None]

gnomad.utils.plotting.scale_file_sizes(file_sizes)[source]
gnomad.utils.plotting.get_rows_data(rows_files)[source]
gnomad.utils.plotting.pair_plot(data, label_col=None, colors=None, tools='save,pan,box_zoom,reset,wheel_zoom,box_select,lasso_select,help', tooltip_cols=None)[source]

Plot each column of data against each other and returns a grid of plots.

The diagonal contains a histogram of each column, or a density plot if labels are provided. The lower diagonal contains scatter plots of each column against each other. The upper diagonal is empty.

All columns should be numerical with the exception of the label_col if provided. If a color dict containing provided mapping labels to specific colors can be specified using color_dict

Parameters:
  • data (DataFrame) – Dataframe to plot

  • label_col (str) – Column of the DataFrame containing the labels

  • colors (Union[List[str], Dict[str, str]]) – RGB hex colors. If a dict is provided, it should contain the mapping of label to colors.

  • tools (str) – Tools for the resulting plots

  • tooltip_cols (List[str]) – Additional columns that should be displayed in tooltip

Return type:

Column

Returns:

Grid of plots (column of rows)