In [19]:
%matplotlib inline
import numpy as np
import pandas as pd
import scipy as sp
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns
IP reaction (1 mL)
Ab in reaction
Kd = [Ab] [L] / [AbL]
Inputs: Desired Kd ability to resolve Total Ab and L (e.g., [Ab] + [AbL]) requires overwhelming Protein A/G binding sites?
In [23]:
df = pd.read_csv('/Users/laserson/lasersonlab/larman/libraries/T7-Pep_InputCountsComplete46M.csv', header=None, index_col=0)
In [24]:
counts = df.values.ravel()
In [25]:
sns.distplot(counts)
Out[25]:
(min, 10%ile, 50%ile, 90%ile, max)
In [46]:
iles = (counts.min(), sp.stats.scoreatpercentile(counts, 10), sp.stats.scoreatpercentile(counts, 50), sp.stats.scoreatpercentile(counts, 90), counts.max())
iles
Out[46]:
In [38]:
cov = sum(counts)
cov
Out[38]:
And the same values as frequencies
In [39]:
tuple([float(val) / cov for val in iles])
Out[39]:
In [41]:
counts.mean(), counts.std()
Out[41]:
In [47]:
(18. / cov) * 1e10
Out[47]:
In [48]:
(229. / cov) * 1e10
Out[48]:
In [52]:
(counts > 0).sum()
Out[52]:
In [53]:
counts.shape
Out[53]:
In [101]:
def equil_conc(total_antibody, total_phage, Kd):
s = total_antibody + total_phage + Kd
bound = 0.5 * (s - np.sqrt(s * s - 4 * total_antibody * total_phage))
equil_antibody = total_antibody - bound
equil_phage = total_phage - bound
return (equil_antibody, equil_phage, bound)
In [102]:
equil_conc(13e-15, 8.302889405513118e-17, 1e-9)
Out[102]:
In [103]:
np.logspace?
In [148]:
antibody_concentrations = np.logspace(-15, -3, num=25)
phage_concentrations = np.logspace(-18, -12, num=13)
antibody_labels = ['{:.1e}'.format(c) for c in antibody_concentrations]
phage_labels = ['{:.1e}'.format(c) for c in phage_concentrations]
Kd = 1e-8
frac_antibody_bound = np.zeros((len(antibody_concentrations), len(phage_concentrations)))
frac_phage_bound = np.zeros((len(antibody_concentrations), len(phage_concentrations)))
for (i, a) in enumerate(antibody_concentrations):
for (j, p) in enumerate(phage_concentrations):
bound = equil_conc(a, p, Kd)[2]
frac_antibody_bound[i, j] = bound / a
frac_phage_bound[i, j] = bound / p
fig = plt.figure(figsize=(12, 6))
ax = fig.add_subplot(121)
sns.heatmap(frac_antibody_bound, xticklabels=phage_labels, yticklabels=antibody_labels, square=True, ax=ax)
ax.set_title('Fraction Antibody Bound')
ax.set_ylabel('total antibody clone conc')
ax.set_xlabel('total phage clone conc')
ax = fig.add_subplot(122)
sns.heatmap(frac_phage_bound, xticklabels=phage_labels, yticklabels=antibody_labels, square=True, ax=ax)
ax.set_title('Fraction Phage Bound')
ax.set_ylabel('total antibody clone conc')
ax.set_xlabel('total phage clone conc')
Out[148]:
It's most important to ensure we get maximal phage capture, and this seems to be independent of the total phage concentration. Let's instead explore the fraction phage bound as a function of the antibody concentration and Kd
In [147]:
antibody_concentrations = np.logspace(-15, -3, num=25)
Kds = np.logspace(-15, -6, num=19)
antibody_labels = ['{:.1e}'.format(c) for c in antibody_concentrations]
Kd_labels = ['{:.1e}'.format(c) for c in Kds]
phage_concentration = 2e-15
frac_antibody_bound = np.zeros((len(antibody_concentrations), len(Kds)))
frac_phage_bound = np.zeros((len(antibody_concentrations), len(Kds)))
for (i, a) in enumerate(antibody_concentrations):
for (j, Kd) in enumerate(Kds):
bound = equil_conc(a, phage_concentration, Kd)[2]
frac_antibody_bound[i, j] = bound / a
frac_phage_bound[i, j] = bound / phage_concentration
fig = plt.figure(figsize=(9, 9))
# ax = fig.add_subplot(121)
# sns.heatmap(frac_antibody_bound, xticklabels=Kd_labels, yticklabels=antibody_labels, square=True, ax=ax)
# ax.set_title('Fraction Antibody Bound')
# ax.set_ylabel('total antibody clone conc')
# ax.set_xlabel('Kd')
ax = fig.add_subplot(111)
sns.heatmap(frac_phage_bound, xticklabels=Kd_labels, yticklabels=antibody_labels, square=True, ax=ax)
ax.set_title('Fraction Phage Bound')
ax.set_ylabel('total antibody clone conc')
ax.set_xlabel('Kd')
Out[147]:
In [ ]: