def plot_box(data, which, outname, palette, regulation, group, args=None):
    (fig, ax1) = plt.subplots(figsize=(8, 12))
    box_data = defaultdict(list)
    names = []
    if (which == 'cnv'):
        how = 'mean'
        for (name, g) in group.items():
            names.append(name)
            box_data[name] = data[g]
    else:
        how = 'sum'
        for (name, g) in group.items():
            names.append(name)
            box_data[name] = data[g]
    (z, p) = ranksums(box_data[names[0]], box_data[names[1]])
    if (p >= 0.05):
        plt.close()
        return
    data.to_csv(((outname + ('_box_data_%s' % regulation)) + '.txt'), sep='\t')
    if (args.ac and args.bc):
        group1 = list(group.keys())[0]
        group2 = list(group.keys())[1]
        palette[group1] = args.ac
        palette[group2] = args.bc
    sns.boxplot(data=pd.DataFrame(box_data), ax=ax1, width=0.2, linewidth=0.5, palette=palette)
    ax1.set_title(('Difference of %s (p = %f)' % (which, p)), size=30)
    ax1.set_ylabel(('%s value' % which), size=30)
    fig.autofmt_xdate(ha='center', rotation=0)
    plt.xticks(rotation=0, size=30)
    plt.legend()
    fig.savefig(('%s_box_data_%s_%s_Boxplot.%s' % (outname, regulation, how, args.save)), dpi=600, size=0.5)
    plt.close()
def plot_box(data, which, outname, palette, regulation, group, args=None):
    (fig, ax1) = plt.subplots(figsize=(8, 12))
    box_data = defaultdict(list)
    names = []
    if (which == 'cnv'):
        how = 'mean'
        for (name, g) in group.items():
            names.append(name)
            box_data[name] = data[g]
    else:
        how = 'sum'
        for (name, g) in group.items():
            names.append(name)
            box_data[name] = data[g]
    (z, p) = ranksums(box_data[names[0]], box_data[names[1]])
    if (p >= 0.05):
        plt.close()
        return
    data.to_csv(((outname + ('_box_data_%s' % regulation)) + '.txt'), sep='\t')
    if (args.ac and args.bc):
        group1 = list(group.keys())[0]
        group2 = list(group.keys())[1]
        palette[group1] = args.ac
        palette[group2] = args.bc
    sns.boxplot(data=pd.DataFrame(box_data), ax=ax1, width=0.2, linewidth=0.5, palette=palette)
    ax1.set_title(('Difference of %s (p = %f)' % (which, p)), size=30)
    ax1.set_ylabel(('%s value' % which), size=30)
    fig.autofmt_xdate(ha='center', rotation=0)
    plt.xticks(rotation=0, size=30)
    plt.legend()
    fig.savefig(('%s_box_data_%s_%s_Boxplot.%s' % (outname, regulation, how, args.save)), dpi=600, size=0.5)
    plt.close()