Executed: Mon Mar 27 11:39:14 2017
Duration: 3 seconds.
This notebook estimates the gamma factor from a set of 5 μs-ALEX smFRET measurements.
According to Lee 2005 (PDF, SI PDF), we estimate the $\gamma$-factor from Proximity Ratio (PR) and S values (with background, leakage and direct excitation correction) for a set of 5 μs-ALEX measurements.
The PR and S values are computed by the notebook
which is executed by 8-spots paper analysis.
From Lee 2005 (equation 20), the following linear relation holds:
$$\frac{1}{S} = \Omega + \Sigma \cdot E_{PR}$$Once $\Omega$ and $\Sigma$ are fitted, we can compute the $\gamma$-factor as (equation 22):
$$\gamma = (\Omega-1)/(\Omega + \Sigma-1)$$$$\beta = \Omega + \Sigma - 1$$The definition of $\beta$ based on physical parameters is:
$$ \beta = \frac{I_{A_{ex}}\sigma_{A_{ex}}^A}{I_{D_{ex}}\sigma_{D_{ex}}^D}$$Note that, calling $S_\gamma$ the corrected S, the following relation holds:
$$ S_\gamma = (1 + \beta)^{-1}$$
In [1]:
from __future__ import division
import numpy as np
import pandas as pd
import lmfit
from scipy.stats import linregress
This notebook read data from the file:
In [2]:
data_file = 'results/usALEX-5samples-PR-leakage-dir-ex-all-ph.csv'
In [3]:
data = pd.read_csv(data_file).set_index('sample')
data
Out[3]:
In [4]:
data[['E_gauss_w', 'E_kde_w', 'S_gauss']]
Out[4]:
In [5]:
E_ref, S_ref = data.E_gauss_w, data.S_gauss
In [6]:
res = linregress(E_ref, 1/S_ref)
slope, intercept, r_val, p_val, stderr = res
For more info see scipy.stats.linearregress
.
In [7]:
Sigma = slope
Sigma
Out[7]:
In [8]:
Omega = intercept
Omega
Out[8]:
In [9]:
r_val
Out[9]:
Coefficient of determination $R^2$:
In [10]:
r_val**2
Out[10]:
P-value (to test the null hypothesis that the slope is zero):
In [11]:
p_val
Out[11]:
Gamma computed from the previous fitted values:
In [12]:
gamma = (Omega - 1)/(Omega + Sigma - 1)
'%.6f' % gamma
Out[12]:
In [13]:
with open('results/usALEX - gamma factor - all-ph.csv', 'w') as f:
f.write('%.6f' % gamma)
In [14]:
beta = Omega + Sigma - 1
'%.6f' % beta
Out[14]:
In [15]:
with open('results/usALEX - beta factor - all-ph.csv', 'w') as f:
f.write('%.6f' % beta)
In [16]:
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format='retina' # for hi-dpi displays
sns.set_style('whitegrid')
In [17]:
x = np.arange(0, 1, 0.01)
plt.plot(E_ref, 1/S_ref, 's', label='dsDNA samples')
plt.plot(x, intercept + slope*x, 'k', label='fit (slope = %.2f)' % slope)
plt.legend(loc=4)
plt.ylim(1, 2)
plt.xlabel('PR')
plt.ylabel('1/SR');