Partial Differential Equations and Gaussian Process with GPy

presented at the EBI BioPreDyn Course 'The Systems Biology Modelling Cycle'

Mu Niu, Neil Lawrence, 12th May 20014, University of Sheffield

The Spatio-Temporal Model

In this notebook we consider the latent force model paradigm (Alvarez et al, 2013, Alvarez et al, 2011, Alvarez et al, 2009) to drive spatio-temporal differential equation with a Gaussian process. Latent force models are differential equations whose initial conditions or driving forces are given by a stochastic process. Linear latent force models are linear (partial or ordinary) differential equations. If a linear latent force model is driven by a Gaussian process latent force, this describes a joint Gaussian process distribution across all the variables of interest. The Gaussian process covariance function encodes the relationships between the variables, as proscribed by the differential equation, through the covariance function.

This direction of research is part of our ideas as to how to merge mechanistic and statistical models of data. It also maps onto our ideas about 'Gaussian processes over everything'. The covariance function interelates the protein and mRNA concentrations in the same model.

Differential Equation Model

A model of post-transcriptional processing is formulated to describe the spatio-temporal Drosophila protein expression data (Becker et al, 2013, Alvarez et al, 2011). Protein production is considered to be linearly dependent on the concentration of mRNA at an earlier time point. The model also allows for diffusion of protein between nuclei and linear protein decay. These processes are dependent on the diffusion parameter and the degradation rate of protein respectively.

\begin{equation} a \frac{\partial ^2 y_{x,t}}{\partial x^2} + b \frac{\partial y_{x,t}}{\partial t} + c y_{x,t}= f_{x,t} \end{equation}

The coefficients $a$, $b$ and $c$ are unknown. In this study, we use Gaussian process with an exponentiated quadratic kernel as a prior over $y_{x,t}$ (protein). The kernel of $f_{x,t}$ (mRNA) is derived by applying the partial differential operator on the spatial-temporal kernel of protein. The multi-output Gaussian process are developed by combining the covariance matrix of mRNA and protein and their cross covariance.


In [2]:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import numpy as np
import pylab as pb
import GPy
import pandas
from pandas import read_csv

The spatio-temporal multi-output partial differential equation covariance functions have been developed with the kernel name GPy.kern.ODE_st in GPy. The inputs are one dimension spatial data, one dimension temporal data and one dimension index which is used to indicate $f$ and $y$.


In [3]:
data = GPy.util.datasets.drosophila_knirps()

The next thing to do is to compose the data ready for presentation to GPy. Here we need to use the time field as the input and a concatanation of the expression levels as the output. We need to provide a corresponding index for to each input to describe what output is being represented.

Now we set up the covariance function with the relevant parameters.


In [4]:
kern = GPy.kern.ODE_st(input_dim=3,
                       a=1., b=1., c=1.,
                       variance_Yx=1., variance_Yt=1.,
                       lengthscale_Yx=15.,
                       lengthscale_Yt=15.)

With the data correctly presented and the covariance function defined, we are ready to proceed with the Gaussian process regression.


In [5]:
m = GPy.models.GPRegression(data['X'],data['Y'],kern)

Initial Fit

The initial value of $a$, $b$ and $c$ are 1. For these choices of covariance function parameters, we can plot the random field of $f$ and $y$ separately.


In [8]:
leng = data['X'].shape[0]
m.plot(fixed_inputs=[(2,0)], which_data_rows = slice(0,leng*2/2))
m.plot(fixed_inputs=[(2,1)], which_data_rows = slice(leng*2/2,leng*2))


Out[8]:
{'contour': <matplotlib.contour.QuadContourSet instance at 0x10f9a32d8>,
 'dataplot': <matplotlib.collections.PathCollection at 0x10f9b97d0>}

Now we optimize the model, this will take a few minutes.


In [16]:
m.optimize(messages=True)


 I      F              Scale          |g|        
0003   7.614997e+04   2.500000e-01   2.504914e+09 
0008   1.133084e+04   7.812500e-03   8.476310e+07 
0016   3.600478e+03   3.051758e-05   6.694209e+04 
0022   2.830839e+03   4.768372e-07   5.181429e+02 
0031   2.768527e+03   9.313226e-10   7.879161e+01 
0053   2.747934e+03   1.000000e-15   7.722679e+00 
0069   2.746164e+03   1.000000e-15   5.889059e-02 
0082   2.746153e+03   1.000000e-15   7.165007e-03 
0089   2.746153e+03   1.000000e-15   1.479437e-04 
0089   2.746153e+03   1.000000e-15   1.479437e-04 
converged - relative reduction in objective

After optimization, the estimated value of $a$, $b$ and $c$ can be printed.


In [17]:
print m


  GP_regression.           |      Value       |  Constraint  |  Prior  |  Tied to
  ode_st.a                 |  0.438768542606  |     +ve      |         |         
  ode_st.b                 |   10.0747613738  |     +ve      |         |         
  ode_st.c                 |  0.620385966622  |     +ve      |         |         
  ode_st.variance_Yt       |   32.8716774332  |     +ve      |         |         
  ode_st.variance_Yx       |   32.8716774332  |     +ve      |         |         
  ode_st.lengthscale_Yt    |   18.3997301624  |     +ve      |         |         
  ode_st.lengthscale_Yx    |   14.3560437898  |     +ve      |         |         
  Gaussian_noise.variance  |   3.26998881271  |     +ve      |         |         

The plot of the random fields are plotted below.


In [18]:
m.plot(fixed_inputs=[(2,0)], which_data_rows = slice(0,leng*2/2))
pb.savefig("gene.pdf")
m.plot(fixed_inputs=[(2,1)], which_data_rows = slice(leng*2/2,leng*2))
pb.savefig("protein.pdf")


In Kolja Becker's thesis he showed the value of $\alpha$, D and $\lambda$. Should the Gaussian process estimation of $a$, $b$ and $c$ be the same as the value in the thesis? The value of $\lambda$ is equal to 1/$b$.

work funded by the BioPreDyn project, it is a collaboration with Nicolas Durrande, Johannes Jaeger.


In [ ]: