hapsburg.figures.plot_bars ========================== .. py:module:: hapsburg.figures.plot_bars .. autoapi-nested-parse:: Main Inference Class for HMM. Wrapper for Inerence of Posterior. @ Author: Harald Ringbauer, 2019, All rights reserved Functions --------- .. autoapisummary:: hapsburg.figures.plot_bars.create_cousins_roh hapsburg.figures.plot_bars.create_Ne_roh hapsburg.figures.plot_bars.std_Ne_roh hapsburg.figures.plot_bars.plot_bar_ax hapsburg.figures.plot_bars.plot_close_kin hapsburg.figures.plot_bars.plot_panel_row hapsburg.figures.plot_bars.plot_legend_only hapsburg.figures.plot_bars.prepare_dfs_plot hapsburg.figures.plot_bars.prep_dfs_plot_exact hapsburg.figures.plot_bars.prep_xlabels Module Contents --------------- .. py:function:: create_cousins_roh(degrees=[1, 2, 3], bins=[[0.04, 0.08], [0.08, 0.12], [0.12, 0.2], [0.2, 3.0]], bin_n=10000) Create ROH sharing in list of bins (list of [begin,end]) for Cousins of degree degrees [list] return sharing [len(degrees), len(bins)] .. py:function:: create_Ne_roh(Ns=[400, 800, 1600, 3200, 6400], bins=[[0.04, 0.08], [0.08, 0.12], [0.12, 0.2], [0.2, 3.0]], bin_n=10000) Create ROH sharing in list of bins (list of [begin,end]) for panmictic population sizes Ns: List of population sizes bins: Length Bins (in Morgan) to calculate expectations from return sharing [len(degrees), len(bins)] .. py:function:: std_Ne_roh(Ns=[400, 800, 1600, 3200, 6400], bins=[[0.04, 0.08], [0.08, 0.12], [0.12, 0.2], [0.2, 3.0]], bin_n=10000) Create ROH sharing in list of bins (list of [begin,end]) for panmictic population sizes Ns: List of population sizes bins: Length Bins (in Morgan) to calculate expectations from return sharing [len(degrees), len(bins)] .. py:function:: plot_bar_ax(ax, y, bins=[], c=['#313695', '#abd9e9', '#fee090', '#d7191c'], x_ticks=[], ec='silver', fs_l=10, fs_y=10, fs_x=8, fs_t=10, alpha=1.0, barWidth=0.95, ylim=[0, 220], stds=[], title='', ha_title='left', bold_title=False, yticks=False, ylabel='Sum Inferred ROH>4cM [cM]', legend=False, r_title=0, hlines=[]) Plot bars of ROH on Axis. ax: Where to Plot on y: Array of ROH to plot: [n Inds, k Legnth Bins] c: Which colors to plot bins: List of Bins (needed for legend - plotted if len()>0) yticks: Whether to plot Y tick Labels legend: Whether to plot Legend fs_x, fs_y: Fontsize on the x and yLabels r_title: Rotation of the title hlines: List where to plot hlines .. py:function:: plot_close_kin(ax, y, y_plot=100, cutoffs=[50, 100], c='r', ec='k', lw=1, ss=[10, 14], m_cs=['v', 's'], bin_idx=-1) Plot Symbols for close kin at height y_symbol ss: Sizes of markers [List] m_cs: marker_colors [List] cutoffs: cutoffs [List] .. py:function:: plot_panel_row(plot_dfs, wspace=0.05, hspace=0.01, figsize=(24, 3.5), savepath='', x_labels=[], ylabel='Sum Inferred ROH>4cM [cM]', c=['#313695', '#abd9e9', '#fee090', '#d7191c'], ylim=[0, 250], r_title=90, bolds=[], fs_l=10, fs_y=10, fs_x=8, fs_t=10, ha_title='left', hspace_leg=1, leg_pos=-2, show=True, title_col='clst', titles=[], hlines=[], cols=['sum_roh>4', 'sum_roh>8', 'sum_roh>12', 'sum_roh>20'], bins=[[0.04, 0.08], [0.08, 0.12], [0.12, 0.2], [0.2, 3.0]], degrees=[1, 2, 3], Ns=[400, 800, 1600, 3200, 6400], ticks_c=['1st C.', '2nd C.', '3rd C.'], cutoffs=[], ec='k', lw=1, ss=[40, 50], m_cs=['v', 's'], sym_ofst=-10, bin_idx=-1) Plot row of ROH bin plots from plot_dfs (each df one panel) leg_pos = Where to plot legend (if outside range no legend plot) r_title: How much to rotate the title bolds: which titles to bold [list of bools] ha_title: Horizontal alignment of the titles fs_l, fs_y, fs_x, fs_t: Fontsize of legend, y and x labels and titles hspace_leg: Horizontol space between data plots and legend gs: Gridspec: If given plot on there legends: Whether to plot the two legends titles: If given, list of titles title_col: If not title use this column of the dataframe hlines: Where to plot horizontal lines cols: List of Column Names for plot_dfs (assumes > in increasing order) bins: list of length bins to plot [[a1,a2],...[z1,z2]] Ns: What population sizes to plot in barplot [list] degrees: What degrees of Cousins to plot. [list] ticks_c: Tick Labels for Cousin Legend [list] x_labels: If FALSE, don't plot any xlabels, if empty list default [list] .. py:function:: plot_legend_only(figsize=(7, 6), wspace=0.05, hspace=0.01, savepath='', hlines=[], fs_l=10, fs_y=10, fs_x=8, fs_t=10, c=['#313695', '#abd9e9', '#fee090', '#d7191c'], bins=[[0.04, 0.08], [0.08, 0.12], [0.12, 0.2], [0.2, 3.0]], ha_title='center', degrees=[1, 2, 3], Ns=[400, 800, 1600, 3200, 6400], ylim=[0, 250], x_ticks_c=['1st C.', '2nd C.', '3rd C.'], title_c='Recent Loops', title_N='Small Pop. Size', y_label='Expected Sum ROH>4cM [cM]') Plot Inbreeding from recent Cousins as well as small pop size. bins: list of length bins to plot [[a1,a2],...[z1,z2]] Ns: What population sizes to plot in barplot [list] degrees: What degrees of Cousins to plot. [list] .. py:function:: prepare_dfs_plot(df, cms=[4, 8, 12], col_group='clst', split_modern=True, mod_group='pop', sortcol=0) Prepare the Dataframe which to plot Return split up (and sorted) list of df, return list of column names df: Master Dataframe cms: Minimum Length of Chromosomes in bins sortcol: By which > column to sort within group [int] if split_modern, split age==0 samples by mod_group .. py:function:: prep_dfs_plot_exact(df, pops=[], col_group='pop', mod_only=False, exact=True, cm_sort=4) Pull all matching populations and return list of dataframes .. py:function:: prep_xlabels(plot_dfs, col_age='age') Prepare vector of x labels corresponding to ages of individuals