hapsburg.figures.plot_ibdx

Plotting function to plot IBD X Estimates from Ne @ Author: Harald Ringbauer, 2020, All rights reserved

Functions

new_column(df, df_meta[, col, col_new, match_col])

Maps Entries from meta dataframe onto the IBD dataframe.

give_sub_df(df[, pop1, pop2, col, output, exact])

Return sub dataframe where pair across pop1 and pop2

give_stats_cm_bin(df[, cms, col_b, output])

print some stats about IBD dataframe df

get_IBD_stats(df[, pop1, pop2, col, col_b, cms, output, a])

Get IBD fraction statistics.

get_IBD_stats_pops(df[, pops1, pops2, col, col_b, ...])

Get IBD fraction statistics for list of pop pairs.

get_ci_counts(counts, n[, a, minc])

Get Confidence Intervalls from counts and

create_Ne_roh_nr([Ns, bins, bin_n, chr_lgts])

Create ROH sharing in list of bins (list of [begin,end])

create_ne_dct(cms, ns[, chr_lgts])

Create Dictionary of Ne

plot_IBD_fracs(ax, cms1, fracs[, cis, n, c, xlim, ...])

Plot IBD fractions in cM bins. Plots on axis.

plot_ibd_curves([figsize, labels, cms, fracs, cis, ...])

Plot IBD X curves on one plot.

plot_ne_dct(ax[, dct_ne, bins, label_idx, c, fs])

Plot ne: ROH sharing onto axis

Module Contents

hapsburg.figures.plot_ibdx.new_column(df, df_meta, col='New Clade', col_new='', match_col='iid')

Maps Entries from meta dataframe onto the IBD dataframe. Return modified dataframe

hapsburg.figures.plot_ibdx.give_sub_df(df, pop1='La Caleta', pop2='La Caleta', col='clst', output=True, exact=False)

Return sub dataframe where pair across pop1 and pop2

hapsburg.figures.plot_ibdx.give_stats_cm_bin(df, cms=[4, 6, 8, 10, 12], col_b='n_roh>', output=True)

print some stats about IBD dataframe df col_b: Start of IBD/ROH column. If one of cms 0 use open upper bound

hapsburg.figures.plot_ibdx.get_IBD_stats(df, pop1='', pop2='', col='clade', col_b='n_roh>', cms=[4, 6, 8, 10, 12], output=False, a=0.05)

Get IBD fraction statistics. a: Signficance level Return fractions, confidence intervalls as well as number of pairsise comparisons col_b: Start of IBD/ROH column

hapsburg.figures.plot_ibdx.get_IBD_stats_pops(df, pops1=[], pops2=[], col='clade', col_b='n_roh>', cms=[4, 6, 8, 10, 12], output=False, a=0.05)

Get IBD fraction statistics for list of pop pairs. Returns lists of fractions, confidence intervalls as well as number of pairsise comparisons. a: Significance Level col_b: Start of IBD/ROH column

hapsburg.figures.plot_ibdx.get_ci_counts(counts, n, a=0.05, minc=0.0001)

Get Confidence Intervalls from counts and trials. Return list of CIS (lentght 2 each) counts: Array of Counts n: Total number of trials a: Signficance level

hapsburg.figures.plot_ibdx.create_Ne_roh_nr(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, chr_lgts=[])

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)]

hapsburg.figures.plot_ibdx.create_ne_dct(cms, ns, chr_lgts=[1.8085 * 2 / 3])

Create Dictionary of Ne

hapsburg.figures.plot_ibdx.plot_IBD_fracs(ax, cms1, fracs, cis=[], n=0, c='maroon', xlim=[4, 12], ylim=[0.001, 1.0], fs=(6, 6), lw=2, ms=6, yscale='log', show=False, hlines=[], lw_h=0.8, label='')

Plot IBD fractions in cM bins. Plots on axis. ax: Axis to plot on. cms1: Vector of cM mean bins. fracs: Fractions to plot on y cis: Confidence Intervals [n elements of length 2]

hapsburg.figures.plot_ibdx.plot_ibd_curves(figsize=(6, 6), labels=[], cms=[], fracs=[], cis=[], fs_big=16, fs_l=12, fs_t=12, label_idx=-1, xlim=[4, 12], ylim=[0.005, 1.1], colors=[], ylabel='# IBD per pair of male X', xlabel='centimorgan [2 cM bins]', savepath='', dpi=400, leg_loc='upper right', hlines=[0.001, 0.01, 0.1, 1.0], offset=0, dct_ne={}, frameon=False)

Plot IBD X curves on one plot. offset: Offset along x axis of each y value. label_idx: If>=0 Plot Ne labels on curves on according bin

hapsburg.figures.plot_ibdx.plot_ne_dct(ax, dct_ne={}, bins=[], label_idx=-1, c='lightgray', fs=12)

Plot ne: ROH sharing onto axis