Ejemplo n.º 1
0
def mixBispecYN(L0, KxStar, Rtot, Kav, fully=True):
    """ Compare bispecific to mixture of bivalent  """
    if fully:
        return polyc(L0, KxStar, Rtot, [[1, 1]], [1.0], Kav)[2][0] / \
            np.sum(polyc(L0, KxStar, Rtot, [[2, 0], [0, 2]], [0.5, 0.5], Kav)[2])
    else:
        return polyc(L0, KxStar, Rtot, [[1, 1]], [1.0], Kav)[0][0] / \
            np.sum(polyc(L0, KxStar, Rtot, [[2, 0], [0, 2]], [0.5, 0.5], Kav)[0])
Ejemplo n.º 2
0
def tetheredYN(L0, KxStar, Rtot, Kav, fully=True):
    """ Compare tethered (bispecific) vs monovalent  """
    if fully:
        return polyc(L0, KxStar, Rtot, [[1, 1]], [1.0], Kav)[2][0] / \
            polyfc(L0 * 2, KxStar, 1, Rtot, [0.5, 0.5], Kav)[0]
    else:
        return polyc(L0, KxStar, Rtot, [[1, 1]], [1.0], Kav)[0][0] / \
            polyfc(L0 * 2, KxStar, 1, Rtot, [0.5, 0.5], Kav)[0]
Ejemplo n.º 3
0
def selectivity(pop1name, pop2name, L0, KxStar, Cplx, Ctheta, Kav, fully=True, untethered=False):
    """ Always calculate the full binding of the 1st kind of complex """
    pop1 = cellPopulations[pop1name][0], cellPopulations[pop1name][1]
    pop2 = cellPopulations[pop2name][0], cellPopulations[pop2name][1]
    if untethered:  # mixture of monovalent
        return polyfc(L0, KxStar, 1, np.power(10, pop1), [0.5, 0.5], Kav)[0] \
            / polyfc(L0, KxStar, 1, np.power(10, pop2), [0.5, 0.5], Kav)[0]
    if fully:
        return np.sum(polyc(L0, KxStar, np.power(10, pop1), Cplx, Ctheta, Kav)[2]) \
            / np.sum(polyc(L0, KxStar, np.power(10, pop2), Cplx, Ctheta, Kav)[2])
    else:
        return np.sum(polyc(L0, KxStar, np.power(10, pop1), Cplx, Ctheta, Kav)[0]) \
            / np.sum(polyc(L0, KxStar, np.power(10, pop2), Cplx, Ctheta, Kav)[0])
def heatmapNorm(ax, R0, L0, KxStar, Kav, Comp, f=None, Cplx=None, vrange=(0, 5), title="", cbar=False, layover=2, highlight=[], lineN=101, recFactor=1.0):
    assert bool(f is None) != bool(Cplx is None)
    nAbdPts = 70
    abundRange = (LR + np.log10(recFactor), HR + np.log10(recFactor))
    abundScan = np.logspace(abundRange[0], abundRange[1], nAbdPts)

    if f is None:
        func = np.vectorize(lambda abund1, abund2: polyc(L0, KxStar, [abund1, abund2], Cplx, Comp, Kav)[2][0])
    else:
        func = np.vectorize(lambda abund1, abund2: polyfc(L0, KxStar, f, [abund1, abund2], Comp, Kav)[0])

    func0 = func(10**(R0[0] + np.log10(recFactor)), 10**(R0[1] + np.log10(recFactor)))
    X, Y = np.meshgrid(abundScan, abundScan)
    Z = func(X, Y) / func0

    contours1 = ax.contour(X, Y, Z, levels=np.logspace(0, 10, (lineN - 1) // 2 + 1)[1:], colors="black", linewidths=0.5)
    contours0 = ax.contour(X, Y, Z, levels=np.logspace(-10, 0, (lineN - 1) // 2 + 1), colors="white", linewidths=0.5)
    ax.set_xscale("log")
    ax.set_yscale("log")
    ax.set_title(title)
    plt.clabel(contours1, inline=True, fontsize=8, fmt="%3.1g")
    plt.clabel(contours0, inline=True, fontsize=8, fmt="%3.1g")
    ax.pcolor(X, Y, Z, cmap='viridis', vmin=vrange[0], vmax=vrange[1])
    norm = plt.Normalize(vmin=vrange[0], vmax=vrange[1])
    if cbar:
        cbar = ax.figure.colorbar(cm.ScalarMappable(norm=norm, cmap='viridis'), ax=ax)
        cbar.set_label("Relative Ligand Bound")
    # layover: 2 = with name; 1 = only pop w/o name; 0 = none
    if layover == 2:
        overlapCellPopulation(ax, abundRange, highlight=highlight, recFactor=np.log10(recFactor), pname=True)
    elif layover == 1:
        overlapCellPopulation(ax, abundRange, highlight=highlight, recFactor=np.log10(recFactor), pname=False)
def heatmap(ax, L0, KxStar, Kav, Comp, f=None, Cplx=None, vrange=(-2, 4), title="", cbar=False, layover=2, fully=False, highlight=[]):
    assert bool(f is None) != bool(Cplx is None)
    nAbdPts = 70
    abundRange = (LR, HR)
    abundScan = np.logspace(abundRange[0], abundRange[1], nAbdPts)

    if f is None:
        if fully:
            func = np.vectorize(lambda abund1, abund2: np.sum(polyc(L0, KxStar, [abund1, abund2], Cplx, Comp, Kav)[2]))
        else:
            func = np.vectorize(lambda abund1, abund2: np.sum(polyc(L0, KxStar, [abund1, abund2], Cplx, Comp, Kav)[0]))
    else:
        func = np.vectorize(lambda abund1, abund2: polyfc(L0, KxStar, f, [abund1, abund2], Comp, Kav)[0])

    X, Y = np.meshgrid(abundScan, abundScan)
    logZ = np.log(func(X, Y))

    vmed = int((vrange[0] + vrange[1]) / 2)
    contours0 = ax.contour(X, Y, logZ, levels=np.arange(-20, vmed, 1), colors="white", linewidths=0.5)
    contours1 = ax.contour(X, Y, logZ, levels=np.arange(vmed, 20, 1), colors="black", linewidths=0.5)
    ax.set_xscale("log")
    ax.set_yscale("log")

    ax.yaxis.set_major_formatter(mticker.ScalarFormatter(useOffset=False, useMathText=True))

    ax.set_title(title)
    plt.clabel(contours0, inline=True, fontsize=8)
    plt.clabel(contours1, inline=True, fontsize=8)
    ax.pcolor(X, Y, logZ, cmap='viridis', vmin=vrange[0], vmax=vrange[1])
    norm = plt.Normalize(vmin=vrange[0], vmax=vrange[1])
    if cbar:
        cbar = ax.figure.colorbar(cm.ScalarMappable(norm=norm, cmap='viridis'), ax=ax)
        cbar.set_label("Log Ligand Bound")
    # layover: 2 = with name; 1 = only pop w/o name; 0 = none
    if layover == 2:
        overlapCellPopulation(ax, abundRange, highlight=highlight, pname=True)
    elif layover == 1:
        overlapCellPopulation(ax, abundRange, highlight=highlight, pname=False)
Ejemplo n.º 6
0
def sigmaPopC(name, L0, KxStar, Cplx, Ctheta, Kav, quantity=0, h=None):
    return np.array([
        polyc(L0, KxStar, Rtot, Cplx, Ctheta, Kav)[quantity][1]
        for Rtot in sigmapts(name, h=h)
    ]).reshape(-1)
Ejemplo n.º 7
0
def heatmapDL(ax,
              L0,
              KxStar,
              Kav,
              Comp,
              Cplx=None,
              vrange=(-2, 4),
              title="",
              cbar=True,
              dead=False,
              jTherap=False,
              highlight=[],
              lowlight=[]):
    "Makes a heatmap with modified cell population abundances according to Antagonist binding"
    nAbdPts = 70
    abunds = np.array(list(cellPopulations.values()))[:, 0:2]
    abundRange = (np.amin(abunds) - 1, np.amax(abunds) + 1)
    abundScan = np.logspace(abundRange[0], abundRange[1], nAbdPts)
    if dead:
        func = np.vectorize(lambda abund1, abund2: polyc(
            L0, KxStar, [abund1, abund2], Cplx, Comp, Kav)[0][0])
        title = "Antagonist Bound"
    else:
        func = np.vectorize(lambda abund1, abund2: polyc(
            L0, KxStar, [abund1, abund2], Cplx, Comp, Kav)[0][1])
        if jTherap:
            title = "Agonist Bound without Antagonist"
        else:
            title = "Agonist Bound with Antagonist"

    X, Y = np.meshgrid(abundScan, abundScan)
    logZ = np.log(func(X, Y))
    vmed = int((vrange[0] + vrange[1]) / 2)
    contours0 = ax.contour(X,
                           Y,
                           logZ,
                           levels=np.arange(-20, vmed, 1.0),
                           colors="white",
                           linewidths=0.5)
    contours1 = ax.contour(X,
                           Y,
                           logZ,
                           levels=np.arange(vmed, 20, 1.0),
                           colors="black",
                           linewidths=0.5)
    ax.set_xscale("log")
    ax.set_yscale("log")
    ax.set_title(title)
    plt.clabel(contours0, inline=True, fontsize=8)
    plt.clabel(contours1, inline=True, fontsize=8)
    ax.pcolor(X, Y, logZ, cmap='viridis', vmin=vrange[0], vmax=vrange[1])
    norm = plt.Normalize(vmin=vrange[0], vmax=vrange[1])
    ax.set(xlabel="Receptor 1 Abundance (#/cell)",
           ylabel='Receptor 2 Abundance (#/cell)')
    if cbar:
        cbar = ax.figure.colorbar(cm.ScalarMappable(norm=norm, cmap='viridis'),
                                  ax=ax,
                                  aspect=40)
        cbar.set_label("Log Ligand Bound")
    overlapCellPopulation(ax,
                          abundRange,
                          data=cellPopulations,
                          highlight=highlight,
                          lowlight=lowlight)