Learn R Programming

tktdjl2r

tktdjl2r is a R companion package for TKTDsimulation.jl package written in julia to simulate TKTD models.

You will need a working installation of Julia in your path. To install Julia, download a generic binary from the JuliaLang site and add it to your path.

TKTDsimulation.jl utilizes differential equation package of DifferentialEquations.jl.

Install julia and require packages

Once julia is installed, you may have to install TKTDsimulation.jl since this package is not in the official repository.

(@v1.5) pkg> add https://github.com/virgile-baudrot/TKTDsimulation.jl
   Updating git-repo `https://github.com/virgile-baudrot/TKTDsimulation.jl`
   Updating registry at `C:\Users\NAME\.julia\registries\General`
 Resolving package versions...
No Changes to `C:\Users\NAME\.julia\environments\v1.5\Project.toml`
No Changes to `C:\Users\NAME\.julia\environments\v1.5\Manifest.toml`

To install the master branch of the package (for developers), use:

devtools::install_github('in2p3/sandrine.charles/tktdjl2r', build_vignettes=T)

Trouble with JuliaCall

See the JuliaCall github repository

Test JuliaCall:

library(JuliaCall)
julia <- julia_setup()

Then try this comand:

julia_command("a = sqrt(2);")
julia_eval("a")

A simple example

library(tktdjl2r)

# Julia can be quite long to install the first time.
tktdjl2r::tktdjl2r_setup()

You should see these lines on windows:

Julia version 1.5.0 at location C:\Users\NAME\AppData\Local\Programs\JULIA1~1.0\bin will be used.
Loading setup script for JuliaCall...
Finish loading setup script for JuliaCall.

Then run the following models:

Note: the first time a model is run, it can be quite long due to setup.

  • TK model:
single_runTK = runTK(time=c(0,1,2,3), conc=c(0,1,2,2), kd=0.5)
  • SD model:
single_runSD = runSD(time=c(0,1,2,3), conc=c(0,1,2,2), 
                     kd=0.5, hb=0.2, z=1, kk=0.4)
  • IT model
single_runIT = runIT(time=c(0,1,2,3), conc=c(0,1,2,2),
                     kd=0.5, hb=0.2, alpha=1, beta=0.4)

Copy Link

Version

Install

install.packages('tktdjl2r')

Monthly Downloads

4

Version

0.2.0

License

MIT + file LICENSE

Maintainer

Virgile Baudrot

Last Published

December 17th, 2020

Functions in tktdjl2r (0.2.0)

runTK

Single TK model
runIT_MCMC

MCMC IT model
list_paramIT_PRZcst

Fit MCMC of propiconazole data set with IT model
runSD

Single SD model
runTK_MCMC

MCMC TK model
runIT

Single IT model
tktdjl2r_setup

Setup tktdjl2
runMFx

Function to compute the optimal multiplication factor for SD model with binary search using distribution of parameters
runSD_MCMC

MCMC SD model
list_paramSD_PRZcst

Fit MCMC of propiconazole data set with SD model