gnomad.utils.plotting
|
|
|
Plot histogram from Hail hist aggregation. |
Plot multiple histograms on the same plot. |
|
Plot cumulative histogram from Hail hist aggregation. |
|
|
|
Take path to hail Table or MatrixTable (gs://bucket/path/hail.mt), output Grid or Tabs, respectively. |
|
|
|
|
Plot each column of data against each other and returns a grid of plots. |
- 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 plottitle (
str
) – Plot titlelog (
bool
) – Whether the y-axis should be logfill_color (
str
) – Color to fill the histogram bars that fall within the hist boundariesoutlier_fill_color (
str
) – Color to fill the histogram bars that fall outside the hist boundariesline_color (
str
) – Color of the lines around the histogram barshover_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 plottitle (
str
) – Plot titlelog (
bool
) – Whether the y-axis should be logfill_color (
Dict
[str
,str
]) – Color to fill the histogram bars that fall within the hist boundariesoutlier_fill_color (
Dict
[str
,str
]) – Color to fill the histogram bars that fall outside the hist boundariesline_color (
str
) – Color of the lines around the histogram barshover_mode (
str
) – Hover mode; one of ‘mouse’ (default), ‘vline’ or ‘hline’hide_zeros (
bool
) – Remove hist bars with 0 countalpha (
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 plottitle (
str
) – Plot titlenormalize (
bool
) – Whether to normalize the data (0,1)line_color (
str
) – Color of the lineline_width (
int
) – Width of the linelog (
bool
) – Whether the y-axis should be loghover_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.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.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 plotlabel_col (
str
) – Column of the DataFrame containing the labelscolors (
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 plotstooltip_cols (
List
[str
]) – Additional columns that should be displayed in tooltip
- Return type:
Column
- Returns:
Grid of plots (column of rows)