Initial Setup

library(CoRC)
loadExamples(2)
#> [[1]]
#> # A COPASI model reference:
#> Model name: "Bacterial chemotaxis model"
#> Number of compartments: 1
#> Number of species: 21
#> Number of reactions: 14

Task functions

CoRC has implemented a variety of COPASI functions. Tasks generally have an run execution function (e.g. runTimeCourse), a settings set function (e.g. setTimeCourseSettings) and a settings get function (e.g. getTimeCourseSettings).

Get task settings:

Get functions return a list of settings in the same format as is expected as input to set functions.

str(getTimeCourseSettings())
#> List of 11
#>  $ duration              : num 1000
#>  $ dt                    : num 0.1
#>  $ intervals             : int 10000
#>  $ automatic_intervals   : logi FALSE
#>  $ suppress_output_before: num 0
#>  $ output_events         : logi FALSE
#>  $ save_result_in_memory : logi TRUE
#>  $ start_in_steady_state : logi FALSE
#>  $ update_model          : logi FALSE
#>  $ executable            : logi FALSE
#>  $ method                :List of 6
#>   ..$ method                 : chr "deterministic"
#>   ..$ integrate_reduced_model: logi FALSE
#>   ..$ relative_tolerance     : num 1e-06
#>   ..$ absolute_tolerance     : num 1e-12
#>   ..$ max_internal_steps     : int 10000
#>   ..$ max_internal_step_size : num 0

Set task settings:

setTimeCourseSettings(duration = 100)
getTimeCourseSettings()$duration
#> [1] 100

Run task:

Run functions return a list of results. Included in this list is an entry settings with contains all tasks settings.

str(runTimeCourse())
#> List of 6
#>  $ settings     :List of 11
#>   ..$ duration              : num 100
#>   ..$ dt                    : num 0.01
#>   ..$ intervals             : int 10000
#>   ..$ automatic_intervals   : logi FALSE
#>   ..$ suppress_output_before: num 0
#>   ..$ output_events         : logi FALSE
#>   ..$ save_result_in_memory : logi TRUE
#>   ..$ start_in_steady_state : logi FALSE
#>   ..$ update_model          : logi FALSE
#>   ..$ executable            : logi FALSE
#>   ..$ method                :List of 6
#>   .. ..$ method                 : chr "deterministic"
#>   .. ..$ integrate_reduced_model: logi FALSE
#>   .. ..$ relative_tolerance     : num 1e-06
#>   .. ..$ absolute_tolerance     : num 1e-12
#>   .. ..$ max_internal_steps     : int 10000
#>   .. ..$ max_internal_step_size : num 0
#>  $ column_keys  : chr [1:19] "Time" "T1{compartment}" "T3{compartment}" "CheY{compartment}" ...
#>  $ units        :List of 2
#>   ..$ time         : chr "s"
#>   ..$ concentration: chr "µmol / l"
#>  $ result       : tibble [10,001 × 19] (S3: tbl_df/tbl/data.frame)
#>   ..$ Time    : num [1:10001] 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 ...
#>   ..$ T1      : num [1:10001] 0 0.000612 0.001225 0.001837 0.002449 ...
#>   ..$ T3      : num [1:10001] 0.00 1.36e-12 1.09e-11 3.68e-11 8.72e-11 ...
#>   ..$ CheY    : num [1:10001] 9.7 9.7 9.7 9.7 9.7 ...
#>   ..$ CheA    : num [1:10001] 5.3 5.3 5.3 5.3 5.3 ...
#>   ..$ T2      : num [1:10001] 0.00 3.54e-08 1.42e-07 3.18e-07 5.66e-07 ...
#>   ..$ CheBp   : num [1:10001] 0.00 6.19e-08 2.73e-07 6.33e-07 1.14e-06 ...
#>   ..$ T4      : num [1:10001] 0.00 3.94e-17 6.30e-16 3.19e-15 1.01e-14 ...
#>   ..$ CheAp   : num [1:10001] 0.00 1.63e-05 3.44e-05 5.25e-05 7.06e-05 ...
#>   ..$ CheB    : num [1:10001] 0.28 0.28 0.28 0.28 0.28 ...
#>   ..$ T0      : num [1:10001] 5.3 5.3 5.3 5.3 5.3 ...
#>   ..$ CheYp   : num [1:10001] 0 0.000052 0.000173 0.000316 0.000467 ...
#>   ..$ Tactive : num [1:10001] 0.00 6.64e-05 1.33e-04 1.99e-04 2.66e-04 ...
#>   ..$ Tactive0: num [1:10001] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ Tactive1: num [1:10001] 0.00 6.64e-05 1.33e-04 1.99e-04 2.65e-04 ...
#>   ..$ Tactive2: num [1:10001] 0.00 1.59e-08 6.34e-08 1.43e-07 2.54e-07 ...
#>   ..$ Tactive3: num [1:10001] 0.00 1.02e-12 8.12e-12 2.74e-11 6.50e-11 ...
#>   ..$ Tactive4: num [1:10001] 0.00 3.94e-17 6.30e-16 3.19e-15 1.01e-14 ...
#>   ..$ Ttotal  : num [1:10001] 5.3 5.3 5.3 5.3 5.3 ...
#>  $ result_number: tibble [10,001 × 19] (S3: tbl_df/tbl/data.frame)
#>   ..$ Time    : num [1:10001] 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 ...
#>   ..$ T1      : num [1:10001] 0 0.516 1.033 1.549 2.065 ...
#>   ..$ T3      : num [1:10001] 0.00 1.15e-09 9.20e-09 3.10e-08 7.36e-08 ...
#>   ..$ CheY    : num [1:10001] 8178 8178 8178 8178 8178 ...
#>   ..$ CheA    : num [1:10001] 4468 4468 4468 4468 4468 ...
#>   ..$ T2      : num [1:10001] 0.00 2.98e-05 1.19e-04 2.69e-04 4.77e-04 ...
#>   ..$ CheBp   : num [1:10001] 0.00 5.21e-05 2.30e-04 5.34e-04 9.63e-04 ...
#>   ..$ T4      : num [1:10001] 0.00 3.32e-14 5.31e-13 2.69e-12 8.50e-12 ...
#>   ..$ CheAp   : num [1:10001] 0 0.0137 0.029 0.0443 0.0596 ...
#>   ..$ CheB    : num [1:10001] 236 236 236 236 236 ...
#>   ..$ T0      : num [1:10001] 4468 4468 4467 4467 4466 ...
#>   ..$ CheYp   : num [1:10001] 0 0.0439 0.1457 0.2667 0.3938 ...
#>   ..$ Tactive : num [1:10001] 0 0.056 0.112 0.168 0.224 ...
#>   ..$ Tactive0: num [1:10001] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ Tactive1: num [1:10001] 0 0.056 0.112 0.168 0.224 ...
#>   ..$ Tactive2: num [1:10001] 0.00 1.34e-05 5.35e-05 1.20e-04 2.14e-04 ...
#>   ..$ Tactive3: num [1:10001] 0.00 8.56e-10 6.85e-09 2.31e-08 5.48e-08 ...
#>   ..$ Tactive4: num [1:10001] 0.00 3.32e-14 5.31e-13 2.69e-12 8.50e-12 ...
#>   ..$ Ttotal  : num [1:10001] 4468 4468 4468 4468 4468 ...
#>  $ task_error   : NULL
#>  - attr(*, "class")= chr "copasi_ts"

Task settings

Task settings can be set in two ways. The set familiy of functions is the preferred way to set task settings.

getTimeCourseSettings()$duration
#> [1] 100
setTimeCourseSettings(duration = 10)
getTimeCourseSettings()$duration
#> [1] 10

The run familiy of functions will generally take the same arguments as the set familiy of functions but will only set them temporarily.

getTimeCourseSettings()$duration
#> [1] 10
runTimeCourse(duration = 1)$settings$duration
#> [1] 1
getTimeCourseSettings()$duration
#> [1] 10

The get familiy of functions will return a list that can be used as a template for calling functions that expect settings as input. A similar list is also given in every output of a run function.

method_settings <- getTimeCourseSettings()$method
str(method_settings)
#> List of 6
#>  $ method                 : chr "deterministic"
#>  $ integrate_reduced_model: logi FALSE
#>  $ relative_tolerance     : num 1e-06
#>  $ absolute_tolerance     : num 1e-12
#>  $ max_internal_steps     : int 10000
#>  $ max_internal_step_size : num 0

setTimeCourseSettings(method = method_settings)

Task execution

Executing a task will return a list containing all relevant task results.

str(runTimeCourse())
#> List of 6
#>  $ settings     :List of 11
#>   ..$ duration              : num 10
#>   ..$ dt                    : num 0.001
#>   ..$ intervals             : int 10000
#>   ..$ automatic_intervals   : logi FALSE
#>   ..$ suppress_output_before: num 0
#>   ..$ output_events         : logi FALSE
#>   ..$ save_result_in_memory : logi TRUE
#>   ..$ start_in_steady_state : logi FALSE
#>   ..$ update_model          : logi FALSE
#>   ..$ executable            : logi FALSE
#>   ..$ method                :List of 6
#>   .. ..$ method                 : chr "deterministic"
#>   .. ..$ integrate_reduced_model: logi FALSE
#>   .. ..$ relative_tolerance     : num 1e-06
#>   .. ..$ absolute_tolerance     : num 1e-12
#>   .. ..$ max_internal_steps     : int 10000
#>   .. ..$ max_internal_step_size : num 0
#>  $ column_keys  : chr [1:19] "Time" "T1{compartment}" "T3{compartment}" "CheY{compartment}" ...
#>  $ units        :List of 2
#>   ..$ time         : chr "s"
#>   ..$ concentration: chr "µmol / l"
#>  $ result       : tibble [10,001 × 19] (S3: tbl_df/tbl/data.frame)
#>   ..$ Time    : num [1:10001] 0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 ...
#>   ..$ T1      : num [1:10001] 0.00 6.13e-05 1.23e-04 1.84e-04 2.45e-04 ...
#>   ..$ T3      : num [1:10001] 0.00 1.36e-15 1.09e-14 3.68e-14 8.73e-14 ...
#>   ..$ CheY    : num [1:10001] 9.7 9.7 9.7 9.7 9.7 ...
#>   ..$ CheA    : num [1:10001] 5.3 5.3 5.3 5.3 5.3 ...
#>   ..$ T2      : num [1:10001] 0.00 3.54e-10 1.42e-09 3.19e-09 5.66e-09 ...
#>   ..$ CheBp   : num [1:10001] 0.00 1.96e-10 1.29e-09 3.67e-09 7.48e-09 ...
#>   ..$ T4      : num [1:10001] 0.00 3.94e-21 6.30e-20 3.19e-19 1.01e-18 ...
#>   ..$ CheAp   : num [1:10001] 0.00 6.52e-07 2.03e-06 3.67e-06 5.42e-06 ...
#>   ..$ CheB    : num [1:10001] 0.28 0.28 0.28 0.28 0.28 ...
#>   ..$ T0      : num [1:10001] 5.3 5.3 5.3 5.3 5.3 ...
#>   ..$ CheYp   : num [1:10001] 0.00 2.20e-07 1.40e-06 3.87e-06 7.63e-06 ...
#>   ..$ Tactive : num [1:10001] 0.00 6.64e-06 1.33e-05 1.99e-05 2.66e-05 ...
#>   ..$ Tactive0: num [1:10001] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ Tactive1: num [1:10001] 0.00 6.64e-06 1.33e-05 1.99e-05 2.66e-05 ...
#>   ..$ Tactive2: num [1:10001] 0.00 1.59e-10 6.34e-10 1.43e-09 2.54e-09 ...
#>   ..$ Tactive3: num [1:10001] 0.00 1.02e-15 8.12e-15 2.74e-14 6.50e-14 ...
#>   ..$ Tactive4: num [1:10001] 0.00 3.94e-21 6.30e-20 3.19e-19 1.01e-18 ...
#>   ..$ Ttotal  : num [1:10001] 5.3 5.3 5.3 5.3 5.3 5.3 5.3 5.3 5.3 5.3 ...
#>  $ result_number: tibble [10,001 × 19] (S3: tbl_df/tbl/data.frame)
#>   ..$ Time    : num [1:10001] 0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 ...
#>   ..$ T1      : num [1:10001] 0 0.0516 0.1033 0.1549 0.2066 ...
#>   ..$ T3      : num [1:10001] 0.00 1.15e-12 9.20e-12 3.10e-11 7.36e-11 ...
#>   ..$ CheY    : num [1:10001] 8178 8178 8178 8178 8178 ...
#>   ..$ CheA    : num [1:10001] 4468 4468 4468 4468 4468 ...
#>   ..$ T2      : num [1:10001] 0.00 2.98e-07 1.19e-06 2.69e-06 4.77e-06 ...
#>   ..$ CheBp   : num [1:10001] 0.00 1.66e-07 1.09e-06 3.09e-06 6.30e-06 ...
#>   ..$ T4      : num [1:10001] 0.00 3.32e-18 5.32e-17 2.69e-16 8.50e-16 ...
#>   ..$ CheAp   : num [1:10001] 0 0.00055 0.00171 0.00309 0.00457 ...
#>   ..$ CheB    : num [1:10001] 236 236 236 236 236 ...
#>   ..$ T0      : num [1:10001] 4468 4468 4468 4468 4468 ...
#>   ..$ CheYp   : num [1:10001] 0 0.000186 0.001184 0.003259 0.00643 ...
#>   ..$ Tactive : num [1:10001] 0 0.0056 0.0112 0.0168 0.0224 ...
#>   ..$ Tactive0: num [1:10001] 0 0 0 0 0 0 0 0 0 0 ...
#>   ..$ Tactive1: num [1:10001] 0 0.0056 0.0112 0.0168 0.0224 ...
#>   ..$ Tactive2: num [1:10001] 0.00 1.34e-07 5.35e-07 1.20e-06 2.14e-06 ...
#>   ..$ Tactive3: num [1:10001] 0.00 8.56e-13 6.85e-12 2.31e-11 5.48e-11 ...
#>   ..$ Tactive4: num [1:10001] 0.00 3.32e-18 5.31e-17 2.69e-16 8.50e-16 ...
#>   ..$ Ttotal  : num [1:10001] 4468 4468 4468 4468 4468 ...
#>  $ task_error   : NULL
#>  - attr(*, "class")= chr "copasi_ts"

str(runSteadyState())
#> List of 9
#>  $ settings         :List of 5
#>   ..$ calculate_jacobian        : logi TRUE
#>   ..$ perform_stability_analysis: logi TRUE
#>   ..$ update_model              : logi FALSE
#>   ..$ executable                : logi FALSE
#>   ..$ method                    :List of 10
#>   .. ..$ resolution                               : num 1e-09
#>   .. ..$ derivation_factor                        : num 0.001
#>   .. ..$ use_newton                               : logi TRUE
#>   .. ..$ use_integration                          : logi TRUE
#>   .. ..$ use_back_integration                     : logi TRUE
#>   .. ..$ accept_negative_concentrations           : logi FALSE
#>   .. ..$ iteration_limit                          : int 50
#>   .. ..$ maximum_duration_for_forward_integration : num 1e+09
#>   .. ..$ maximum_duration_for_backward_integration: num 1e+06
#>   .. ..$ target_criterion                         : chr "Distance and Rate"
#>  $ result           : chr "found"
#>  $ species          : tibble [11 × 8] (S3: tbl_df/tbl/data.frame)
#>   ..$ key            : chr [1:11] "CheA{compartment}" "CheAp{compartment}" "CheB{compartment}" "CheBp{compartment}" ...
#>   ..$ name           : chr [1:11] "CheA" "CheAp" "CheB" "CheBp" ...
#>   ..$ type           : chr [1:11] "reactions" "reactions" "reactions" "reactions" ...
#>   ..$ concentration  : num [1:11] 5.185 0.115 0.2082 0.0718 8.8118 ...
#>   ..$ number         : num [1:11] 4371.5 97 175.5 60.6 7429.2 ...
#>   ..$ rate           : num [1:11] 2.42e-13 -2.42e-13 -1.85e-16 1.85e-16 -1.90e-13 ...
#>   ..$ number_rate    : num [1:11] 2.04e-10 -2.04e-10 -1.56e-13 1.56e-13 -1.60e-10 ...
#>   ..$ transition_time: num [1:11] 0.05112 0.00113 2.89824 1 0.08695 ...
#>  $ compartments     : tibble [0 × 5] (S3: tbl_df/tbl/data.frame)
#>   ..$ key : chr(0) 
#>   ..$ name: chr(0) 
#>   ..$ type: chr(0) 
#>   ..$ size: num(0) 
#>   ..$ rate: num(0) 
#>  $ global_quantities: tibble [0 × 5] (S3: tbl_df/tbl/data.frame)
#>   ..$ key  : chr(0) 
#>   ..$ name : chr(0) 
#>   ..$ type : chr(0) 
#>   ..$ value: num(0) 
#>   ..$ rate : num(0) 
#>  $ reactions        : tibble [14 × 4] (S3: tbl_df/tbl/data.frame)
#>   ..$ key        : chr [1:14] "(Che A phosph)" "(Che B phosph)" "(Che Y phosph)" "(Che Y autodephosph)" ...
#>   ..$ name       : chr [1:14] "Che A phosph" "Che B phosph" "Che Y phosph" "Che Y autodephosph" ...
#>   ..$ flux       : num [1:14] 1.42e-13 1.01e-16 1.42e-13 1.24e-16 4.75e-17 ...
#>   ..$ number_flux: num [1:14] 85505.5 60.6 85445 74.9 28.6 ...
#>  $ jacobian_complete: num [1:11, 1:11] -3.01e-02 -5.07e-04 0.00 -2.81e+01 8.71e-03 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : chr [1:11] "T1" "T3" "CheY" "CheA" ...
#>   .. ..$ : chr [1:11] "T1" "T3" "CheY" "CheA" ...
#>  $ jacobian_reduced : num [1:7, 1:7] -3.97e-02 1.29e-04 0.00 -2.81e+01 1.23e-02 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : chr [1:7] "T1" "T3" "CheY" "CheA" ...
#>   .. ..$ : chr [1:7] "T1" "T3" "CheY" "CheA" ...
#>  $ protocol         : chr "Try Newton's method. \n   Starting Newton Iterations...\n    Newton step failed. Negative volume or concentrati"| __truncated__