Q-Matrix library

A collection of functions for Q matrix manipulations.

Notes

DC_PyPs project are pure Python implementations of Q-Matrix formalisms for ion channel research. To learn more about kinetic analysis of ion channels see the references below.

References

CH82: Colquhoun D, Hawkes AG (1982) On the stochastic properties of bursts of single ion channel openings and of clusters of bursts. Phil Trans R Soc Lond B 300, 1-59.

HJC92: Hawkes AG, Jalali A, Colquhoun D (1992) Asymptotic distributions of apparent open times and shut times in a single channel record allowing for the omission of brief events. Phil Trans R Soc Lond B 337, 383-404.

CH95a: Colquhoun D, Hawkes AG (1995a) The principles of the stochastic interpretation of ion channel mechanisms. In: Single-channel recording. 2nd ed. (Eds: Sakmann B, Neher E) Plenum Press, New York, pp. 397-482.

CH95b: Colquhoun D, Hawkes AG (1995b) A Q-Matrix Cookbook. In: Single-channel recording. 2nd ed. (Eds: Sakmann B, Neher E) Plenum Press, New York, pp. 589-633.

CHS96: Colquhoun D, Hawkes AG, Srodzinski K (1996) Joint distributions of apparent open and shut times of single-ion channels and maximum likelihood fitting of mechanisms. Phil Trans R Soc Lond A 354, 2555-2590.

qmatlib.H(s, tres, QAA, QFF, QAF, QFA, kF)

Evaluate H(s) funtion (Eq. 54, HJC92). HAA(s) = QAA + QAF * (s*I - QFF) ^(-1) * (I - exp(-(s*I - QFF) * tau)) * QFA To evaluate HFF(s) exhange A by F and F by A in function call.

Parameters :

s : float

Laplace transform argument.

tres : float

Time resolution (dead time).

QAA : array_like, shape (kA, kA)

QFF : array_like, shape (kF, kF)

QAF : array_like, shape (kA, kF)

QFA : array_like, shape (kF, kA)

QAA, QFF, QAF, QFA - submatrices of Q.

kF : int

A number of shut states in kinetic scheme.

Returns :

H : ndarray, shape (kA, kA)

qmatlib.W(s, tres, QAA, QFF, QAF, QFA, kA, kF)

Evaluate W(s) function (Eq. 52, HJC92). WAA(s) = s * IA - HAA(s) To evaluate WFF(s) exhange A by F and F by A in function call.

Parameters :

s : float

Laplace transform argument.

tres : float

Time resolution (dead time).

QAA : array_like, shape (kA, kA)

QFF : array_like, shape (kF, kF)

QAF : array_like, shape (kA, kF)

QFA : array_like, shape (kF, kA)

QAA, QFF, QAF, QFA - submatrices of Q.

kA : int

A number of open states in kinetic scheme.

kF : int

A number of shut states in kinetic scheme.

Returns :

W : ndarray, shape (k2, k2)

qmatlib.XAF(tres, roots, QAA, QFF, QAF, QFA, expQFF)

Calculate coefficients for asymptotic eGAF(t) (Eq. 3.2 HJC90): AR(tres) * QAF * exp(QFF * tres)

Parameters :

tres : float

Time resolution (dead time).

roots : array_like, shape (1, kA)

Roots of the asymptotic open time pdf.

QAA, QFF, QAF, QFA : array_like

Submatrices of Q.

Returns :

X : array_like, shape(kA, kA, kF)

qmatlib.Zxx(Q, kopen, QFF, QAF, QFA, expQFF, open)

Calculate Z constants for the exact open time pdf (Eq. 3.22, HJC90). Exchange A and F for shut time pdf.

Parameters :

t : float

Time.

Q : array_like, shape (k, k)

kopen : int

Number of open states.

QFF, QAF, QFA : array_like

Submatrices of Q.

open : bool

True for open time pdf, False for shut time pdf.

Returns :

eigen : array_like, shape (k,)

Eigenvalues of -Q matrix.

Z00, Z10, Z11 : array_like, shape (k, kA, kF)

Z constants for the exact open time pdf.

qmatlib.dARSdS(tres, QAA, QFF, GAF, GFA, expQFF, kA, kF)

Evaluate the derivative with respect to s of the Laplace transform of the survival function (Eq. 3.6, CHS96) for open states:

\left[ -\frac{\text{d}}{\text{d}s} {^\cl{A}\!\bs{R}^*(s)} \right]_{s=0}

For same evaluation for shut states exhange A by F and F by A in function call.

SFF = I - exp(QFF * tres) First evaluate [dVA(s) / ds] * s = 0. dVAds = -inv(QAA) * GAF * SFF * GFA - GAF * SFF * inv(QFF) * GFA + + tres * GAF * expQFF * GFA

Then: DARS = inv(VA) * QAA^(-2) - inv(VA) * dVAds * inv(VA) * inv(QAA) = = inv(VA) * [inv(QAA) - dVAds * inv(VA)] * inv(QAA) where VA = I - GAF * SFF * GFA

Parameters :

tres : float

Time resolution (dead time).

QAA : array_like, shape (kA, kA)

QAF : array_like, shape (kA, kF)

QFF : array_like, shape (kF, kF)

QFA : array_like, shape (kF, kA)

Q11, Q12, Q22, Q21 - submatrices of Q.

GAF : array_like, shape (kA, kF)

GFA : array_like, shape (kF, kA)

GAF, GFA - G matrices.

expQFF : array_like, shape(kF, kF)

expQAA : array_like, shape(kA, kA)

expQFF, expQAA - exponentials of submatrices QFF and QAA.

kA : int

A number of open states in kinetic scheme.

kF : int

A number of shut states in kinetic scheme.

Returns :

DARS : array_like, shape (kA, kA)

qmatlib.dW(s, tres, QAF, QFF, QFA, kA, kF)

Evaluate the derivative with respect to s of the matrix W(s) at the root s (Eq. 56, HJC92) for open states. For same evaluation for shut states exhange A by F and F by A in function call. W’(s) = I + QAF * [SFF(s) * (s*I - QFF)^(-1) - tau * (I - SFF(s))] * eGFA(s) where SFF(s) = I - exp(-(s*I - QFF) * tau) (Eq. 17, HJC92) and eGFA(s) = (s*I - QFF)^(-1) * QFA (Eq. 4, HJC92).

Parameters :

s : float

Laplace transform argument.

tres : float

Time resolution (dead time).

QAF : array_like, shape (kA, kF)

QFF : array_like, shape (kF, kF)

QFA : array_like, shape (kF, kA)

QAF, QFF, QFA - submatrices of Q.

kA : int

A number of open states in kinetic scheme.

kF : int

A number of shut states in kinetic scheme.

Returns :

dW : ndarray, shape (kF, kF)

qmatlib.eGAF(t, tres, roots, XAF, eigvals, Z00, Z10, Z11)

Calculate transition density eGAF(t) for exact (Eq. 3.2, HJC90) and asymptotic (Eq. 3.24, HJC90) distribution.

Parameters :

t : float

Time interval.

tres : float

Time resolution (dead time).

roots : array_like, shape (1, kA)

Roots of the asymptotic pdf.

XAF : array_like, shape(kA, kA, kF)

eigvals : array_like, shape (1, k)

Eigenvalues of -Q matrix.

Z00, Z10, Z11 : array_like, shape (k, kA, kF)

Z constants for the exact open time pdf.

Returns :

eGAFt : array_like, shape(kA, kA, kF)

qmatlib.eGs(GAF, GFA, kA, kF, expQFF)

Calculate eGAF, probabilities from transitions from apparently open to shut states regardles of when the transition occurs. Thease are Laplace transform of eGAF(t) when s=0. Used to calculat initial HJC vectors (HJC92). eGAF*(s=0) = (I - GAF * (I - expQFF) * GFA)^-1 * GAF * expQFF To caculate eGFA exhange A by F and F by A in function call.

Parameters :

GAF : array_like, shape (kA, kF)

GFA : array_like, shape (kF, kA)

kA : int

A number of open states in kinetic scheme.

kF : int

A number of shut states in kinetic scheme.

Returns :

eGAF : array_like, shape (kA, kF)

qmatlib.eigs(Q)

Calculate eigenvalues and spectral matrices of a matrix Q.

Parameters :

Q : array_like, shape (k, k)

Returns :

eigvals : ndarray, shape (k,)

Eigenvalues of M.

A : ndarray, shape (k, k, k)

Spectral matrices of Q.

qmatlib.expQt(M * t)
Parameters :

M : array_like, shape (k, k)

t : float

Time.

Returns :

expM : ndarray, shape (k, k)

qmatlib.f0(u, eigvals, Z00)

A component of exact time pdf (Eq. 22, HJC92).

Parameters :

u : float

u = t - tres

eigvals : array_like, shape (k,)

Eigenvalues of -Q matrix.

Z00 : list of array_likes

Constants for the exact open/shut time pdf. Z00 for likelihood calculation or gama00 for time distributions.

Returns :

f : ndarray

qmatlib.f1(u, eigvals, Z10, Z11)

A component of exact time pdf (Eq. 22, HJC92).

Parameters :

u : float

u = t - tres

eigvals : array_like, shape (k,)

Eigenvalues of -Q matrix.

Z10, Z11 (or gama10, gama11) : list of array_likes

Constants for the exact open/shut time pdf. Z10, Z11 for likelihood calculation or gama10, gama11 for time distributions.

Returns :

f : ndarray

qmatlib.iGs(Q, kA, kB)

Calculate GBA and GAB matrices (Eq. 1.25, CH82). Calculate also GFA and GAF if kF is given instead of kB.

\bs{G}_\cl{BA} &= -\bs{Q}_\cl{BB}^{-1} \bs{Q}_\cl{BA} \\
\bs{G}_\cl{AB} &= -\bs{Q}_\cl{AA}^{-1} \bs{Q}_\cl{AB}

Parameters :

Q : array_like, shape (k, k)

kA : int

A number of open states in kinetic scheme.

kB : int

A number of short lived shut states in kinetic scheme.

Returns :

GAB : ndarray, shape (kA, kB)

GBA : ndarray, shape (kB, kA)

qmatlib.phiA(mec)

Calculate initial vector for openings.

Parameters :

mec : dcpyps.Mechanism

The mechanism to be analysed.

Returns :

phi : ndarray, shape (kA)

qmatlib.phiF(mec)

Calculate inital vector for shuttings.

Parameters :

mec : dcpyps.Mechanism

The mechanism to be analysed.

Returns :

phi : ndarray, shape (kF)

qmatlib.phiHJC(eGAF, eGFA, kA)

Calculate initial HJC vector for openings by solving phi*(I-eGAF*eGFA)=0 (Eq. 10, HJC92) For shuttings exhange A by F and F by A in function call.

Parameters :

eGAF : array_like, shape (kA, kF)

eGFA : array_like, shape (kF, kA)

kA : int

A number of open states in kinetic scheme.

kF : int

A number of shut states in kinetic scheme.

Returns :

phi : array_like, shape (kA)

qmatlib.phiSub(Q, k1, k2)

Calculate initial vector for any subset.

Parameters :

mec : dcpyps.Mechanism

The mechanism to be analysed.

Returns :

phi : ndarray, shape (kA)

qmatlib.pinf(Q)

Calculate ecquilibrium occupancies by adding a column of ones to Q matrix. Pinf = uT * invert((S * transpos(S))).

Parameters :Q : array_like, shape (k, k)
Returns :pinf : ndarray, shape (k1)

Table Of Contents

Previous topic

Open probability and dose response curves

Next topic

Calculating responses to concentration jumps

This Page