New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[F] Better handling analytical PK models #34
Comments
Looks like a nice set of ideas. I'm a little confused regarding the CL vs CLi distinction. For example, given this trans11 example:
Wouldn't this be the same as just using trans2 and explicitly capturing? : code <- '
$PARAM CL = 1, V = 35, KA = 1
$CMT GUT CENT
-$SUBROUTINES advan=2, trans=11
+$SUBROUTINES advan=2, trans=2
$MAIN
double CLi = CL*exp(ETA(1));
double Vi = V*exp(ETA(2));
double KAi = KA;
$OMEGA 1 1
labels=s(ECL,EV)
-$CAPTURE ECL EV
+$CAPTURE ECL EV CLi Vi KAi
' aka the 'benefit' is your Secondly, it seems trans1 could just be a default? code <- '
$PARAM a = 1, b = 35, c = 12, d = 200, e = 1
$CMT GUT CENT PERIPH
-$SUBROUTINES advan=4, trans=1
+$SUBROUTINES advan=4
$MAIN
pred_CL = a;
pred_V2 = b;
pred_Q = c;
pred_V3 = d;
pred_KA = e;
' |
Yes trans = 1 is the default. I explicitly set it, but you are right ... it wasn't necessary to do. The main benefit / motivation for doing this is getting the user out of having to write stuff like this:
Once you commit to, say, It's kind of a fix for a self-inflicted wound: I fooled around with 3 or 4 different ways to get
which seems really wasteful when you should be able to do this:
The trans 1, 2, and 4 are as NONMEM does. I invented trans 13 because I tend to code like that and wanted to have it around. Posted the proposal to see if any other unforeseen consequences. I want to deprecate |
Another try: drop This still has trans = 1 (nothing) trans=2 (CL/V/KA) and trans=4 (CL/V2/Q/V3/KA). Wondering about changing trans to be either "CLV" ... "clearances and volumes" ... mrgsolve will pick the right parameter set based on the number of compartments chosen (most users doing this) or "CLVi" ... clearances and volumes with code <- '
$CMT GUT CENT
$PKMODEL ncmt=1, trans=2, depot=TRUE
$PARAM CL=1, V = 20, KA=1
'
mod <-mcode("model", code)
mod %>% ev(amt=100) %>% mrgsim
|
haha I was already thinking about
pkmodel could quickly check for invalid param combos so
could fail with like
This is of course, assuming that the flexibility of these analytical models is still low enough to handle this. |
The problem with dropping code blocks I think has to deal with On Tue, Apr 26, 2016 at 5:37 PM Devin Pastoor notifications@github.com
|
and to your previous post - absolutely get (and really like) the idea of providing those shorthands - I still am just trying to wrap my head around CL vs CLi distinction that trans11 provides. Does it provide additional error checking or something? Wouldn't CLi Vi etc essentially always need to be defined 'customly' given the expectation of a random effects structure being added (else they'd just be using trans2) As in, what is the benefit of this:
over
Other than not having to explicitly capture CLi Vi? Is there addtional error checking optimization etc? |
@dpastoor wrote:
We could totally do this; you wouldn't need to compile anything, but let odeproblem::advan2 do all of the calculating back in the mrgsolve dll. As @vjd noted you couldn't do anything complicated like covariate model (or population stuff) ... but it could be useful / cool do to for teaching "two-compartment model" or whatever. |
Sorry for confusion on: All it does is give the user more flexibility around the names of the variables. Whether you use trans 2 @dpastoor wrote:
Since I was showing Vijay this today ... When you use
as if you yourself wrote it. It uses CL/V/KA because If, instead, you used
That's better ... we want to advance with the individual, not population, parameters. Either way, the I wouldn't say there is and advantage of 11 over 2. Only that, if you had |
Here's the latest stab:
Still calling this ##' Parse data from \code{$PKMODEL}.
##'
##' @param ncmt number of compartments
##' @param depot logical indicating whether to add depot/dosing compartment
##' @param trans the parameterization for the PK model
PKMODEL <- function(ncmt=1, depot=FALSE, trans = pick_trans(ncmt,depot), ...) {
stopifnot(ncmt %in% c(1,2))
advan <- pick_advan(ncmt,depot)
return(list(advan=advan, trans=trans, n=ncmt))
} We want 1-compartment model with depot dosing; trans is assumed to be 2 for one-compartment model we need to supply |
I "kind of" see - pardon my naivety - if it's not too much trouble can you expand on what the difference in advancing the system between those 2. ** I had typed out a longer response, and have now deleted it since I think something clicked in my head, hopefully my understanding below is correct ** are you saying, that if this code was used
the conc values, which are ultimately derived from pred_CL, etc. would be referenced to CL still, so our CLi derivation would draw from an eta distribution and be output, but that would just be seen as another user defined variable, nothing 'special' so wouldn't actually impact underlying concentration calculations, which would still be driven by the pop CL/V since they are mapped to pred_CL = CL etc. If this is the case, then it of course makes absolute sense why you need that explicit distinction. |
@dpastoor 's explanation matches up with what I was thinking. |
Hopefully the specification has been simplified. But I can still see confusion ahead. I'm about to check in some code that searches library(dplyr)
library(magrittr)
library(mrgsolve) PROBLEMcode <- '
$CMT CENT
$PKMODEL ncmt=1
$PARAM V1 = 2
$MAIN
double CL = 1;
double VC = 2;
'
mod <- try(mcode("foo1", code))
mod
FINEcode <- '
$CMT CENT
$PKMODEL ncmt=1
$PARAM V = 2
$MAIN
double CL = 1;
double VC = 2;
'
mod <- try(mcode("foo2", code))
mod
PROBLEMcode <- '
$CMT CENT PERIPH
$PKMODEL ncmt=2
$PARAM V = 2
$MAIN
double CL = 1;
double VC = 2;
'
mod <- try(mcode("foo3", code))
mod
FINEcode <- '
$CMT CENT PERIPH
$PKMODEL ncmt=2
$PARAM V = 2, KM = 2, V3 = 2
$GLOBAL
bool foo = false;
$MAIN
double CL = 1;
double V2 = 2;
double Q = 3;
double KA = 1;
'
mod <- try(mcode("foo4", code))
mod
PROBLEMcode <- '
$CMT GUT CENT PERIPH
$PKMODEL ncmt=2, depot=TRUE, trans=11
$PARAM V = 2, KM = 2, V3 = 2, Qi = 2
$GLOBAL
bool foo = false;
$MAIN
double CL = 1;
double V2 = 2;
double Q = 3;
double KA = 1;
'
mod <- try(mcode("foo5",code))
mod
FINEcode <- '
$CMT GUT CENT PERIPH
$PKMODEL ncmt=2, depot=TRUE, trans=11
$PARAM V = 2, KM = 2, V3 = 2, Qi = 2
$GLOBAL
bool foo = false;
$MAIN
double CLi = 1;
double V2i = 2;
double Q = 3;
double V3i = 200;
double KAi = 1;
'
mod <- try(mcode("foo6",code))
mod
|
Yep would have already brought it up if it felt too weird. So far been very pleasant (beyond that one tricky error) |
This seems pretty stable so far. Closing. |
Proposed change for analytical PK models
The idea is this: specify
ADVAN
andTRANS
in$SUBROUTINES
. Depending on what you pick forTRANS
,mrgsolve
will automatically capture the "fundamental" PK parameters for that ADVAN/TRANS.For
trans 2
, the fundamental parameters areCL
,V
, andKA
. We can utilize items in$PARAM
here.Another
trans
(11) puts a lower casei
at the end. We could draw from$PARAM
again, but in this example, we use a derived variable.A similar deal for
ADVAN 4
Just leave me alone
What's included?
ADVAN
1 through 4 (as defined by NONMEM)TRANS
pred_CL
,pred_V3
etc ... theTRANS
stuff is just convenience to save you typing.TRANS
. But if you don't, the compiler will give a pretty clear error thatVi
(for example) wasn't found.$ADVAN2
and$ADVAN4
. For now, they should work as they always have.The text was updated successfully, but these errors were encountered: