示例#1
0
def fig_boxplotcomparison(regular, phospho, sheet, column, bounds, figpath):
    """
    Figure 2c from Aurora paper
    """
    #%%
    xvals = []
    yvals = []
    for i, j in zip([regular[sheet], regular[column], phospho[sheet].values, phospho[column].values], ["peptides", "norm_peptides", "phospho", "norm_phospho"]):
        xvals.extend(i)
        yvals.extend([j]*len(i))

    df = pd.DataFrame([xvals, yvals]).transpose()
    df.columns = [column, "peptide type"]
    #%%
    lower_bound = bounds[0]
    upper_bound = bounds[1]
    bmap = brewer2mpl.get_map('Paired', 'Qualitative', 6).mpl_colors
    f, ax = plt.subplots(1, figsize=(11.69, 8.27))
    sns.boxplot(x="peptide type", y=column, data=df, palette=bmap)
    ax.set(xticks=[0, 1, 2, 3],
           xticklabels=["peptides", "peptides \n(normalized)", "phospho-\npeptides", "phosphopeptides \n(normalized)"])
    ax.set(ylim=(-2, 2), ylabel="log2 (fold change)", title=column)
    ax.axhline(lower_bound, ls="--", lw=2, color="red", alpha=0.7)
    ax.axhline(upper_bound, ls="--", lw=2, color="red", alpha=0.7)
    ax.yaxis.set_major_locator(MaxNLocator(4))
    sns.despine()
    cutils.save_fig(f, figpath+"162_BoxplotNorm_{}".format(column))
示例#2
0
def fig_phosints(infile1, infile2, figpath, labels=3):
    """
    Visualize the non-phospgorylated vs. phosphorylated peptide ratios.
    """
    if labels==3:
        sheetnames = ["log2HL", "log2HM", "log2ML"]
    else:
        sheetnames = ["log2HL"]
    for sheet in sheetnames:
        phospho = pd.read_excel(infile1, sheetname=sheet)
        regular = pd.read_excel(infile2, sheetname=sheet)
        column = "norm_"+ sheet
        #%%

        #======================================================================
        #         Scatterplot: General trend
        #======================================================================
        maxx = np.max([np.max(phospho[column]), abs(np.min(phospho[column]))]) + 0.1
        f, ax = plt.subplots(1, figsize=(11.69, 8.27))
        ax.scatter(regular[column], np.log10(regular["Area"]), s=80, lw=1,
                   alpha=0.7, label="Regular peptides")
        ax.scatter(phospho[column], np.log10(phospho["Area"]), c="green",
                   s=80, lw=1, alpha=0.7, label="phospho peptides")
        ax.set(title="Normalized peptide Ratios: {}".format(sheet),
               xlabel="log2 (fold change)", ylabel="log10 (intensity)",
                xlim=(-maxx, maxx))
        ax.legend(loc="upper left")
        ax.xaxis.set_major_locator(MaxNLocator(4))
        ax.yaxis.set_major_locator(MaxNLocator(4))
        sns.despine()
        cutils.save_fig(f, figpath+"162_Intensityscatter_{}".format(column))
        #%%
        #======================================================================
        #         Histogram
        #======================================================================
        #%%
        xvalues = regular[column].values
        # ratio histogram
        bounds = fig_ratiohisto(xvalues, column, figpath)

        #boxplot over all ratios
        fig_boxplotcomparison(regular, phospho, sheet, column, bounds, figpath)
示例#3
0
def fig_ratiohisto(xvalues, column, figpath):
    #%%
    alpha = 0.05
    f, ax = plt.subplots(1, figsize=(11.69, 8.27))
    ax.hist(xvalues, bins=80, normed=True, alpha=0.7)
    maxx = np.max([np.max(xvalues), abs(np.min(xvalues))]) + 0.1
    x = np.linspace(-maxx, maxx, 100)
    loc, scale = cutils.estimate_normal_params(xvalues)
    lower_bound = stats.norm.ppf(alpha/2, loc=loc, scale=scale)
    upper_bound = stats.norm.ppf(1 - alpha/2, loc=loc, scale=scale)
    p = norm.pdf(x, loc, scale)
    ax.plot(x, p, '--', linewidth=2, alpha=0.8, lw=2, c="k")
    ax.set_xlim(-1.5, 1.5)
    ax.xaxis.set_major_locator(MaxNLocator(4))
    ax.yaxis.set_major_locator(MaxNLocator(4))
    ax.set(xlabel="log2 (foldchange)", ylabel="Density", title="Normalized peptides ratio {}".format(column))
    ax.axvline(lower_bound, ls="--", lw=2, color="red", alpha=0.7)
    ax.axvline(upper_bound, ls="--", lw=2, color="red", alpha=0.7)
    sns.despine()
    cutils.save_fig(f, figpath+"162_FitHistogram_{}".format(column))
    return(lower_bound, upper_bound)