Skip to content

Commit

Permalink
Update version, docs. Fix whitespace in Figure5
Browse files Browse the repository at this point in the history
  • Loading branch information
rfd1 committed Feb 28, 2023
1 parent 30070ea commit 3613330
Show file tree
Hide file tree
Showing 24 changed files with 251 additions and 141 deletions.
5 changes: 3 additions & 2 deletions .idea/code.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 19 additions & 16 deletions REPRODUCEME.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and store as an instance of `src.get_data.RawData`.

The data for
each replicate plate
possessing single-stranded DNA with $D_k=1\times10^{-6}$ mol/L is
possessing single-stranded DNA with $B_d=22\times10^{-6}$ mol nucleobases/L is
input into the following structures

>>> kwargs = dict(t="SS", B_d=22e-6, N=22)
Expand All @@ -22,7 +22,7 @@ input into the following structures

The data for
each replicate plate
possessing single-stranded DNA with $D_k=2\times10^{-6}$ mol/L is
possessing single-stranded DNA with $B_d=44\times10^{-6}$ mol nucleobases/L is
input into the following structures

>>> kwargs = dict(t="SS", B_d=44e-6, N=22)
Expand All @@ -31,7 +31,7 @@ input into the following structures

The data for
each replicate plate
possessing double-stranded DNA with $D_k=1\times10^{-6}$ mol/L is
possessing double-stranded DNA with $B_d=22\times10^{-6}$ mol nucleobases/L is
input into the following structures

>>> kwargs = dict(t="DS", B_d=22e-6, N=22)
Expand All @@ -40,7 +40,7 @@ input into the following structures

The data for
each replicate plate
possessing double-stranded DNA with $D_k=2\times10^{-6}$ mol/L is
possessing double-stranded DNA with $B_d=44\times10^{-6}$ mol nucleobases/L is
input into the following structures

>>> kwargs = dict(t="DS", B_d=44e-6, N=22)
Expand Down Expand Up @@ -109,6 +109,7 @@ The value for $F_\mathrm{min}$ is
>>> F_min
231432.0

(see Section S1.2 in the Supporting Material),
while the average fluorescence for low dye concentrations is

>>> F_min_avg
Expand Down Expand Up @@ -154,15 +155,15 @@ each combination via
... tuple(F_hats),
... (SS_1.T, SS_2.T, DS_1.T, DS_2.T),
... "figure4.pdf",
... sname=r"$\widehat{\mathbf{F}}_{j,i}^\mathrm{LS}$")
... sname=r"\widehat{\mathbf{F}}_{j,i}^\mathrm{LS}")
...

This is Figure 4 of the main text, which can be found [here](out/figure4.pdf).

Subsequently, Equation (18) is solved
using `src.noise_removal.predictor_corrector`
and $V(\mathbf{M})$ and $V(\mathbf{C})$
are calulated
are calulated (see Section S1.3 in the SM)


>>> from src.noise_removal import predictor_corrector
Expand Down Expand Up @@ -200,7 +201,7 @@ The results are plotted via Figure 5
... (SS_1.Fhat_tls, SS_2.Fhat_tls, DS_1.Fhat_tls, DS_2.Fhat_tls),
... (SS_1.T, SS_2.T, DS_1.T, DS_2.T),
... "figure5.pdf",
... sname=r"$\widehat{\mathbf{F}}_{j,i}^\mathrm{TLS}$")
... sname=r"\widehat{\mathbf{F}}_{j,i}^\mathrm{TLS}")
...

which can be found [here](out/figure5.pdf),
Expand Down Expand Up @@ -251,7 +252,6 @@ we can readily plot the Figure 8 as
...

which looks like [this](out/figure8.pdf).

The association constant is calculated as

>>> K_a = DS.get_K()/2/C_REF/DS.N*1e-6
Expand All @@ -273,22 +273,25 @@ which looks like [this](out/figure9.pdf).

## Supplementary Figures

Figure S1 and S2 are made via
Figures [S1](out/figureS1.pdf), [S2](out/figureS2.pdf), [S3](out/figureS3.pdf),
[S4](out/figureS4.pdf), and [S5](out/figureS5.pdf) are made via

>>> from src.plot_raw_data import make_figure_S1, make_figure_S3
>>> from src.plot_raw_data import make_figure_S1
>>> make_figure_S1()

>>> from src.plot_params import plot_figure_S2
>>> plot_figure_S2(SS_1, SS_2, DS_1, DS_2)

>>> from src.plot_raw_data import make_figure_S3
>>> make_figure_S3()
Maximum change from 6/15 to 6/16: 32841
Minimum change from 6/15 to 6/16: -4525
Average change from 6/15 to 6/16: 4085


Figure S2, S4, and S5 are made via

>>> from src.plot_params import plot_figure_S2, plot_figure_S4, \
... plot_figure_S5
>>> plot_figure_S2(SS_1, SS_2, DS_1, DS_2)
>>> from src.plot_params import plot_figure_S4
>>> plot_figure_S4(SS, DS)

>>> from src.plot_params import plot_figure_S5
>>> from src.parameter_extraction import calculate_relative_brightness, \
... calculate_relative_brightness_err
>>> rb = calculate_relative_brightness(SS.get_f(), DS.get_f())
Expand Down
Binary file modified doc/manual.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Robert F. DeJaco'

# The short X.Y version
version = 'v2.1.0'
version = 'v2.2.0'
# The full version, including alpha/beta/rc tags
release = 'v2.1.0'
release = 'v2.2.0'


# -- General configuration ---------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions doc/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Get Data
.. automodule:: src.get_data
:members:

Noise Removal
-------------
Quantifying Noise and Linearity
-------------------------------

.. automodule:: src.noise_removal
:members:
Expand All @@ -35,8 +35,8 @@ Raw Data
.. automodule:: src.plot_raw_data
:members:

Noise Removal
.............
Quantifying Noise and Linearity
................................

.. automodule:: src.plot_noise_removal
:members:
Expand Down
Binary file modified out/figure2.pdf
Binary file not shown.
Binary file modified out/figure4.pdf
Binary file not shown.
Binary file modified out/figure5.pdf
Binary file not shown.
Binary file modified out/figure6.pdf
Binary file not shown.
Binary file modified out/figure7.pdf
Binary file not shown.
Binary file modified out/figure8.pdf
Binary file not shown.
Binary file modified out/figure9.pdf
Binary file not shown.
Binary file modified out/figureS1.pdf
Binary file not shown.
Binary file modified out/figureS2.pdf
Binary file not shown.
Binary file modified out/figureS3.pdf
Binary file not shown.
Binary file modified out/figureS4.pdf
Binary file not shown.
Binary file modified out/figureS5.pdf
Binary file not shown.
6 changes: 3 additions & 3 deletions src/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def excel_to_data(f_name: str, channel="GREEN"):
"""
Convert "Raw Data" sheet of excel file to pandas dataframe.
Uses Equation (12) of manuscript
Uses Equation (9) of manuscript
to calculate temperature associated with each cycle.
Parameters
Expand Down Expand Up @@ -84,9 +84,9 @@ class RawData:
Attributes
----------
F : np.ndarray
Fluorescence data, :math:`F_d^{t\\ell}` (see Equation 14 of main text)
Fluorescence data, :math:`F_d^{t\\ell}` (see Equation 11 of main text)
C : np.ndarray
Dye concentrations, :math:`C` (see Equation 13 of main text)
Dye concentrations, :math:`C` (see Equation 10 of main text)
B : float
DNA concentration, :math:`B_d` in mol/L
t : str
Expand Down
6 changes: 3 additions & 3 deletions src/noise_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def compute_M_LS(F, C):
Returns
-------
np.array
:math:`\\mathbf{M}^\\mathrm{LS}`, see Equation (21)
:math:`\\mathbf{M}^\\mathrm{LS}`, see Equation (17)
"""
return F@C/np.inner(C, C)
Expand Down Expand Up @@ -54,7 +54,7 @@ def compute_M_plus(F, c_plus):


def predictor_corrector(F, C, rho_squared, maxiter=100000, print_iter=True):
"""Solve Equation (22) with predictor--corrector algorithm
"""Solve Equation (18) with predictor--corrector algorithm
Parameters
----------
Expand All @@ -63,7 +63,7 @@ def predictor_corrector(F, C, rho_squared, maxiter=100000, print_iter=True):
C : np.ndarray
Dye concentration data :math:`\\mathbf{C}`
rho_squared : float
Weighting factor for concentrations, :math:`\\rho^2` in Equation (22a)
Weighting factor for concentrations, :math:`\\rho^2` in Equation (18a)
maxiter : int, optional
maximum iterations allowed, by default 100000
print_iter : bool, optional
Expand Down
97 changes: 17 additions & 80 deletions src/parameter_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def calculate_relative_brightness(f_SS, f_DS):
"""Calculate relative brightness, Equation (28).
"""Calculate relative brightness, Equation (24).
Parameters
----------
Expand All @@ -24,7 +24,7 @@ def calculate_relative_brightness(f_SS, f_DS):


def calculate_relative_brightness_err(SS_M1, SS_M2, DS_M1, DS_M2, SS_V_M1, SS_V_M2, DS_V_M1, DS_V_M2) -> np.array:
"""Estimate error in relative brightness, Equation (28).
"""Estimate error in relative brightness, Equation (24).
Parameters
----------
Expand Down Expand Up @@ -145,81 +145,8 @@ def __init__(self, cls1: CombinedData, cls2: CombinedData):
self.N = cls1.N
assert self.N == cls2.N, "Cannot combine different DNA lengths"

def get_phi_1(self) -> np.array:
"""Get :math:`\\varphi_{1}`, vectorized version of Equation (S6a)
Returns
-------
np.array
"""
return 2*self.r - 1

def get_std_phi_1(self) -> np.array:
"""Get estimate of standard deviation in :math:`\\varphi_{1}`
Returns
-------
np.array
.. math::
\\frac{2}{\\mathbf{M}_{2j}}\\sqrt{V(\\mathbf{M}_{1j}) + r_j^2V(\\mathbf{M}_{2j})}
"""
return 2*np.sqrt(
self.V_M1 + self.r*self.r*self.V_M2
)/self.M2

def get_phi_2(self):
"""Get :math:`\\varphi_{2}`, vectorized version of Equation (S6b)
Returns
-------
np.array
"""
return 2 - 1/self.r

def get_std_phi_2(self):
"""Get estimate of standard deviation in :math:`\\varphi_{2}`
Returns
-------
np.array
.. math::
\\frac{1}{\\mathbf{M}_{1j}}\\sqrt{V(\\mathbf{M}_{2j}) + r_j^{-2}V(\\mathbf{M}_{1j})}
"""
return np.sqrt(
self.V_M2 + self.V_M1/self.r/self.r
)/self.M1

def get_theta_b_all_1(self, n):
return n*self.C1[-1]*(2*self.r - 1)/self.N

def get_psi_j1(self, j: int):
return self.C1*(2*self.r[j] - 1)

def get_std_psi_j1(self, j: int):
return np.sqrt(
(2*self.r[j] - 1)*(2*self.r[j] - 1)*self.V_C1
+ 4*self.C1*self.C1/self.M2[j]/self.M2[j]*self.V_M1[j]
+ 4*self.C1*self.C1*self.r[j]*self.r[j]/self.M2[j]/self.M2[j]*self.V_M2[j]
)

def get_psi_j2(self, j: int):
return self.C2*(1 - 1/2/self.r[j])

def get_std_psi_j2(self, j: int):
return np.sqrt(
(1 - 1/2/self.r[j])*(1 - 1/2/self.r[j])*self.V_C2
+ (self.C2*self.C2/4/self.M1[j]/self.M1[j])*self.V_M2[j]
+ self.C2*self.C2/self.r[j]/self.r[j]/self.M1[j]/self.M1[j]/4*self.V_M1[j]
)

def get_K(self) -> np.array:
"""Get :math:`\\mathbf{K}` from vectorized version of Equation (24)
"""Get :math:`\\mathbf{K}` from vectorized version of Equation (21)
Returns
-------
Expand Down Expand Up @@ -251,7 +178,7 @@ def get_K_std(self) -> np.array:
return np.sqrt((DM*DM*(4*self.V_M1+ 2*self.V_M2) + DH*DH*(self.V_M1+ self.V_M2))/8/DM/DM/DM/DM)

def get_f(self) -> np.array:
"""Get :math:`\\mathbf{f}` from vectorized version of Equation (27)
"""Get :math:`\\mathbf{f}` from vectorized version of Equation (23)
Returns
-------
Expand Down Expand Up @@ -301,7 +228,7 @@ def get_f_std(self) -> np.array:
)

def get_dg(self) -> np.array:
"""Get free energy of dye binding, :math:`\\Delta g`, vectorized version of Equation (29).
"""Get free energy of dye binding, :math:`\\Delta g`, vectorized version of Equation (25).
Returns
-------
Expand All @@ -312,7 +239,7 @@ def get_dg(self) -> np.array:
return -R_kJ_molK * self.T * np.log(K/C_REF/self.N)

def get_dh(self) -> np.array:
"""Get differential enthalpy of binding, :math:`\\Delta h` as the vectorized version of Equation (30).
"""Get differential enthalpy of binding, :math:`\\Delta h` as the vectorized version of Equation (26).
Returns
-------
Expand Down Expand Up @@ -368,4 +295,14 @@ def get_dh_std(self) -> np.array:
+ dhj__M1jm1*dhj__M1jm1*self.V_M1[:-2]
+ dhj__M2jm1*dhj__M2jm1*self.V_M2[:-2]
)


def get_theta_b_all_1(self, n):
"""Returns :math:`\\theta_{b,j,1}` in Equation (S6a) pointwise in :math:`j`
The index :math:`b` is the total number of wells.
Returns
-------
np.array
"""
return n * self.C1[-1] * (2 * self.r - 1) / self.N
Loading

0 comments on commit 3613330

Please sign in to comment.