-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a42f9d5
commit 0a207cb
Showing
244 changed files
with
36,724 additions
and
760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
Package: NMsim | ||
Type: Package | ||
Title: Seamless 'Nonmem' Simulation Platform | ||
Version: 0.0.6 | ||
Version: 0.0.7 | ||
Authors@R: c(person("Philip", "Delff", email = "philip@delff.dk",role = c("aut","cre")), | ||
person("Matthew","Fidler", role = c("ctb"), email = "matt.fidler@novartis.com", comment="Co-author on NMreadCov")) | ||
Maintainer: Philip Delff <philip@delff.dk> | ||
Description: A complete and seamless 'Nonmem' simulation interface from within R. Turns 'Nonmem' control streams into simulation control streams, executes them with specified simulation input data and returns the results. The simulation is performed by 'Nonmem', eliminating time spent and risks of re-implementation of models in other tools. | ||
License: MIT + file LICENSE | ||
RoxygenNote: 7.2.3 | ||
Depends: R (>= 3.5.0) | ||
Imports: data.table, NMdata (>= 0.1.1), R.utils, MASS | ||
Suggests: testthat, knitr, rmarkdown, fst, dplyr, ggplot2, patchwork, | ||
tibble, tracee, tidyr | ||
Imports: data.table, NMdata (>= 0.1.3), R.utils, MASS, fst | ||
Suggests: testthat, knitr, rmarkdown, dplyr, ggplot2, patchwork, | ||
tibble, tracee, tidyr, tidyvpc | ||
Encoding: UTF-8 | ||
BugReports: https://github.com/philipdelff/NMsim/issues | ||
Language: en-US | ||
URL: https://philipdelff.github.io/NMsim/ | ||
NeedsCompilation: no | ||
Packaged: 2023-11-28 17:08:37 UTC; philipde | ||
Packaged: 2024-01-08 17:18:29 UTC; philipde | ||
Author: Philip Delff [aut, cre], | ||
Matthew Fidler [ctb] (Co-author on NMreadCov) | ||
Repository: CRAN | ||
Date/Publication: 2023-11-28 17:40:13 UTC | ||
Date/Publication: 2024-01-09 00:30:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
##' Read simulation results based on NMsim's track of model runs | ||
##' @param x Path to the simulation-specific rds file generated by | ||
##' NMsim, typically called `NMsim_paths.rds`. Or a table of | ||
##' simulation runs as returned by NMsim when `wait=FALSE`. | ||
##' @param as.fun The default is to return data as a data.frame. Pass | ||
##' a function (say tibble::as_tibble) in as.fun to convert to | ||
##' something else. If data.tables are wanted, use | ||
##' as.fun="data.table". The default can be configured using | ||
##' NMdataConf. | ||
##' @return A data set of class defined by as.fun | ||
##' @import NMdata | ||
##' @import fst | ||
##' @export | ||
|
||
NMreadSim <- function(x,as.fun){ | ||
|
||
. <- NULL | ||
ROWMODEL2 <- NULL | ||
args.NMscanData <- NULL | ||
path.sim.lst <- NULL | ||
|
||
file.res.data <- NULL | ||
|
||
if(missing(as.fun)) as.fun <- NULL | ||
as.fun <- NMdata:::NMdataDecideOption("as.fun",as.fun) | ||
|
||
## when to look for combined and saved results? | ||
|
||
|
||
|
||
## if path is a dir, search for rds | ||
|
||
## if an rds, just read it | ||
if(!is.list(x) && is.character(x)) { | ||
tab.paths <- readRDS(x) | ||
|
||
if(!inherits(tab.paths,"NMsimTab")) { | ||
stop("The provided rds file does not contain a NMsimTab object") | ||
} | ||
file.res.data <- fnAppend(fnExtension(x,"fst"),"res") | ||
} else if(is.NMsimTab(x)){ | ||
tab.paths <- x | ||
} | ||
|
||
## if an lst, read it | ||
if(!is.null(file.res.data) && | ||
file.exists(file.res.data) && | ||
file.mtime(file.res.data)>file.mtime(x)){ | ||
res <- read_fst(file.res.data,as.data.table=TRUE) | ||
} else { | ||
|
||
### read all sim results | ||
if(F){ | ||
## this simple approach may fail if the models return incompatible columns | ||
res <- tab.paths[,{ | ||
cat(ROWMODEL2," ") | ||
## the rds table must keep NMscanData arguments | ||
args.NM <- args.NMscanData[[1]] | ||
if(! "quiet" %in% names(args.NM)){ | ||
args.NM$quiet <- TRUE | ||
} | ||
|
||
do.call(NMscanData,c(list(file=path.sim.lst),args.NM)) | ||
},keyby=.(ROWMODEL2)] | ||
} | ||
|
||
#### must read each model into list elements. Then rbind(fill=T) | ||
### this is to make sure results from different models with | ||
### incompatible columns can be combined. | ||
|
||
res.list <- lapply(split(tab.paths,by="ROWMODEL2"),function(dat){ | ||
dat[,{ | ||
## cat(ROWMODEL2," ") | ||
## the rds table must keep NMscanData arguments | ||
args.NM <- args.NMscanData[[1]] | ||
if(! "quiet" %in% names(args.NM)){ | ||
args.NM$quiet <- TRUE | ||
} | ||
|
||
do.call(NMscanData,c(list(file=path.sim.lst),args.NM)) | ||
},by=.(ROWMODEL2)] | ||
}) | ||
res <- rbindlist(res.list,fill=TRUE) | ||
res[,ROWMODEL2:=NULL] | ||
|
||
if(!is.null(file.res.data)){ | ||
NMwriteData(res,file=file.res.data,formats.write="fst",genText=F) | ||
} | ||
} | ||
|
||
setattr(res,"NMsim-models",tab.paths) | ||
return(as.fun(res)) | ||
} |
Oops, something went wrong.