UUPharmacometrics / xpose4

Model building aid for population analysis using NONMEM
http://uupharmacometrics.github.io/xpose4/
GNU Lesser General Public License v3.0
35 stars 11 forks source link

Crash of dv.preds.vs.idv when WRES missing #10

Open rikardn opened 5 years ago

rikardn commented 5 years ago

I run a simple model (pheno) with the following table:

$TABLE ID MDV TIME DV IPRED PRED RES CWRES NOAPPEND NOPRINT ONEHEADER FILE=sdtab1

Loading into an xpose4 database and doing xpose4::dv.preds.vs.idv(xpdb) caused xpose4 to crash with the following backtrace:

Error in limits.and.aspect(default.prepanel, prepanel = prepanel, have.xlim = have.xlim, : need at least one panel
7.stop("need at least one panel")
6.limits.and.aspect(default.prepanel, prepanel = prepanel, have.xlim = have.xlim, xlim = xlim, have.ylim = have.ylim, ylim = ylim, x.relation = foo$x.scales$relation, y.relation = foo$y.scales$relation, panel.args.common = foo$panel.args.common, panel.args = foo$panel.args, aspect = aspect, npackets = npackets, ...
5.xyplot.formula(formula(formel), data, obj = object, prepanel = function(x, y) { xlim <- NULL ylim <- NULL ...
4.xyplot(formula(formel), data, obj = object, prepanel = function(x, y) { xlim <- NULL ylim <- NULL ...
3.xpose.plot.default(xvardef("idv", object), c(xvardef("dv", object), xvardef("ipred", object), xvardef("pred", object)), object, scales = scales, ylb = ylb, layout = layout, smooth = smooth, ...)
2.xpose4::dv.preds.vs.idv(xpdb)
1.print(xpose4::dv.preds.vs.idv(xpdb))

Adding the column WRES to the $TABLE stops it from crashing.

andrewhooker commented 5 years ago

By default xpose4 expects the 'standard' parameters to be found in NONMEM table output. This includes IWRE, IPRE, TIME, and the NONMEM default items (DV, PRED, RES and WRES) that are added when NOAPPEND is not present in the $TABLE record. If you remove NOAPPEND then your example should work.

WRES is used to filter non-observation rows from NONMEM table files. I suppose that CWRES, if present, could be used instead of WRES in future releases. But currently this is not the case.

rikardn commented 5 years ago

(I guess MDV could be used as well.)

It would be of great help if xpose could give an error message here pointing the user to what is missing.

andrewhooker commented 5 years ago

Yes. Agree. I think there is some good logic in xpose that we can use here (check for EVID as well).