insightrx / pkpdsim Goto Github PK
View Code? Open in Web Editor NEWSimulate PK-PD models defined as ODE systems
Home Page: https://insightrx.github.io/PKPDsim/
License: Other
Simulate PK-PD models defined as ODE systems
Home Page: https://insightrx.github.io/PKPDsim/
License: Other
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()
Can you help advice what is not right here please
Thank you
Jesmin
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?
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
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
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()
?
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
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 ))
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.
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
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
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
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
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]=KAA[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]=KAA[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!:)
I'm trying to create an ODE model with sin and cos and it is not working
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.