## ~dhogan/rnap

c0b76b03b3653b25c359dd92771c98fb8cabb288 — Daniel Hogan 1 year, 2 months ago
use rates instead of dwells

1 files changed, 39 insertions(+), 37 deletions(-)

M figures.py

M figures.py => figures.py +39 -37
@@ 498,14 498,14 @@ def fretStateHist(data):
ax = plt.subplot(1, 1, 1)
for template in templates:
histData = templateDifferenceArrays[template]
-        if np.mean(histData) < 0: label = f"{template}\n(-{np.mean(histData):.4f}\u00B1{np.std(histData)/np.sqrt(len(histData)):.4f})"
-        else: label = f"{template}\n({np.mean(histData):.4f}\u00B1{np.std(histData)/np.sqrt(len(histData)):.4f})",
+        if np.mean(histData) < 0:
+            label = f"{template}\n(-{np.mean(histData):.4f}\u00B1{np.std(histData)/np.sqrt(len(histData)):.4f})"
+        else:
+            label = (
+                f"{template}\n({np.mean(histData):.4f}\u00B1{np.std(histData)/np.sqrt(len(histData)):.4f})",
+            )
plt.hist(
-            histData,
-            bins="auto",
-            histtype="step",
-            label=label,
-            color=color[template],
+            histData, bins="auto", histtype="step", label=label, color=color[template]
)
# plt.title('Per trace FRET difference')
simplifyAxes(ax)

@@ 647,15 647,17 @@ def repTrace(data, name):
print("Done")

-def tau(array):
+def k(array):
t1 = 0.5
t2 = np.median(array) + 0.0001
n1 = len([t for t in array if t1 < t < t2])
n2 = len([t for t in array if t2 < t])
-    tc = (t2 - t1) / np.log((n1 / n2) + 1)
+    k = np.log((n1 / n2) + 1) / (t2 - t1)
n = n1 + n2
-    tmax, tmin = 2 * n * tc / np.array(chi2.interval(0.68, 2 * n))
-    return tc, (tmin, tmax)
+    kmin, kmax = np.array(chi2.interval(0.682689, 2 * n)) * k / (2 * n)
+    assert (kmax - k) - (k - kmin) < 0.001 * k
+    sigmak = kmax - k
+    return k, sigmak

def pauseDurations(data):

@@ 707,18 709,17 @@ def pauseDurations(data):
[False, False, False, True, True, True, True],
):
pts = pdwells[(f, gtp, hp)]
-        ptau, psigma = tau(pts)
-        y.append(ptau)
-        yerror.append(np.abs(np.array(psigma) - ptau))
+        pk, psigmak = k(pts)
+        y.append(pk)
+        yerror.append(psigmak)
print(
-            f"\t{f}\t{gtp}\t{len(pts)}\t${ptau:2.2f}^{{+{psigma[1]-ptau:2.2f}}}_{{{psigma[0]-ptau:2.2f}}}$"
+            f"\t{f}\t{gtp}\t{len(pts)}\t\SI{{{pk:2.3f} \pm {psigmak:2.3f}}}{{\per\second}}"
)
-    yerror = np.array(yerror).T
template = "hairpin pause"
plt.bar(
x[3:],
y[3:],
-        yerr=yerror[:, 3:],
+        yerr=yerror[3:],
label="hairpin",
linewidth=2,
color=fill[template],

@@ 729,7 730,7 @@ def pauseDurations(data):
plt.bar(
x[:3],
y[:3],
-        yerr=yerror[:, :3],
+        yerr=yerror[:3],
label="no hairpin",
linewidth=2,
color=fill[template],

@@ 740,22 741,21 @@ def pauseDurations(data):
x[0:2] + [np.mean(x[2:4])] + x[4:],
["25", "50", "200/250", "1000", "250", "1000"],
)
-    forcebar = np.max(np.array(y) + np.array(yerror)) + 1
+    forcebar = 0.45
plt.plot([0.75, 5.25], [forcebar, forcebar], color="k")
plt.annotate(
-        "10 pN", xy=(3, forcebar + 0.3), xycoords="data", horizontalalignment="center"
+        "10 pN", xy=(3, forcebar + 0.025), xycoords="data", horizontalalignment="center"
)
plt.plot([6.25, 7.75], [forcebar, forcebar], color="k")
plt.annotate(
-        "5 pN", xy=(7, forcebar + 0.3), xycoords="data", horizontalalignment="center"
+        "5 pN", xy=(7, forcebar + 0.025), xycoords="data", horizontalalignment="center"
)
-    plt.axis([np.min(x) - 1, np.max(x) + 1, 0, np.ceil(forcebar + 0.5)])
-    plt.legend(loc=(0.015, 0.7))
+    plt.axis([np.min(x) - 1, np.max(x) + 1, 0, 0.5])
+    plt.legend(loc=(0.025, 0.65))
simplifyAxes(ax)
-    plt.ylim([0, 16])
plt.xlabel("GTP concentration (\u00B5M)")
-    plt.ylabel("Time constant (s)")
-    plt.savefig(f"figures/rnap_his_durations.pgf")
+    plt.ylabel("Rate (s\\textsuperscript{--1})")
+    plt.savefig(f"figures/rnap_pause_escape_rates.pgf")
plt.clf()

print("\n\nTermination pauses")

@@ 768,13 768,12 @@ def pauseDurations(data):
pts = np.array([])
for hp in (True, False):
pts = np.concatenate((pts, tdwells[(f, gtp, hp)]))
-        ptau, psigma = tau(pts)
-        y.append(ptau)
-        yerror.append(np.abs(np.array(psigma) - ptau))
+        pk, psigmak = k(pts)
+        y.append(pk)
+        yerror.append(psigmak)
print(
-            f"\t{f}\t{gtp}\t{len(pts)}\t${ptau:2.2f}^{{+{psigma[1]-ptau:2.2f}}}_{{{psigma[0]-ptau:2.2f}}}$"
+            f"\t{f}\t{gtp}\t{len(pts)}\t\SI{{{pk:2.3f} \pm {psigmak:2.3f}}}{{\per\second}}"
)
-    yerror = np.array(yerror).T
template = "terminating"
plt.bar(
x,

@@ 786,20 785,23 @@ def pauseDurations(data):
ecolor=color[template],
)
plt.xticks(x, ["25", "50", "200/250", "1000", "250", "1000"])
-    forcebar = np.max(np.array(y) + np.array(yerror)) + 1
+    forcebar = 0.9
plt.plot([0, 3], [forcebar, forcebar], color="k")
plt.annotate(
-        "10 pN", xy=(1.5, forcebar + 0.3), xycoords="data", horizontalalignment="center"
+        "10 pN",
+        xy=(1.5, forcebar + 0.05),
+        xycoords="data",
+        horizontalalignment="center",
)
plt.plot([4.5, 5.5], [forcebar, forcebar], color="k")
plt.annotate(
-        "5 pN", xy=(5, forcebar + 0.3), xycoords="data", horizontalalignment="center"
+        "5 pN", xy=(5, forcebar + 0.05), xycoords="data", horizontalalignment="center"
)
-    plt.axis([np.min(x) - 1, np.max(x) + 1, 0, np.ceil(forcebar + 0.5)])
+    plt.axis([np.min(x) - 1, np.max(x) + 1, 0, 1])
simplifyAxes(ax)
plt.xlabel("GTP concentration (\u00B5M)")
-    plt.ylabel("Time constant (s)")
-    plt.savefig(f"figures/rnap_termination_durations.pgf")
+    plt.ylabel("Rate (s\\textsuperscript{--1})")
+    plt.savefig(f"figures/rnap_termination_escape_rates.pgf")
plt.clf()

print("Done")