def plot_fractionDisagreements_perCohort(cohs):
    'Visualize fraction of samples with disagreements in thresholded copy \n    number for each gene. Run sequential_cohort_test_thresholded_values()\n    before this function.'
    df = sequential_cohort_test_thresholded_values(cohs)
    df_box = pd.melt(df.reset_index(), id_vars='Gene Symbol').set_index('Gene Symbol')
    df_box.columns = ['Tumor Type', 'Fraction of Samples with Disagreements']
    dft = df.T
    dft['med_degenerates'] = df.median(axis=0)
    boxorder = dft.sort_values('med_degenerates', axis=0).index
    df_cn = pd.read_table('../../PanCanAneuploidy/bin/PANCAN_armonly_ASandpuritycalls_092817_xcellcalls.txt', index_col=0, usecols=[0, 1, 2, 16])
    coh_medians = [int(np.median(df_cn[(df_cn['Type'] == x)]['RecurrentSCNA'].dropna())) for x in df_cn.Type.unique()]
    df_med = pd.DataFrame(coh_medians, index=df_cn.Type.unique(), columns=['med'])
    pal = sns.color_palette('Blues', ((max(df_med.med) - min(df_med.med)) + 1))
    my_pal = {c: pal[df_med.at[(c, 'med')]] for c in df_med.index}
    g = sns.boxplot(x=df_box.columns[0], y=df_box.columns[1], data=df_box, order=boxorder, fliersize=1, palette=my_pal, linewidth=0.5)
    newxticks = [(((x + ' (') + str(df_med.loc[x]['med'])) + ')') for x in boxorder]
    g.set_xticklabels(newxticks, rotation=90)
    plt.ylabel('Fraction with Disagreements', fontsize=12)
    sns.despine()
    plt.gcf().set_size_inches((8, 3))
    plt.savefig('2_thresholdedCN_boxplot.pdf', bbox_inches='tight')
    plt.savefig('2_thresholdedCN_boxplot.png', bbox_inches='tight')
Visualize fraction of samples with disagreements in thresholded copy 
number for each gene. Run sequential_cohort_test_thresholded_values()
before this function.
def plot_fractionDisagreements_perCohort(cohs):
    'Visualize fraction of samples with disagreements in thresholded copy \n    number for each gene. Run sequential_cohort_test_thresholded_values()\n    before this function.'
    df = sequential_cohort_test_thresholded_values(cohs)
    df_box = pd.melt(df.reset_index(), id_vars='Gene Symbol').set_index('Gene Symbol')
    df_box.columns = ['Tumor Type', 'Fraction of Samples with Disagreements']
    dft = df.T
    dft['med_degenerates'] = df.median(axis=0)
    boxorder = dft.sort_values('med_degenerates', axis=0).index
    df_cn = pd.read_table('../../PanCanAneuploidy/bin/PANCAN_armonly_ASandpuritycalls_092817_xcellcalls.txt', index_col=0, usecols=[0, 1, 2, 16])
    coh_medians = [int(np.median(df_cn[(df_cn['Type'] == x)]['RecurrentSCNA'].dropna())) for x in df_cn.Type.unique()]
    df_med = pd.DataFrame(coh_medians, index=df_cn.Type.unique(), columns=['med'])
    pal = sns.color_palette('Blues', ((max(df_med.med) - min(df_med.med)) + 1))
    my_pal = {c: pal[df_med.at[(c, 'med')]] for c in df_med.index}
    g = sns.boxplot(x=df_box.columns[0], y=df_box.columns[1], data=df_box, order=boxorder, fliersize=1, palette=my_pal, linewidth=0.5)
    newxticks = [(((x + ' (') + str(df_med.loc[x]['med'])) + ')') for x in boxorder]
    g.set_xticklabels(newxticks, rotation=90)
    plt.ylabel('Fraction with Disagreements', fontsize=12)
    sns.despine()
    plt.gcf().set_size_inches((8, 3))
    plt.savefig('2_thresholdedCN_boxplot.pdf', bbox_inches='tight')
    plt.savefig('2_thresholdedCN_boxplot.png', bbox_inches='tight')