Skip to content
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

xpose.nlmixr does not capture all of the data #6

Closed
mattfidler opened this issue Apr 2, 2019 · 11 comments
Closed

xpose.nlmixr does not capture all of the data #6

mattfidler opened this issue Apr 2, 2019 · 11 comments

Comments

@mattfidler
Copy link
Contributor

There seems to be a problem importing data into xpose; Some of the data isn't captured.

See:

UUPharmacometrics/xpose#154

This can be useful in:

https://github.com/nlmixrdevelopment/nlmixr-examples/blob/master/case-study-warfarin/warfarin_PKPD_joint.R

@kestrel99 do you have any idea on this? It shouldn't be hard to be implement?

@bguiastr
Copy link

bguiastr commented Apr 2, 2019

As part of the upcoming initiative to make xpose S3 compatible, I will also try to contribute to xpose.nlmixr and bring it up to speed.

@mattfidler
Copy link
Contributor Author

Thank you @guiastrennec; Its much appreciated.

@DedeLLL
Copy link

DedeLLL commented Apr 4, 2019

Hi Dr.@mattfidler I am not sure if we are talking about the same problem. I was using the latest nlmixr 1.0.0.8 on github and wanted to use the function xpose_data_nlmixr() to convert the data. However I got the same error every time.
Error in data.frame(data_a, full.dat) : arguments imply differing number of rows: 6960, 6947
I also tried the old version of nlmixr 1.0.07 from Cran and the function xpose_data_nlmixr() worked smoothly. The package xpose.nlmixr I was using is version 0.1.3 downloaded from github.
Thanks for your time! :)

@kestrel99
Copy link
Collaborator

Thanks @guiastrennec! @DedeLLL, I'll look into your issue as well.

@DedeLLL
Copy link

DedeLLL commented Apr 4, 2019

Thanks so much! @kestrel99 :)

@mattfidler
Copy link
Contributor Author

Hi @DedeLLL it seems like a different issue. Was there any warnings after fitting the data, like IDs that were dropped?

@DedeLLL
Copy link

DedeLLL commented Apr 5, 2019

Hi @mattfidler @kestrel99 Thanks for your time, I actually used the example from the nlmixr package help document.

> d <- Oral_1CPT
  d <- d[,names(d) != "SS"]
  f <- function(){
    ini({
        lCl <- 1.6     
        lVc <- log(90)   
        lKA <- 0.1     
        prop.err <- c(0, 0.2, 1)
        eta.Cl ~ 0.1 
        eta.Vc ~ 0.1 
        eta.KA ~ 0.1 
    })
    model({
        Cl <- exp(lCl + eta.Cl)
        Vc = exp(lVc + eta.Vc)
        KA <- exp(lKA + eta.KA)
        kel <- Cl / Vc;
        d/dt(depot)    = -KA*depot;
        d/dt(centr)  =  KA*depot-kel*centr;
        cp = centr / Vc;
        cp ~ prop(prop.err)
    })
}
fit.s <-  nlmixr(f,d,est="saem",control=saemControl(n.burn=50,n.em=100,print=50))

The result I got was

Warning message:
In (function (uif, data, est = NULL, control = list(), ..., sum.prod = FALSE,  :
  Bounds are ignored in SAEM

This was the only warning I got.
Then I used

fit.s <- addCwres(fit.s)
a<-xpose_data_nlmixr(fit.s)

I got the error

Error in data.frame(data_a, full.dat) : 
  arguments imply differing number of rows: 6960, 6947`

@DedeLLL
Copy link

DedeLLL commented Apr 5, 2019

Also I tried another dataset from the help document of nlmixr.
fit.s <- nlmixr(f,Bolus_2CPT,est="saem",control=saemControl(n.burn=50,n.em=100))
f is the same model.
a<-xpose_data_nlmixr(fit.s)
I got another error
Error in suppessWarnings(do.call(RxODE:::rxSolve.default, c(list(object = .rx, : could not find function "suppessWarnings"

mattfidler added a commit that referenced this issue Apr 8, 2019
@mattfidler
Copy link
Contributor Author

Hi @DedeLLL ,

I believe your issues have been addressed. Please update RxODE, nlmixr and xpose.nlmixr.

Here is my example and the results:

library(nlmixr)
library(xpose.nlmixr)
#> Loading required package: xpose
#> Loading required package: ggplot2
#> 
#> Attaching package: 'xpose'
#> The following object is masked from 'package:nlmixr':
#> 
#>     vpc
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> 
#> Attaching package: 'xpose.nlmixr'
#> The following object is masked from 'package:nlmixr':
#> 
#>     vpc

d <- Oral_1CPT;
d <- d[d$ID %in% unique(d$ID)[1:12], ]
# d <- d[,names(d) != "SS"] ## SS supported in RxODE/nlmixr now
f <- function(){
    ini({
        lCl <- 1.6
        lVc <- log(90)
        lKA <- 0.1
        prop.err <- c(0, 0.2, 1)
        eta.Cl ~ 0.1
        eta.Vc ~ 0.1
        eta.KA ~ 0.1
    })
    model({
        Cl <- exp(lCl + eta.Cl)
        Vc = exp(lVc + eta.Vc)
        KA <- exp(lKA + eta.KA)
        kel <- Cl / Vc;
        d/dt(depot)    = -KA*depot;
        d/dt(centr)  =  KA*depot-kel*centr;
        cp = centr / Vc;
        cp ~ prop(prop.err)
    })
}

fit.s <-  nlmixr(f,d,est="saem",control=saemControl(n.burn=50,n.em=100,print=50))
#> Warning in (function (uif, data, est = NULL, control = list(), ...,
#> sum.prod = FALSE, : Bounds are ignored in SAEM
#> Compiling RxODE equations...
#> done.
#> 1:    1.8670   4.5645   0.0235   0.0950   0.0964   0.0950   0.5929
#> 50:    1.4771   4.1704   0.0226   0.0873   0.1208   0.1207   0.2014
#> 100:    1.4764   4.1758   0.0076   0.0906   0.1233   0.1194   0.2015
#> 150:    1.4737   4.1723   0.0045   0.0890   0.1263   0.1182   0.2009
#> Calculating residuals/tables
#> done.

xpdb <- xpose_data_nlmixr(fit.s)
#> Calculating residuals/tables
#> done.
#> Warning in xpose_data_nlmixr(fit.s): Added CWRES to fit (using
#> nlmixr::addCwres)

dv_vs_pred(xpdb)

Created on 2019-04-07 by the reprex package (v0.2.1)

@DedeLLL
Copy link

DedeLLL commented Apr 9, 2019

It works! Thanks sooooooo much @mattfidler for your precious time and effort. By the way, I updated all the new packages for macOSX and it also worked really well. (The previous versions could not work on my mac although I checked my clang and gfortran to be the latest version) That is a real bonus!

@mattfidler
Copy link
Contributor Author

Great! I'm glad to hear it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants