Giter Site home page Giter Site logo

insightrx / pkpdsim Goto Github PK

View Code? Open in Web Editor NEW
29.0 12.0 10.0 42.07 MB

Simulate PK-PD models defined as ODE systems

Home Page: https://insightrx.github.io/PKPDsim/

License: Other

R 89.91% C++ 9.70% Shell 0.29% Dockerfile 0.10%
pharmacometrics r ode pharmacodynamics pharmacokinetics

pkpdsim's People

Contributors

benjaminrich avatar dominic-irx avatar dpastoor avatar insightrx-ci avatar jasmineirx avatar karawoo avatar roninsightrx avatar ronkeizer avatar shanmdphd avatar vikrammatange avatar willfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pkpdsim's Issues

Beginning Test Run

Hello
Im trying PKPDSim and ran the below code as in the site:
install.packages("PKPDsim")
library(PKPDsim)
library(ggplot2)

pk2 <- new_ode_model(
code = "dAdt[1] = -(CL/V) * A[1]",
obs = list(cmt = 1, scale = "V"),
dose = list(cmt = 1)
)
r2 <- new_regimen(
amt = 100,
n = 5,
interval = 12,
type = "infusion",
t_inf = 2
)
dat2 <- sim(
ode = pk2,
parameters = p,
regimen = r2,
only_obs = TRUE
)
ggplot(dat2, aes(x = t, y = y)) +
geom_line()

pkpdsim_Test1 compared to the ones in the site

Can you help advice what is not right here please
Thank you
Jesmin

Interface with nlmixr (estimation)

Hi Ron,
I was wondering how well PKPDsim interfaces with nlmixr. I noticed your pkpdsim_to_nlmix() function accurately creates an nlmixr ui model to be fitted, given a simple model. PKPDsim provides more flexibility in model specification, such as allowing the specification of time varying covariates. I myself am having an issue just with creating fixed covariates with nlmixr while using the saem estimation method (this is a known issue with nlmixr and saem). I am assuming if the functionality was not implemented in nlmixr, but was with PKPDsim, the model will not translate well. I was hoping you could confirm or deny this, and if that is the case, have you utilized any other R packages for estimation that work well with PKPDsim?

Individual parameters

Hi,

First of all, thanks for maintaining this useful package.

I can't see from the documentation how to use individual parameters in a parameter table. I could do this in a loop or through the covariate table, but something tells me that it's just because I haven't found a more straightforward way.

Thanks!
Philip

Rcpp issue?

Hi Ron, I just installed the InsightRx/PKPDsim on a new macbook and I'm having issues with Rcpp when i try the new_ode_model() function. I am getting several errors like:

filecab22cab112.cpp:226:14: error: use of overloaded operator '=' is ambiguous (with operand types 'std::vector<double>' and 'Rcpp::Vector<19, PreserveStorage>::NameProxy' (aka 'generic_name_proxy<19, PreserveStorage>'))
  cov_FEMALE = design["cov_FEMALE"];
  ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:574:13: note: candidate function
    vector& operator=(vector&& __x)

I have run the code on an older macbook/older PKPsim version and everything works fine. When I installed PKPDsim, I updated all packages (Rccp version 1.0.3) but I have also tried older Rcpp versions with no luck.

I've found this previous post which seems to be describing the same issue. Do you think there a similar problem with the compiler version? Please advise on how to fix. Thanks! #1

feature to simulate with uncertainty

perhaps best to write a separate function to handle the looping over drawn parameter sets, rather than have an additional argument to PKPDsim? sim_uncertainty()?

I am getting Rcpp operator overloading issue n R 3.6.0, but it is fine R 3.4.2

Hi team,

I am trying to load a simple ode model provided in the docs page (covariates page). But I am getting an operator overloading issue between Rcpp::vector and std::vector in R 3.6.

When I try the same example in R 3.4.2, it works fine.

Could you please help me understand if there is a R version dependency and is that expected?

Thanks,
Thomas

If else statements within a differential equation

Dear @ronkeizer,
Can you please advise how would one try to write an ODE with an if/else statement in PKPDsim? I'm trying to write the following from Berkeley Madonna but not sure about the syntax/structure in PKPDsim...
Thanks in advance,
Mohamed

d/dt(Imax_FLT3) =
IF (C_FLT3>KC50_FLT3) THEN kdes * (1 - Imax_FLT3 * (1 + fu_FLT3 * C_FLT3/KC50_FLT3 )) ELSE kdes * (1 - Imax_FLT3 * (1 - fu_FLT3 * C_FLT3/KC50_FLT3 ))

Error with gcc-7.2

Dear PKPDSim creators,

thank you loads for a most useful package. With current versions of gcc-7.2 and stdlib, I ran into an error message. Using the introductory example

p <- list(CL = 1, V = 10, KA = 0.5)
pk1 <- new_ode_model("pk_1cmt_oral")

led to the following list of error messages, each one nagging at ambiguous overload operators:

file4b7eba8cc03.cpp: In Funktion »Rcpp::List sim_wrapper_cpp(Rcpp::NumericVector, Rcpp::List, Rcpp::List, Rcpp::NumericVector, double)«:
file4b7eba8cc03.cpp:89:21: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
times = design["t"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = double; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = double; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = double; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:90:24: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
doses = design["dose"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = double; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = double; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = double; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:91:23: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
evid = design["evid"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:92:23: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
dummy = design["dum"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = double; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = double; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = double; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:93:24: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
rates = design["rate"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = double; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = double; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = double; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:94:31: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
dose_cmt = design["dose_cmt"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
file4b7eba8cc03.cpp:95:28: Fehler: ambiguous overload for »operator=« (operand types are »std::vector« and »Rcpp::Vector<19>::NameProxy {aka Rcpp::internal::generic_name_proxy<19>}«)
dose_type = design["type"];
^
In file included from /usr/include/c++/7/vector:69:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/vector.tcc:179:5: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator]
vector<_Tp, _Alloc>::
^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/vector:64:0,
from /usr/local/lib64/R/library/Rcpp/include/RcppCommon.h:59,
from /usr/local/lib64/R/library/Rcpp/include/Rcpp.h:27,
from file4b7eba8cc03.cpp:8:
/usr/include/c++/7/bits/stl_vector.h:461:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator]
operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
^~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:482:7: Anmerkung: candidate: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator]
operator=(initializer_list<value_type> __l)
^~~~~~~~
make: *** [file4b7eba8cc03.o] Fehler 1
g++ -I/usr/local/lib64/R/include -DNDEBUG -I"/usr/local/lib64/R/library/Rcpp/include" -I"/usr/local/lib64/R/library/BH/include" -I"/tmp/RtmpD8fySg/sourceCpp-x86_64-pc-linux-gnu-0.12.13" -I/usr/local/include -w -fpic -g -O2 -c file4b7eba8cc03.cpp -o file4b7eba8cc03.o
/usr/local/lib64/R/etc/Makeconf:166: die Regel für Ziel „file4b7eba8cc03.o“ scheiterte
Fehler in Rcpp::sourceCpp(code = sim_func, rebuild = TRUE, env = globalenv(), :
Error 1 occurred building shared library.

Issue with making a model with new_ode_model()

The new_ode_model() function seems to be broken for me. I am using R 4.2.1 ? Is this potentially the issue?


 pk1 <- new_ode_model(model = "pk_1cmt_oral")
Error in if (txt < 0) return(ode_def_orig) : the condition has length > 1
> pk1 <- new_ode_model(code = "
+   dAdt[1] = -KA * A[1]
+   dAdt[2] = +KA * A[1] -(CL/V) * A[2]
+ ")
Error in if (txt < 0) return(ode_def_orig) : the condition has length > 1

How do you do a PKPD indrect response simulation?

Hi Ron,

I am trying to figure out how to simulate PK-IDR. Your documentation doesn't show much details. Also, I ran the example you provided, and was wondering how you can see/plot the Effect values at the same time as Conc vs Time; on same plot or separate plots?

-Ken

nlmixr package - saem and nlme function issue

Hi,

I have installed the nlmixr package. However when i try to run a code based on the package, i receive error on saem.

Also, i tested the package installation using the file provided by the nlmixr package developer. "https://raw.githubusercontent.com/nlmixrdevelopment/nlmixr/master/build/test_install.R".

When i source the above file, i receive the above error:

source("test_install.R")
Correct R version: Yes, R version 3.6.0 (2019-04-26)
RxODE installed: Yes
Python installed: Yes, Python 3.6.8
sympy installed: Yes
devtools package installed: Yes
RxODE package installed: Yes
Rtools installed or not needed: Yes
SnakeCharmR package installed: Yes
units package installed: Yes
nlmixr package installed: Yes
xpose.nlmixr package installed: Yes
shinyMixR package installed: Yes
Running nlme
Running saem
Error : Error building SAEM model

Could you please let me know what is the exact issue and how could i resolve it?

Best Regards,
Thomas

Simulate effect of a time-varying categorical covariate

Dear Ron,
I am trying to do a simple simulation for a cross-over trial where in period 1 multiple doses of Drug X alone (or under fasting condition) are administered. In period 2, multiple doses of Drug X are administered in combination with a another conmed (or with food). How can I code the off/on switch of the drug-drug or drug-food interactions (basically being silent in Period 1 and then active in Period 2)?
Thanks for your reply in advance...
Mohamed

Problems creating new_ode model

Hi guys,

I want to create a one compartment model with first order absorption and elimination (drug administered orally). I want the model to contain bioavailabilty and half life time and to be able to show concentrations and to predict time to reach steady state.

I first tried to model it like this (without halflife time):

par_mod_BA<-list(KA=1, KEL=0.6, F=0.98)
reg_mod_BA<-new_regimen(
amt=400,
interval=24,
n=5
)
mod_BA<-new_ode_model(
code="
dAdt[1]=-KAA[1];
dAdt[2]=KA
A[1]-KEL*A[2]",
dose=list(cmt=1, bioav="F"),
obs=list(cmt=2),
parameters=c("F","KEL", "KA")
)

My questions is:
I want to include half life time "HLT", that can be described by the term HLT=ln(2)/KEL, KEL=ln(2)/HLT respectively. I tried it by making HLT a covariate.

cov1<-list("HLT"=new_covariate(value=17))

par_mod_BA<-list(KA=1, KEL=0.6, F=0.98)

reg_mod_BA<-new_regimen(
amt=400,
interval=24,
n=5
)

mod_BA_HLT<-new_ode_model(
code="
dAdt[1]=-KAA[1];
dAdt[2]=KA
A[1]-KEL*A[2];
KEL=log(2)/HLT",
declare_variables=c("KEL","KA"),
covariates=cov1
)

data_mod_BA_HLT<-sim_ode(ode=mod_BA_HLT,
regimen=reg_mod_BA,
parameters=par_mod_BA)

But when I try to run the simulation is says:
Error in sim(...) :
Not all covariates for this model have been specified. Missing:
HLT

but I don't understand because I specified it in my opinion. I tried to fix it but I can't figure out what I am doing wrong...

Thank you so much for any help!:)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.