aboutsummaryrefslogblamecommitdiff
path: root/docs/reference/mkinpredict.html
blob: 730792c1a2aac876543cc11ce870e3e52cf8984a (plain) (tree)





























































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                    
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html>
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>mkinpredict. mkin</title>

<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script>

<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cerulean/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<!-- Font Awesome icons -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">


<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>

<!-- mathjax -->
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
  </head>

  <body>
    <div class="container">
      <header>
      
<div class="navbar navbar-default  navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="../index.html">mkin</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">Home</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/jranke/mkin">
    <span class="fa fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->
      
      </header>

      <div class="page-header">
  <h1>
</h1>
</div>

<div class="row">
  <div class="col-md-9">
    
    <p>This function produces a time series for all the observed variables in a
  kinetic model as specified by <code>mkinmod</code>, using a specific set of
  kinetic parameters and initial values for the state variables.</p>
    

    <pre><span class='fu'>mkinpredict</span>(<span class='no'>mkinmod</span>, <span class='no'>odeparms</span>, <span class='no'>odeini</span>, <span class='no'>outtimes</span>, <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>,
              <span class='kw'>use_compiled</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, <span class='kw'>method.ode</span> <span class='kw'>=</span> <span class='st'>"lsoda"</span>, <span class='kw'>atol</span> <span class='kw'>=</span> <span class='fl'>1e-08</span>, <span class='kw'>rtol</span> <span class='kw'>=</span> <span class='fl'>1e-10</span>,
        <span class='kw'>map_output</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='no'>...</span>)</pre>
    
    <h2>Arguments</h2>
    <dl class="dl-horizontal">
      <dt>mkinmod</dt>
      <dd>
    A kinetic model as produced by <code>mkinmod</code>.
  </dd>
      <dt>odeparms</dt>
      <dd>
    A numeric vector specifying the parameters used in the kinetic model, which
    is generally defined as a set of ordinary differential equations.
  </dd>
      <dt>odeini</dt>
      <dd>
    A numeric vectory containing the initial values of the state variables of
    the model. Note that the state variables can differ from the observed
    variables, for example in the case of the SFORB model.
  </dd>
      <dt>outtimes</dt>
      <dd>
    A numeric vector specifying the time points for which model predictions
    should be generated.
  </dd>
      <dt>solution_type</dt>
      <dd>
    The method that should be used for producing the predictions. This should
    generally be &quot;analytical&quot; if there is only one observed variable, and
    usually &quot;deSolve&quot; in the case of several observed variables. The third
    possibility &quot;eigen&quot; is faster but not applicable to some models e.g.
    using FOMC for the parent compound.
  </dd>
      <dt>method.ode</dt>
      <dd>
    The solution method passed via <code>mkinpredict</code> to
    <code>ode</code> in case the solution type is &quot;deSolve&quot;. The default
    &quot;lsoda&quot; is performant, but sometimes fails to converge.
  </dd>
      <dt>use_compiled</dt>
      <dd>
    If set to <code>FALSE</code>, no compiled version of the <code>mkinmod</code> 
    model is used, even if is present. 
  </dd>
      <dt>atol</dt>
      <dd>
    Absolute error tolerance, passed to <code>ode</code>. Default is 1e-8,
    lower than in <code>lsoda</code>.
  </dd>
      <dt>rtol</dt>
      <dd>
    Absolute error tolerance, passed to <code>ode</code>. Default is 1e-10,
    much lower than in <code>lsoda</code>.
  </dd>
      <dt>map_output</dt>
      <dd>
    Boolean to specify if the output should list values for the observed
    variables (default) or for all state variables (if set to FALSE). 
  </dd>
      <dt>&amp;#8230;</dt>
      <dd>
    Further arguments passed to the ode solver in case such a solver is used.
  </dd>
    </dl>
    
    <div class="Value">
      <h2>Value</h2>

      <p>A matrix in the same format as the output of <code>ode</code>.</p>
    </div>
    
    <h2 id="examples">Examples</h2>
    <pre class="examples"><div class='input'>  <span class='no'>SFO</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinmod</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>))
  <span class='co'># Compare solution types</span>
  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)</div><div class='output co'>#&gt;    time  degradinol
#&gt; 1     0 100.0000000
#&gt; 2     1  74.0818221
#&gt; 3     2  54.8811636
#&gt; 4     3  40.6569660
#&gt; 5     4  30.1194212
#&gt; 6     5  22.3130160
#&gt; 7     6  16.5298888
#&gt; 8     7  12.2456428
#&gt; 9     8   9.0717953
#&gt; 10    9   6.7205513
#&gt; 11   10   4.9787068
#&gt; 12   11   3.6883167
#&gt; 13   12   2.7323722
#&gt; 14   13   2.0241911
#&gt; 15   14   1.4995577
#&gt; 16   15   1.1108997
#&gt; 17   16   0.8229747
#&gt; 18   17   0.6096747
#&gt; 19   18   0.4516581
#&gt; 20   19   0.3345965
#&gt; 21   20   0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>)</div><div class='output co'>#&gt;    time  degradinol
#&gt; 1     0 100.0000000
#&gt; 2     1  74.0818221
#&gt; 3     2  54.8811636
#&gt; 4     3  40.6569660
#&gt; 5     4  30.1194212
#&gt; 6     5  22.3130160
#&gt; 7     6  16.5298888
#&gt; 8     7  12.2456428
#&gt; 9     8   9.0717953
#&gt; 10    9   6.7205513
#&gt; 11   10   4.9787068
#&gt; 12   11   3.6883167
#&gt; 13   12   2.7323722
#&gt; 14   13   2.0241911
#&gt; 15   14   1.4995577
#&gt; 16   15   1.1108996
#&gt; 17   16   0.8229747
#&gt; 18   17   0.6096747
#&gt; 19   18   0.4516581
#&gt; 20   19   0.3345965
#&gt; 21   20   0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>, <span class='kw'>use_compiled</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</div><div class='output co'>#&gt;    time  degradinol
#&gt; 1     0 100.0000000
#&gt; 2     1  74.0818221
#&gt; 3     2  54.8811636
#&gt; 4     3  40.6569660
#&gt; 5     4  30.1194212
#&gt; 6     5  22.3130160
#&gt; 7     6  16.5298888
#&gt; 8     7  12.2456428
#&gt; 9     8   9.0717953
#&gt; 10    9   6.7205513
#&gt; 11   10   4.9787068
#&gt; 12   11   3.6883167
#&gt; 13   12   2.7323722
#&gt; 14   13   2.0241911
#&gt; 15   14   1.4995577
#&gt; 16   15   1.1108996
#&gt; 17   16   0.8229747
#&gt; 18   17   0.6096747
#&gt; 19   18   0.4516581
#&gt; 20   19   0.3345965
#&gt; 21   20   0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"eigen"</span>)</div><div class='output co'>#&gt;    time  degradinol
#&gt; 1     0 100.0000000
#&gt; 2     1  74.0818221
#&gt; 3     2  54.8811636
#&gt; 4     3  40.6569660
#&gt; 5     4  30.1194212
#&gt; 6     5  22.3130160
#&gt; 7     6  16.5298888
#&gt; 8     7  12.2456428
#&gt; 9     8   9.0717953
#&gt; 10    9   6.7205513
#&gt; 11   10   4.9787068
#&gt; 12   11   3.6883167
#&gt; 13   12   2.7323722
#&gt; 14   13   2.0241911
#&gt; 15   14   1.4995577
#&gt; 16   15   1.1108997
#&gt; 17   16   0.8229747
#&gt; 18   17   0.6096747
#&gt; 19   18   0.4516581
#&gt; 20   19   0.3345965
#&gt; 21   20   0.2478752
#&gt; </div><div class='input'>

  <span class='co'># Compare integration methods to analytical solution</span>
  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"analytical"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#&gt;    time degradinol
#&gt; 21   20  0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"lsoda"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#&gt;    time degradinol
#&gt; 21   20  0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"ode45"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#&gt;    time degradinol
#&gt; 21   20  0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>), <span class='fl'>0</span>:<span class='fl'>20</span>,
              <span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"rk4"</span>)[<span class='fl'>21</span>,]</div><div class='output co'>#&gt;    time degradinol
#&gt; 21   20  0.2480043
#&gt; </div><div class='input'> <span class='co'># rk4 is not as precise here</span>

  <span class='co'># The number of output times used to make a lot of difference until the</span>
  <span class='co'># default for atol was adjusted</span>
  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>),
              <span class='fu'>seq</span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>))[<span class='fl'>201</span>,]</div><div class='output co'>#&gt;     time degradinol
#&gt; 201   20  0.2478752
#&gt; </div><div class='input'>  <span class='fu'>mkinpredict</span>(<span class='no'>SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_degradinol_sink</span> <span class='kw'>=</span> <span class='fl'>0.3</span>), <span class='fu'>c</span>(<span class='kw'>degradinol</span> <span class='kw'>=</span> <span class='fl'>100</span>),
              <span class='fu'>seq</span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.01</span>))[<span class='fl'>2001</span>,]</div><div class='output co'>#&gt;      time degradinol
#&gt; 2001   20  0.2478752
#&gt; </div><div class='input'>
  <span class='co'># Check compiled model versions - they are faster than the eigenvalue based solutions!</span>
  <span class='no'>SFO_SFO</span> <span class='kw'>=</span> <span class='fu'>mkinmod</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"m1"</span>),
                    <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>))</div><div class='output'><strong class='text-info'>Successfully compiled differential equation model from auto-generated C code.</strong></div><div class='input'>  <span class='fu'>system.time</span>(
    <span class='fu'>print</span>(<span class='fu'>mkinpredict</span>(<span class='no'>SFO_SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_parent_m1</span> <span class='kw'>=</span> <span class='fl'>0.05</span>, <span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>k_m1_sink</span> <span class='kw'>=</span> <span class='fl'>0.01</span>),
                <span class='fu'>c</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fl'>0</span>), <span class='fu'>seq</span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>),
                <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"eigen"</span>)[<span class='fl'>201</span>,]))</div><div class='output co'>#&gt;     time   parent       m1
#&gt; 201   20 4.978707 27.46227
#&gt; </div><div class='output co'>#&gt;    user  system elapsed 
#&gt;   0.000   0.028   0.004 
#&gt; </div><div class='input'>  <span class='fu'>system.time</span>(
    <span class='fu'>print</span>(<span class='fu'>mkinpredict</span>(<span class='no'>SFO_SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_parent_m1</span> <span class='kw'>=</span> <span class='fl'>0.05</span>, <span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>k_m1_sink</span> <span class='kw'>=</span> <span class='fl'>0.01</span>),
                <span class='fu'>c</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fl'>0</span>), <span class='fu'>seq</span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>),
                <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>)[<span class='fl'>201</span>,]))</div><div class='output co'>#&gt;     time   parent       m1
#&gt; 201   20 4.978707 27.46227
#&gt; </div><div class='output co'>#&gt;    user  system elapsed 
#&gt;   0.016   0.004   0.002 
#&gt; </div><div class='input'>  <span class='fu'>system.time</span>(
    <span class='fu'>print</span>(<span class='fu'>mkinpredict</span>(<span class='no'>SFO_SFO</span>, <span class='fu'>c</span>(<span class='kw'>k_parent_m1</span> <span class='kw'>=</span> <span class='fl'>0.05</span>, <span class='kw'>k_parent_sink</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>k_m1_sink</span> <span class='kw'>=</span> <span class='fl'>0.01</span>),
                <span class='fu'>c</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fl'>0</span>), <span class='fu'>seq</span>(<span class='fl'>0</span>, <span class='fl'>20</span>, <span class='kw'>by</span> <span class='kw'>=</span> <span class='fl'>0.1</span>),
                <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>, <span class='kw'>use_compiled</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)[<span class='fl'>201</span>,]))</div><div class='output co'>#&gt;     time   parent       m1
#&gt; 201   20 4.978707 27.46227
#&gt; </div><div class='output co'>#&gt;    user  system elapsed 
#&gt;   0.036   0.000   0.035 
#&gt; </div></pre>
  </div>
  <div class="col-md-3">
    <h2>Author</h2>
    
  Johannes Ranke

  </div>
</div>

      <footer>
      <p>Built by <a href="http://hadley.github.io/pkgdown/">pkgdown</a>. Styled with <a href="http://getbootstrap.com">Bootstrap 3</a>.</p>
      </footer>
   </div>

  </body>
</html>

Contact - Imprint