# \donttest{
workshop_fetch("Estimation", output_directory=tempdir(), overwrite=TRUE)
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/analysis_parent.r
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/analysis_parent_metabolite.r
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/analysis_parent_metabolite_global.r
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/analysis_parent_metabolite_nm_data.r
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/system.txt
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/pm_data.csv
-#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmpSYVZMR/nm_data.csv
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/analysis_parent.r
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/analysis_parent_metabolite.r
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/analysis_parent_metabolite_global.r
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/analysis_parent_metabolite_nm_data.r
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/system.txt
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/pm_data.csv
+#> → Creating file: /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//Rtmpms4SZn/nm_data.csv
#> $sources
-#> [1] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/scripts/analysis_parent.r"
-#> [2] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/scripts/analysis_parent_metabolite.r"
-#> [3] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/scripts/analysis_parent_metabolite_global.r"
-#> [4] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/scripts/analysis_parent_metabolite_nm_data.r"
-#> [5] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/systems/system-adapt.txt"
-#> [6] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/csv/pm_data.csv"
-#> [7] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4164f85580/ubiquity/ubinc/csv/nm_data.csv"
+#> [1] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/scripts/analysis_parent.r"
+#> [2] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/scripts/analysis_parent_metabolite.r"
+#> [3] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/scripts/analysis_parent_metabolite_global.r"
+#> [4] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/scripts/analysis_parent_metabolite_nm_data.r"
+#> [5] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/systems/system-adapt.txt"
+#> [6] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/csv/pm_data.csv"
+#> [7] "/private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/Rtmp0OZXtm/temp_libpathf4131265fbf/ubiquity/ubinc/csv/nm_data.csv"
#>
#> $destinations
#> [1] "analysis_parent.r"
diff --git a/docs/search.json b/docs/search.json
index 13a20b2..52fec60 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -1 +1 @@
-[{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Model Deployment","text":"model developed may useful provide easy way run simulations automate specific analyses. , ubiquity provides ShinyApp allows model run easy use interface highly customizable. App can run locally (useful meetings answer quick questions) deployed Shiny server allow others access model. demonstrate interface can begin PK model mAbs humans (Davda etal. mAbs, 6(4), 1094-1102) : Use ?system_new see list available system file examples. building system can create ShinyApp template: create following three files: ubiquity_app.R - Script run control ubiquity ShinyApp server.R - Server script ui.R- UI script","code":"library(ubiquity) system_new(file_name = \"system.txt\", system_file = \"mab_pk\", overwrite = TRUE) cfg = build_system(system_file = \"system.txt\") system_fetch_template(cfg, template = \"ShinyApp\", overwrite = TRUE)"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"running-the-model","dir":"Articles","previous_headings":"","what":"Running the model","title":"Model Deployment","text":"Next simply open ubiquity_app.R RStudio source , RStudio open window associated application. ShinyApp tends work better run within browser. starting App load default dosing file run model. first model output plotted. make changes App, changes reflected user log bottom screen. can change outputs plotted, axis limits, aspects plot using plot controls figure. intent provide quick method get model running default behaviors provide users need. behavior ShinyApp can customized (described ). First discuss default interface:","code":""},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"altering-dosing","dir":"Articles","previous_headings":"Running the model","what":"Altering dosing","title":"Model Deployment","text":"list bolus times values can specified comma-separated values. dose repeated fashion check ``Repeat last dose’’ box, provide dosing interval (units dosing times), give number doses administer. example repeat 400 mg dose every two weeks two doses. Rates infusion specified set switching times corresponding infusion rates (separated commas). infusion rates held constant next switching time. example infuse drug 800mg/min starting time 0, infusion turned (set 0) 30 minutes.","code":""},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"population-simulations","dir":"Articles","previous_headings":"Running the model","what":"Population simulations","title":"Model Deployment","text":"variability system parameters specified (? ?) “Variability” tab visible. Simply check “Simulate variability” box, alter number subjects, prediction interval, elements variance-covariance matrix simulate desired population response. select “Update Plot”, selected output plotted (mean – solid line, selected confidence interval – shaded region).","code":""},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"saving-model-results","dir":"Articles","previous_headings":"","what":"Saving model results","title":"Model Deployment","text":"save model results need provide descriptive name analysis, push save button, click link generated. select time stamp, appended name zip file. default following files saved: analysis_single_dose_400_mg_lib.r, analysis_single_dose_400_mg.r - two files can used recreate results ShinyApp. analysis_single_dose_400_mg_timecourse.png - Time-course simulation results analysis_single_dose_400_mg.csv - Predictions containing timescale model, every state, output analysis_single_dose_400_mg_RX.html - file report (X) specified ubiquity_app.R (See ) system.txt - system file describing model ubiquity_log.txt - log file user done","code":""},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"model-scripts","dir":"Articles","previous_headings":"Saving model results","what":"Model scripts","title":"Model Deployment","text":"files analysis_NAME.r analysis_NAME_lib.r can used two ways. First, two files can used stand-alone files recreate simulation results ShinyApp. Creating Simulation Scripts main script (analysis_NAME.r) can used starting point create simulation scripts. necessary modify First comment sourcing standalone library: Next (script system.txt file) uncommenting following lines force system rebuilt changes system file loaded.","code":"#source(\"analysis_NAME_lib.r\"); if(!require(ubiquity)){ source(file.path('library', 'r_general', 'ubiquity.R')) } cfg = build_system(system_file=\"system.txt\")"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"controlling-what-is-saved","dir":"Articles","previous_headings":"Saving model results","what":"Controlling what is saved","title":"Model Deployment","text":"certain instances may want allow user access everything saved default. edit ubiquity_app.R can alter pushed user setting relevant fields FALSE.","code":"cfg$gui$save$system_txt = TRUE cfg$gui$save$user_log = TRUE"},{"path":[]},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"model-diagram","dir":"Articles","previous_headings":"Model documentation","what":"Model diagram","title":"Model Deployment","text":"can difficult user look set parameters, dosing inputs, outputs determine model works. aid user can useful create model diagram. utilize majority screen space, image roughly twice wide tall. can create image favorite drawing program. Inkscape free vector drawing program available inkscape.org. run following: create file system.svg. can edit save portable network graphics (png) file named system.png directory ubiquity_app.R file. start ShinyApp find file create tab plotting area App.","code":"system_fetch_template(cfg, template=\"Model Diagram\")"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"model-reports","dir":"Articles","previous_headings":"Model documentation","what":"Model reports","title":"Model Deployment","text":"Sometimes need detail annotated model diagram. may need perform calculations based results simulation. may better present information tabulated format. scenarios can create RMarkdown file. Create copy report template (system_report.Rmd) script test (test_system_report.r): called ’ll access ubiquity model object (cfg) simulation results som. simulation results take form deterministic simulation (see output ?run_simulation_ubiquity) , variability checked, stochastic simulation (see output ?simulate_subjects) tell ShinyApp load report (named system_report.Rmd), following lines need added ubiquity_app.R. title field title tab ShinyApp file name file created. can create five reports way, differentiated list name (R1, R2, … R5). file test_system_report.r can used debug model report file. First run model ShinyApp reports disabled. App runs stores state (cfg) current simulation results (som) following data files: cfg \\rightarrow transient/rgui/default/gui_state.RData som \\rightarrow transient/rgui/default/gui_som.RData Next load test script, modify report name accordingly, run : generate report HTML format. can insert debugging commands report test add information. working, can enable report described appear tab viewable user. reports may depend user input. example, RMarkdown file documents modeling assumptions model construction process content change user interacts App. use pre-rendered report simply replace .Rmd .html: tell App read html, prevent rendering report, speed things user.","code":"system_fetch_template(cfg, template=\"Shiny Rmd Report\") cfg$gui$modelreport_files$R1$title = \"Tab Title\" cfg$gui$modelreport_files$R1$file = \"system_report.Rmd\" load(\"transient/rgui/default/gui_som.RData\") load(\"transient/rgui/default/gui_state.RData\") params = list() params$cfg = cfg params$som = som rmarkdown::render(\"system_report.Rmd\", params = params, output_format = \"html_document\") cfg$gui$modelreport_files$R1$title = \"Tab Title\" cfg$gui$modelreport_files$R1$file = \"system_report.html\""},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"user-definable-functions","dir":"Articles","previous_headings":"","what":"User definable functions","title":"Model Deployment","text":"customize simulation plotting within ShinyApp necessary create custom functions. need placed file. example placed mylibs.r main template directory. Lastly, need tell ShinyApp load file. need edit ubiquity_app.R add following line:","code":"cfg$gui$functions$user_def = 'mylibs.r'"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"custom-simulation-commands","dir":"Articles","previous_headings":"User definable functions","what":"Custom simulation commands","title":"Model Deployment","text":"default ShinyApp run simulations using run_simulation_ubiquity (individual) simulate_subjects (population). take inputs parameters vector containing current parameter set changes made interface cfg data structure. can create functions overwrite defining following: Individual Simulations Population Simulations Note order use default plotting functionality functions need return values format default functions individual (run_simulation_ubiquity) population (simulate_subjects) simulations.","code":"cfg$gui$functions$sim_ind = 'function_name(parameters, cfg)' cfg$gui$functions$sim_var = 'function_name(parameters, cfg)'"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"custom-plotting-commands","dir":"Articles","previous_headings":"User definable functions","what":"Custom plotting commands","title":"Model Deployment","text":"customize plotting output need create functions can utilize simulation output som. individual population simulations output run_simulation_ubiquity simulate_subjects, respectively. Unless user-specified simulation functions used. case som can format needed. possible also access parameters vector containing current parameter set changes made interface cfg data structure. can create plotting functions overwrite defining following ubiquity_app.R: Indiviudal Plot Population Plot","code":"cfg$gui$functions$plot_ind = 'function_name(cfg, parameters,som)' cfg$gui$functions$plot_var = 'function_name(cfg, parameters,som)'"},{"path":"https://r.ubiquity.tools/articles/Deployment.html","id":"deployment-on-a-shiny-server","dir":"Articles","previous_headings":"","what":"Deployment on a Shiny Server","title":"Model Deployment","text":"deploy ShinyApp shiny server need indicate modifying ubiquity_app.R changing deploying variable TRUE: ShinyApp needs initialized server. can two ways. First can create empty file called REBUILD needs deployed along side app files. can touch command nat.utils package: force initialization first time app loaded. works well using rsconnect deploy app. Alternatively, can manually sync files run following shiny user server. App fails run Shiny Server check following: Make sure correct packages installed available user Shiny Server running . Make sure ownership permissions server files correct. test deployment can install shinyVM","code":"deploying = TRUE nat.utils::touch(\"REBUILD\") R -e \"source('ubiquity_app.R')\""},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Naive-Pooled Parameter Estimation","text":"workshop (workshop.ubiquity.tools) provides several examples performing parameter estimation ubiquity. make copy scripts supporting files current working directory run following: analysis_parent.r - Least squares estimation single output analysis_parent_metabolite.r - Maximum likelihood estimation two outputs analysis_parent_metabolite_global.r - Using global optimization packages analysis_parent_metabolite_nm_data.r - Reading cohorts NONMEM file scripts build previous one demonstrate different features ubiquity parameter estimation routines. examples use system (shown figure ) contains three differential equations tracking mass parent drug blood (Mpb) tissue space (Mpt). blood parent can form (fmKp) metabolite (Mmb) subsequent elimination (Km). parent/metabolite model adapted ADAPT5 Users Manual (https://bmsr.usc.edu/files/2013/02/ADAPT5-User-Guide.pdf). Using system_new (use ?system_new see list available system file examples) can copy template file current directory build system: system built, can create local copy estimation template system: create file: analysis_estimate.R working directory. beginning script three variables created control script format output. variable analysis_name defines prefix prepended output generated script. Archiving analysis results controlled Boolean variable archive_results. Lastly, script controlled using flowctl variable (possible options listed commented ). estimation script following main components: Select parameter set subset parameters estimate Set options (simulation, estimation, etc) Load datasets Define cohorts Estimate parameters Plot results explored using scripts .","code":"library(ubiquity) fr = workshop_fetch(section=\"Estimation\", overwrite=TRUE) library(ubiquity) system_new(file_name=\"system.txt\", system_file=\"adapt\", overwrite = TRUE) cfg = build_system(system_file = \"system.txt\") system_fetch_template(cfg, template=\"Estimation\")"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"least-squares-estimationsingle-output-analysis_parent-r","dir":"Articles","previous_headings":"","what":"Least squares estimation/single output (analysis_parent.r)","title":"Naive-Pooled Parameter Estimation","text":"first example (analysis_parent.r) begins specifying want perform parameter estimation archive results using name1 parent_d1030 indicate analyzing parent PK 10 30 mg dosing cohorts: Next select parameters estimate. ’re estimating parent data, names parameters relevant parent PK (pnames) selected. estimate parameters simply exclude third argument. system parameters estimated weighted least squares objective used2. Next set options relevant estimation underlying simulation routines. example simulation output times specified, relevant parameters can set. template generated several common options commented . can uncommented modified needed. dataset (shown table ) included ubiquity package accessed using system.file. example script referenced explicitly. format requirements datasets flat files header row. format flexible requires time/observation information columns required filter data isolate cohorts received treatment. inputs defined cohorts defined. Data files loaded using system_load_data() name3 assigned dataset. Data can read files (csv, xls, xlsx, tab) existing data frame. name (pm_data ) used reference dataset later script. dataset column observation time (TIME), subject id (ID), concentrations parent (PT) metabolite (MT), BLQ flag nominal dose (DOSE). columns used (TIME, PT, MT DOSE), others (BQL) ignored. intended example general guide dataset format. necessary different outputs different columns (wide format). dataset loaded tall skinny format well. example going analyze parent data individuals given 10 30 mg using least squares objective. Next need identify data inputs associated data. done defining cohorts, groups data receive treatment model inputs (bolus dosing, infusion rates, covariates) associated cohorts. example define cohort dosing group. make sure starting blank slate can use system_clear_cohorts() remove previously defined information. cohort define list information cohort. cohort unique name field4 dataset field pointing dataset (pm_data) loaded . optional cohort filter (cf) field used reduce entire dataset records associated cohort. See help system_define_cohort() information construct cohort filters. Next necessary define inputs cohort. inputs refers model inputs may include dosing well covariates, estimation template (generated using system_fetch_template() ) contain placeholders defined system file. Note: bolus infusion inputs, necessary define inputs nonzero, covariates necessary define differ definitions system file. input AMT field TIME field units specified system file (AMT TIME internal indentifiers taken dataset). Next need match outputs model outputs dataset. cohort$outputs field used group output. cohort output mapping blood PK parent output Parent. times observations dataset found 'TIME’ column ’PT’ column (missing data specified -1 dropped). mapped model timescale ('hours', specified ) model output (’Cpblood’, specified ). Note units dataset must model: output grouping cohort marker color, shape line type can specified (controlling plotted output). Finally cohort defined using system_define_cohort(): thing 30 mg dose group: cohorts defined call estimation function (system_estimate_parameters()). flowctl set 'plot previous estimate' 'plot guess' values just returned. one estimation options selected flowctl several files generated output folder analysis_name prefix: output/parent_d1030-report.txt - Text file summary estimation results. output/parent_d1030-parameters_all.csv - Summary table parameters (estimated fixed) output/parent_d1030-parameters_est.csv - Summary table estimated parameters output/parent_d1030-system_update.txt - Text update system.txt file new parameter estimates output/parent_d1030-sessionInfo.RData - output sessionInfo() stored SI object data file Next system simulated estimate data stored erp. information variable used generate standard plots , may desirable save information generate figures. necessary understand structure erp. list two different fields. TIME - Time units data OBS - Observations (SMOOTH = FALSE), -1 (SMOOTH=TRUE) PRED - Predictions (SMOOTH = FALSE) VAR - Variance (SMOOTH = FALSE), -1 (SMOOTH=TRUE) SMOOTH - FALSE observation times, TRUE observations OUTPUT - name output COHORT - name cohort ts.time - Simulation time scale ts.TS - entry timescale TS pred - Simulated predictions name - State model output cohort - Cohort name Lastly predictions overlaying data observed vs predicted plots generated using system_plot_cohorts(). Basic formatting figures controlled using plot_opts list (see ?system_plot_cohorts details). called, system_plot_cohorts() write png pdf output time course observed vs predicted files. also return list ggplot objects relative paths files well. example following generated: output/parent_d1030_time course_Parent.pdf output/parent_d1030_time course_Parent.png output/parent_d1030_obs_pred_Parent.pdf output/parent_d1030_obs_pred_Parent.png","code":"flowctl = 'estimate' archive_results = TRUE analysis_name = 'parent_d1030' pnames = c('Vp', 'Vt', 'CLp', 'Q') cfg = system_select_set(cfg, \"default\", pnames) cfg=system_set_option(cfg, group = \"simulation\", option = \"output_times\", seq(0,100,1)) cfg = system_load_data(cfg, dsname = \"pm_data\", data_file = system.file(\"ubinc\", \"csv\", \"pm_data.csv\", package = \"ubiquity\")) cfg = system_clear_cohorts(cfg) cohort = list( name = \"dose_10\", cf = list(DOSE = c(10)), inputs = NULL, outputs = NULL, dataset = \"pm_data\") cohort[[\"inputs\"]][[\"bolus\"]] = list() cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]] = list(TIME=NULL, AMT=NULL) cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"TIME\"]] = c( 0) # hours cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"AMT\"]] = c(10) # mpk cohort[[\"outputs\"]][[\"Parent\"]] = list() # Mapping to data set cohort[[\"outputs\"]][[\"Parent\"]][[\"obs\"]] = list( time = \"TIME\", value = \"PT\", missing = -1) # Mapping to system file cohort[[\"outputs\"]][[\"Parent\"]][[\"model\"]] = list( time = \"hours\", value = \"Cpblood\", variance = \"1\") # Plot formatting cohort[[\"outputs\"]][[\"Parent\"]][[\"options\"]] = list( marker_color = \"black\", marker_shape = 1, marker_line = 2 ) cohort[[\"outputs\"]][[\"Parent\"]][[\"options\"]] = list( marker_color = \"black\", marker_shape = 1, marker_line = 2 ) cfg = system_define_cohort(cfg, cohort) cohort = list( name = \"dose_30\", cf = list(DOSE = c(30)), dataset = \"pm_data\", inputs = NULL, outputs = NULL) # Bolus inputs for the cohort cohort[[\"inputs\"]][[\"bolus\"]] = list() cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]] = list(TIME=NULL, AMT=NULL) cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"TIME\"]] = c( 0) # hours cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"AMT\"]] = c(30) # mpk # Defining Parent output cohort[[\"outputs\"]][[\"Parent\"]] = list() # Mapping to data set cohort[[\"outputs\"]][[\"Parent\"]][[\"obs\"]] = list( time = \"TIME\", value = \"PT\", missing = -1) # Mapping to system file cohort[[\"outputs\"]][[\"Parent\"]][[\"model\"]] = list( time = \"hours\", value = \"Cpblood\", variance = \"1\") # Plot formatting cohort[[\"outputs\"]][[\"Parent\"]][[\"options\"]] = list( marker_color = \"red\", marker_shape = 2, marker_line = 2 ) cfg = system_define_cohort(cfg, cohort) pest = system_estimate_parameters(cfg, flowctl = flowctl, analysis_name = analysis_name, archive_results = archive_results) cfg=system_set_option(cfg, group = \"simulation\", option = \"output_times\", seq(0,100,5)) erp = system_simulate_estimation_results(pest = pest, cfg = cfg) plot_opts = c() plot_opts$outputs$Parent$yscale = 'log' plinfo = system_plot_cohorts(erp, plot_opts, cfg, analysis_name=analysis_name)"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"automated-reporting","dir":"Articles","previous_headings":"Least squares estimation/single output (analysis_parent.r)","what":"Automated Reporting","title":"Naive-Pooled Parameter Estimation","text":"outputs provide components generating presentations documents. Coping pasting figures tables documents can tedious. can convenient automate process accomplished function system_rpt_estimation().","code":""},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"powerpoint","dir":"Articles","previous_headings":"Least squares estimation/single output (analysis_parent.r) > Automated Reporting","what":"PowerPoint","title":"Naive-Pooled Parameter Estimation","text":"append results analysis PowerPoint document simply initialize new report (template=\"PowerPoint\"), call system_rpt_estimation() appropriate analysis_name, results analysis attached slides. save analysis results output directory.","code":"cfg = system_rpt_read_template(cfg, template=\"PowerPoint\") cfg = system_rpt_estimation(cfg=cfg, analysis_name=analysis_name) system_rpt_save_report(cfg=cfg, output_file=file.path(\"output\",paste(analysis_name, \"-report.pptx\", sep=\"\")))"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"word","dir":"Articles","previous_headings":"Least squares estimation/single output (analysis_parent.r) > Automated Reporting","what":"Word","title":"Naive-Pooled Parameter Estimation","text":"process Word document . Just make sure template set \"Word\" report initialized: information integrated report generation see Reporting vignette.","code":"cfg = system_rpt_read_template(cfg, template=\"Word\") cfg = system_rpt_estimation(cfg=cfg, analysis_name=analysis_name) system_rpt_save_report(cfg=cfg, output_file=file.path(\"output\",paste(analysis_name, \"-report.docx\", sep=\"\")))"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"maximum-likelihoodtwo-outputs-analysis_parent_metabolite-r","dir":"Articles","previous_headings":"","what":"Maximum likelihood/two outputs (analysis_parent_metabolite.r)","title":"Naive-Pooled Parameter Estimation","text":"example similar last except analyzing two different outputs (parent metabolite) proportional variance model. now can estimate parameters associated outputs well variance parameters: parameters estimated contain variance parameters (slope_parent slope_metabolite) maximum likelihood objective used. cohort definitions look much except variance model defined 'slope_parent*PRED^2', separate output named Metabolite. Similar modifications made 30 mg dosing cohort. Note: variance model can speified system.txt file using descriptor. specify variance cohort definition value system file used. specified either location default value (PRED^2) used.","code":"pnames = c('Vp', 'Vt', 'Vm', 'CLp', 'Q', 'CLm', 'slope_parent', 'slope_metabolite'); cfg = system_select_set(cfg, \"default\", pnames) cohort = list( name = \"dose_10\", cf = list(DOSE = c(10)), inputs = NULL, outputs = NULL, dataset = \"pm_data\") # Bolus inputs for the cohort cohort[[\"inputs\"]][[\"bolus\"]] = list() cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]] = list(TIME=NULL, AMT=NULL) cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"TIME\"]] = c( 0) # hours cohort[[\"inputs\"]][[\"bolus\"]][[\"Mpb\"]][[\"AMT\"]] = c(10) # mpk # Defining Parent output cohort[[\"outputs\"]][[\"Parent\"]] = list() # Mapping to data set cohort[[\"outputs\"]][[\"Parent\"]][[\"obs\"]] = list( time = \"TIME\", value = \"PT\", missing = -1) # Mapping to system file cohort[[\"outputs\"]][[\"Parent\"]][[\"model\"]] = list( time = \"hours\", value = \"Cpblood\", variance = \"slope_parent*PRED^2\") # Plot formatting cohort[[\"outputs\"]][[\"Parent\"]][[\"options\"]] = list( marker_color = \"black\", marker_shape = 1, marker_line = 1 ) # Defining Metabolite output cohort[[\"outputs\"]][[\"Metabolite\"]] = list() # Mapping to data set cohort[[\"outputs\"]][[\"Metabolite\"]][[\"obs\"]] = list( time = \"TIME\", value = \"MT\", missing = -1) # Mapping to system file cohort[[\"outputs\"]][[\"Metabolite\"]][[\"model\"]] = list( time = \"hours\", value = \"Cmblood\", variance = \"slope_metabolite*PRED^2\") # Plot formatting cohort[[\"outputs\"]][[\"Metabolite\"]][[\"options\"]] = list( marker_color = \"blue\", marker_shape = 1, marker_line = 1 ) cfg = system_define_cohort(cfg, cohort)"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"global-estimation-routines-analysis_parent_metabolite_global-r","dir":"Articles","previous_headings":"","what":"Global estimation routines (analysis_parent_metabolite_global.r)","title":"Naive-Pooled Parameter Estimation","text":"Now build previous example demonstrate select different optimization routines. default, parameter estimation carried using Nelder-Mead optimization method optim library. can specify different functions library. See documentation optim (?optim) valid values method elements control. example, use simulated annealing change method SANN. also global optimization libraries R, two can readily used ubiquity: Particle Swarm Optimizer (pso package) Genetic Algorithms (GA package). use pso package set following options: use GA package set following options: Note: Optimizers like SANN global optimizers (pso GA) good identifying parameter sets outside region initial guess. However, one consequence algorithms can quickly approach bounds. Consequently important provide realistic upper lower bounds parameters ( descriptor system file using system_set_guess() scripting level). use default value machine precision (eps) lower bound infinity (Inf) upper bound optimization routines can choose parameter values can cause internal simulations fail.","code":"cfg = system_set_option(cfg, group = \"estimation\", option = \"method\", value = \"SANN\") library(pso) cfg = system_set_option(cfg, group = \"estimation\", option = \"optimizer\", value = \"pso\") cfg = system_set_option(cfg, group = \"estimation\", option = \"method\", value = \"psoptim\") library(GA) cfg = system_set_option(cfg, group = \"estimation\", option = \"optimizer\", value = \"ga\") cfg = system_set_option(cfg, group = \"estimation\", option = \"method\", value = \"ga\") cfg = system_set_option(cfg, group = \"estimation\", option = \"control\", value = list(maxiter = 10000, optimArgs = list(method = \"Nelder-Mead\", maxiter = 1000)))"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"cohorts-from-nonmem-dataset-analysis_parent_metabolite_nm_data-r","dir":"Articles","previous_headings":"","what":"Cohorts from NONMEM dataset (analysis_parent_metabolite_nm_data.r)","title":"Naive-Pooled Parameter Estimation","text":"examples , cohorts defined manually. Sometimes may data NONMEM dataset dosing information located dataset. may convenient simply define cohort subject dataset. function system_define_cohorts_nm can used. differences script analysis_parent_metabolite.r now highlighted: First load NONMEM dataset clear cohorts: Next define filter use dataset (include 10 30 mg doses): information filtering datasets see help nm_select_records(). Now define maps different outputs. output specify variance, compartment (CMT) number, model output missing number flag: Lastly define map model inputs. case bolus Mpb compartment: Unused columns dataset ignored. filter, input observation maps defined, now add cohorts","code":"cfg = system_load_data(cfg, dsname = \"nm_pm_data\", data_file = system.file(\"ubinc\", \"csv\", \"nm_data.csv\", package = \"ubiquity\")) cfg = system_clear_cohorts(cfg); filter = list() filter$DOSE = c(10, 30) OBSMAP = list() OBSMAP$PT = list(variance = 'slope_parent*PRED^2', CMT = 1, output = 'Cpblood', missing = -1 ) OBSMAP$MT = list(variance = 'slope_metabolite*PRED^2', CMT = 2, output = 'Cmblood', missing = -1 ) INPUTMAP = list() INPUTMAP$bolus$Mpb$CMT_NUM = 1 cfg = system_define_cohorts_nm(cfg, DS = 'nm_pm_data', col_ID = 'ID', col_CMT = 'CMT', col_DV = 'DV', col_TIME = 'TIME', col_AMT = 'AMT', col_RATE = 'RATE', col_EVID = 'EVID', col_GROUP= 'DOSE', filter = filter, INPUTS = INPUTMAP, OBS = OBSMAP, group = FALSE)"},{"path":"https://r.ubiquity.tools/articles/Estimation.html","id":"contents-of-system-txt","dir":"Articles","previous_headings":"","what":"Contents of system.txt","title":"Naive-Pooled Parameter Estimation","text":"","code":"# # Parent/Metabolite example taken from Section 9.3 of the ADAPT5 Users Manual # # https://bmsr.usc.edu/files/2013/02/ADAPT5-User-Guide.pdf #
Vp 10.0 1e-5 100 L yes System
Vt 10.0 1e-5 100 L yes System
Vm 30.0 1e-5 100 L yes System
CLp 1.0 1e-5 100 L/hr yes System
CLm 1.0 1e-5 100 L/hr yes System
Q 0.3 1e-5 100 L/hr yes System Original Estimates slope_parent 0.1 1e-9 10 -- no Variance slope_metabolite 0.1 1e-9 10 -- no Variance ; [ 0 ]; 1; hours ; Mpb; [ 0 ]; 70; mpk -(CLp/Vp + Q/Vp)*Mpb + Q/Vt*Mpt Q/Vp*Mpb - Q/Vt*Mpt CLp/Vp*Mpb - CLm/Vm*Mmb Cpblood = Mpb/Vp Cmblood = Mmb/Vm 1.0 1.0/24.0 0.08 Vp 0.08 Vt 0.08 CLp 0.08 CLm SIMINT_SEQ[0][100][1] "},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"working-with-rxode2-nlmixr2-nonmem-and-monolix","dir":"Articles","previous_headings":"","what":"Working with rxode2, nlmixr2, NONMEM, and Monolix","title":"Howtos","text":"Say model ubiquity want use nlmixr2. perhaps want try simulation engine rxode2, want hand model someone using Monolix. provide way easily convert model different formats automated fashion.","code":""},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"getting-your-model-in-rxode2-format","dir":"Articles","previous_headings":"Working with rxode2, nlmixr2, NONMEM, and Monolix","what":"Getting your model in rxode2 format","title":"Howtos","text":"example consider system file two compartment model (system_2cmt.txt ). build system rxode2 output target created. can use system_fetch_template() function access file. ’m placing script temporary directory. script generate rxode2 model function store function object my_model. default input nlmixr2. can use function piping methodology things like add IIV terms parameters. can use ubiquity build structural model piping, rxode2, nlmixr2 analysis. can see contents system_nlmixr2.R my_model object looks like . Note include output ubiquity need error model. along Descriptor need define variance parameters () also output error model ().","code":"cfg = build_system(system_file = sf_2cmt_full, temporary_directory = file.path(tempdir(), \"transient\")) fr = system_fetch_template(cfg, template = \"nlmixr2\", output_directory = tempdir(), overwrite = TRUE) library(rxode2) source(file.path(tempdir(), \"system_nlmixr2.R\"))"},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"getting-your-model-in-nonmem-format","dir":"Articles","previous_headings":"Working with rxode2, nlmixr2, NONMEM, and Monolix","what":"Getting your model in NONMEM format","title":"Howtos","text":"model rxode2 format can convert NONMEM format babelmixr2 package (via ruminate package). need least one inter-individual variability term. can system file delimiter. example using model piping. specify typical value Vc, parameter TV_Vc, error lognormally distributed. add IIV term eta_Vc. Next just need load ruminate package (>=0.2.4) use rx2other() function create NONMEM control stream:","code":"my_model = my_model |> model({Vc = exp(TV_Vc + eta_Vc)}) library(ruminate) my_model_nm = rx2other(my_model, out_type=\"nonmem\")"},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"getting-your-model-in-monolix-format","dir":"Articles","previous_headings":"Working with rxode2, nlmixr2, NONMEM, and Monolix","what":"Getting your model in Monolix format","title":"Howtos","text":"can also get model Monolix specifying monolix output type:","code":"my_model_mlx = rx2other(my_model, out_type=\"monolix\")"},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"further-reading","dir":"Articles","previous_headings":"Working with rxode2, nlmixr2, NONMEM, and Monolix","what":"Further reading","title":"Howtos","text":"discussion topic see following: https://github.com/nlmixr2/babelmixr2/issues/107","code":""},{"path":"https://r.ubiquity.tools/articles/Howto.html","id":"models-in-different-formats","dir":"Articles","previous_headings":"Working with rxode2, nlmixr2, NONMEM, and Monolix","what":"Models in different formats","title":"Howtos","text":"ubiquity rxode2 script rxode2 object NONMEM Monolix Contents system_2cmt.txt file: Contents system_nlmixr2.R file produced system_fetch_template(): my_model object: file containing control stream found : my_model_nm$files$ctl$fn_full. file containing mlxtran output found : my_model_mlx$files$mlxtran$fn_full","code":"# Two compartment model with absorption compartment (At). The central # compartment (Cc) had a volume (Vc), and the tissue compartment (Cp) has a # volume (Vt). The system is parameterized in terms of macro constants (Q and # CL) # # While the the default dosing is a 1 mg IV dose into the central compartment, # the model is written to accept dosing into an absorption compartment and # through continuous IV infusion. # _________ # | | # | At | # | | # |_________| # | # | ka, fb # | # V # _________ _________ # | | Q | | # | Cc |------>| Cp | # | Vc |<------| Vt | # |_________| |_________| # | # | CL # | # V # # System Units: # # mass [=] mg # volume [=] ml # concentration [=] mg/ml # time [=] hr # #-------------# # | Parameters | # #-------------# # # System parameters # name value lower upper units editable grouping # bound bound Vc 1.0 eps Inf ml yes System
Vt 1.0 eps Inf ml yes System
CL 1.0 eps Inf ml/hr yes System
Q 1.0 eps Inf ml/hr yes System
ka 1.0 eps Inf 1/hr yes System
fb 1.0 eps Inf -- yes System # Bolus Events # ------------ # times/events state values scale units ; [ 0 ]; 1; hours ; Cc; [1.0 ]; 1/Vc; mg ; At; [0.0 ]; 1; mg # Infusion Rates # ------------ # name time/levels values scale units ; times; [0]; 1; hours ; levels; [0]; 1; mg/hour -ka*At ka*At*fb/Vc - CL/Vc*Cc -Q*(Cc-Cp)/Vc + Dinf/Vc +Q*(Cc-Cp)/Vt Cc_mg_ml = Cc prop_err 0.1 eps inf -- yes Variance add_err 0.1 eps inf ng/ml yes Variance add=add_err; prop=prop_err 1.0 1.0/24 # # # my_model <- function() { ini({ # Typical Value of System Parameters TV_Vc = c(.Machine$double.eps, 1.0, Inf) TV_Vt = c(.Machine$double.eps, 1.0, Inf) TV_CL = c(.Machine$double.eps, 1.0, Inf) TV_Q = c(.Machine$double.eps, 1.0, Inf) TV_ka = c(.Machine$double.eps, 1.0, Inf) TV_fb = c(.Machine$double.eps, 1.0, Inf) # Between-subject variability: # Error model parameters prop_err = c(.Machine$double.eps, 0.1, .Machine$double.xmax) add_err = c(.Machine$double.eps, 0.1, .Machine$double.xmax) }) model({ # System Parameters Vc = TV_Vc Vt = TV_Vt CL = TV_CL Q = TV_Q ka = TV_ka fb = TV_fb # Placeholders for infusion rates. # These should be defined in the dataset. # time scale: 1 units: (hours) # mass scale: 1 units: (mg/hour) Dinf = 0.0 # Defining ODEs d/dt(At) = (-ka*At) d/dt(Cc) = (ka*At*fb/Vc - CL/Vc*Cc -Q*(Cc-Cp)/Vc + Dinf/Vc) d/dt(Cp) = (+Q*(Cc-Cp)/Vt) # Outputs and error models Cc_mg_ml = Cc Cc_mg_ml ~ prop(prop_err) + add(add_err) }) }
[36m──
[39m
[1mrxode2-based free-form 3-cmt ODE model
[22m
[36m──────────────────────────────────────
[39m ──
[1m
[1mInitalization:
[1m
[22m ──
[1mFixed Effects
[22m (
[1m
[34m$theta
[39m
[22m): TV_Vc TV_Vt TV_CL TV_Q TV_ka TV_fb prop_err add_err 1.0 1.0 1.0 1.0 1.0 1.0 0.1 0.1
[1mOmega
[22m (
[1m
[34m$omega
[39m
[22m): eta_Vc eta_Vc 1
[1m States
[22m (
[1m
[34m$state
[39m
[22m or
[1m
[34m$stateDf
[39m
[22m): Compartment Number Compartment Name 1 1 At 2 2 Cc 3 3 Cp ──
[1m
[1m
[1m
[1mμ-referencing
[1m
[1m (
[1m
[1m
[34m$muRefTable
[39m
[1m
[1m):
[1m
[22m ── theta eta level 1 TV_Vc eta_Vc id ──
[1m
[1mModel (Normalized Syntax):
[1m
[22m ── function() { ini({ TV_Vc <- c(2.22044604925031e-16, 1) TV_Vt <- c(2.22044604925031e-16, 1) TV_CL <- c(2.22044604925031e-16, 1) TV_Q <- c(2.22044604925031e-16, 1) TV_ka <- c(2.22044604925031e-16, 1) TV_fb <- c(2.22044604925031e-16, 1) prop_err <- c(2.22044604925031e-16, 0.1) add_err <- c(2.22044604925031e-16, 0.1) eta_Vc ~ 1 }) model({ Vc <- exp(TV_Vc + eta_Vc) Vt = TV_Vt CL = TV_CL Q = TV_Q ka = TV_ka fb = TV_fb Dinf = 0 d/dt(At) = (-ka * At) d/dt(Cc) = (ka * At * fb/Vc - CL/Vc * Cc - Q * (Cc - Cp)/Vc + Dinf/Vc) d/dt(Cp) = (+Q * (Cc - Cp)/Vt) Cc_mg_ml = Cc Cc_mg_ml ~ prop(prop_err) + add(add_err) }) } $PROBLEM translated from babelmixr2 ; comments show mu referenced model in ui$getSplitMuModel $DATA my_model.csv IGNORE=@ $INPUT ID TIME EVID AMT DV CMT RXROW $SUBROUTINES ADVAN13 TOL=6 ATOL=12 SSTOL=6 SSATOL=12 $MODEL NCOMPARTMENTS=3 COMP(AT, DEFDOSE) ; At COMP(CC) ; Cc COMP(CP) ; Cp $PK MU_1=THETA(1) VC=DEXP(MU_1+ETA(1)) ; Vc <- exp(TV_Vc) VT=THETA(2) ; Vt <- TV_Vt CL=THETA(3) ; CL <- TV_CL RXR1=THETA(4) ; Q <- TV_Q KA=THETA(5) ; ka <- TV_ka FB=THETA(6) ; fb <- TV_fb $DES DINF=0 ; Dinf = 0 DADT(1) = (- KA*A(1)) ; d/dt(At) = (-ka * At) DADT(2) = (KA*A(1)*FB/VC-CL/VC*A(2)-RXR1*(A(2)-A(3))/VC+DINF/VC) ; d/dt(Cc) = (ka * At * fb/Vc - CL/Vc * Cc - Q * (Cc - Cp)/Vc + Dinf/Vc) DADT(3) = (RXR1*(A(2)-A(3))/VT) ; d/dt(Cp) = (Q * (Cc - Cp)/Vt) CC_MG_ML=A(2) ; Cc_mg_ml = Cc $ERROR ;Redefine LHS in $DES by prefixing with on RXE_ for $ERROR RXE_DINF=0 ; Dinf = 0 RXE_CC_MG_ML=A(2) ; Cc_mg_ml = Cc RX_PF1=RXE_CC_MG_ML ; rx_pf1 ~ Cc_mg_ml ; Write out expressions for ipred and w RX_IP1 = RX_PF1 RX_P1 = RX_IP1 W1=DSQRT((THETA(8))**2+(RX_PF1)**2*(THETA(7))**2) ; W1 ~ sqrt((add_err)^2 + (rx_pred_f_)^2 * (prop_err)^2) IF (W1 .EQ. 0.0) W1 = 1 IPRED = RX_IP1 W = W1 Y = IPRED + W*EPS(1) $THETA (2.2204e-16, 1 ) ; 1 - TV_Vc (2.2204e-16, 1 ) ; 2 - TV_Vt (2.2204e-16, 1 ) ; 3 - TV_CL (2.2204e-16, 1 ) ; 4 - TV_Q (2.2204e-16, 1 ) ; 5 - TV_ka (2.2204e-16, 1 ) ; 6 - TV_fb (2.2204e-16, 0.1) ; 7 - prop_err (2.2204e-16, 0.1) ; 8 - add_err $OMEGA 1 ; eta_Vc $SIGMA 1 FIX $ESTIMATION METHOD=1 INTER MAXEVALS=100000 SIGDIG=3 SIGL=12 PRINT=1 NOABORT $COVARIANCE $TABLE ID ETAS(1:LAST) OBJI FIRSTONLY ONEHEADER NOPRINT FORMAT=s1PE17.9 NOAPPEND FILE=my_model.eta $TABLE ID TIME IPRED PRED RXROW ONEHEADER NOPRINT FORMAT=s1PE17.9 NOAPPEND FILE=my_model.pred [FILEINFO] file='my_model-monolix.csv' delimiter = comma header = {ID, TIME, EVID, AMT, DV, ADM, nlmixrRowNums} [CONTENT] ID = {use=identifier} TIME = {use=time} EVID = {use=eventidentifier} AMT = {use=amount} DV = {use=observation, name=rx_prd_Cc_mg_ml, type=continuous} ADM = {use=administration} [INDIVIDUAL] input={Vc_pop, omega_Vc, Vt_pop, CL_pop, Q_pop, ka_pop, fb_pop} DEFINITION: Vc = {distribution=logNormal, typical=Vc_pop, sd=omega_Vc} Vt = {distribution=normal, typical=Vt_pop, no-variability} CL = {distribution=normal, typical=CL_pop, no-variability} Q = {distribution=normal, typical=Q_pop, no-variability} ka = {distribution=normal, typical=ka_pop, no-variability} fb = {distribution=normal, typical=fb_pop, no-variability} [LONGITUDINAL] input={add_err, prop_err} file='my_model-monolix.txt' DEFINITION: rx_prd_Cc_mg_ml={distribution = normal, prediction = rx_pred_Cc_mg_ml, errorModel=combined2(add_err,prop_err)} data={rx_prd_Cc_mg_ml} model={rx_prd_Cc_mg_ml} Vc_pop={value=2.71828182845905, method=MLE} Vt_pop={value=1, method=MLE} CL_pop={value=1, method=MLE} Q_pop={value=1, method=MLE} ka_pop={value=1, method=MLE} fb_pop={value=1, method=MLE} prop_err={value=0.1, method=MLE} add_err={value=0.1, method=MLE} omega_Vc={value=1, method=MLE} [TASKS] populationParameters() individualParameters(method = {conditionalMode}) fim(method = StochasticApproximation) logLikelihood(method = ImportanceSampling) plotResult(method = {outputplot, indfits, obspred, residualsscatter, residualsdistribution, parameterdistribution, covariatemodeldiagnosis, randomeffects, covariancemodeldiagnosis, saemresults}) [SETTINGS] GLOBAL: exportpath = 'my_model-monolix' POPULATION: exploratoryautostop = no smoothingautostop = no burniniterations = 5 exploratoryiterations = 250 simulatedannealingiterations = 250 smoothingiterations = 200 exploratoryalpha = 0 exploratoryinterval = 200 omegatau = 0.95 errormodeltau = 0.95"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Analysis of Static Systems, an In Vitro Example","text":"tutorial requires ubiquity 2.04 greater. Currently available using development version github Sometimes need analyze data independent variable time. can ubiquity tutorial highlight done. done already, please review naive-pooled parameter estimation tutorial build concepts covered . workshop (workshop.ubiquity.tools) provides example analyize static vitro data. make copy scripts supporting files current working directory run following: create following files current working direcotry: system-in_vitro.txt - System file can run vivo vitro in_vitro_er_data.csv- vitro data file mk_data_in_vitro.R- Script generate vitro data analysis_in_vitro.R- Script perform parameter estimation using vitro data example uses system Chakraborty Jusko. J Pharm Sci 91(5), 1334-1342. Specifically equation 5 article effect two drugs, B, driven concentrations (C_A, C_B): E = 100 \\left( 1- \\frac{ \\frac{I_{max,}(C_A) ^{\\gamma_A}}{(\\Psi IC_{50,})^{\\gamma_A}} + \\frac{I_{max,B}(\\xi C_B)^{\\gamma_B}}{(\\Psi IC_{50,B})^{\\gamma_B}} \\\\ + (I_{max,} + I_{max,B} + I_{max,} I_{max,B}) \\\\ \\times \\frac{(C_A) ^{\\gamma_A}}{(\\Psi IC_{50,})^{\\gamma_A}} \\times \\frac{(\\xi C_B)^{\\gamma_B}}{(\\Psi IC_{50,B})^{\\gamma_B}} \\\\ }{ \\frac{(C_A) ^{\\gamma_A}}{(\\Psi IC_{50,})^{\\gamma_A}} + \\frac{(\\xi C_B)^{\\gamma_B}}{(\\Psi IC_{50,B})^{\\gamma_B}} \\\\ +\\frac{(C_A) ^{\\gamma_A}}{(\\Psi IC_{50,})^{\\gamma_A}} \\times \\frac{(\\xi C_B)^{\\gamma_B}}{(\\Psi IC_{50,B})^{\\gamma_B}} +1 } \\right) \\xi = \\frac{IC_{50,}}{IC_{50,B}} implemented PKPD system file (system-in_vitro.txt) shown bottom. implementation dynamic meaning effect changes PK drug. However effect considered instantaneous typically analyzed vitro data using algebraic relationships. system consider following data: concentrations drug B altered (independent variable) Effect measured (dependent variable).","code":"library(ubiquity) fr = workshop_fetch(section=\"In Vitro\", overwrite=TRUE)"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"the-sysem-file-system-in_vitro-txt","dir":"Articles","previous_headings":"","what":"The sysem file: system-in_vitro.txt","title":"Analysis of Static Systems, an In Vitro Example","text":"First lets discuss way system file structured. bolus dosing PK specified, initial conditions effect compartments also defined terms system parameters: system parameters (C_A0 C_B0) default value zero. default system run like vivo PKPD system. initial condition placeholders used performing vitro analyses. allows use system file vitro vivo analyses. useful static vitro analysis one system file copy paste vivo dynamic system.","code":" Cp_A = C_A0 Cp_B = C_B0"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"the-dataset-in_vitro_er_data-csv","dir":"Articles","previous_headings":"","what":"The dataset: in_vitro_er_data.csv","title":"Analysis of Static Systems, an In Vitro Example","text":"table contains snapshot relevant columns dataset: C_A0 C_B0 Effect treat samp_time 0.001 0.1 102.15401 A_0_001_B_0_1 1 0.001 0.1 100.78589 A_0_001_B_0_1 1 0.001 0.1 91.14621 A_0_001_B_0_1 1 0.001 100 93.38012 A_0_001_B_100 1 0.001 100 91.03467 A_0_001_B_100 1 0.001 100 86.20118 A_0_001_B_100 1 0.001 500 51.76744 A_0_001_B_500 1 0.001 500 48.95016 A_0_001_B_500 1 0.001 500 52.68611 A_0_001_B_500 1 0.001 1000 28.46122 A_0_001_B_1000 1 C_A0 C_B0 columns correspond concentrations elicit Effect. treat column unique name combination two drug concentrations. letters numbers underscores. intentional can use cohort name ’m constructing estimation script . samp_time column set 1. arbitrary mapping cohort definitions requires time column. ’ll see arbitrary .","code":""},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"the-analysis-script-analysis_in_vitro-r","dir":"Articles","previous_headings":"","what":"The analysis script: analysis_in_vitro.R","title":"Analysis of Static Systems, an In Vitro Example","text":"analysis scripts aspects unique vitro analysis performed.","code":""},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"output-times","dir":"Articles","previous_headings":"The analysis script: analysis_in_vitro.R","what":"Output times","title":"Analysis of Static Systems, an In Vitro Example","text":"First output times. run simulations (happens performing parameter estimation) output times results slower simulations. important include ncesssary output times. case two output times (0 1): final value 1 chosen corresponds time column (samp_time) analysis dataset.","code":"cfg=system_set_option(cfg, group = \"simulation\", option = \"output_times\", seq(0,1,1))"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"making-a-dynamic-simulation-static","dir":"Articles","previous_headings":"The analysis script: analysis_in_vitro.R","what":"Making a dynamic simulation static:","title":"Analysis of Static Systems, an In Vitro Example","text":"Next set simulation option dynamic FALSE: fix values differential equations 0 purposes subsequent simulations. available ubiquity version \\ge 2.04.","code":"cfg=system_set_option(cfg, group = \"simulation\", option = \"dynamic\", value = FALSE)"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"datasets","dir":"Articles","previous_headings":"The analysis script: analysis_in_vitro.R","what":"Datasets","title":"Analysis of Static Systems, an In Vitro Example","text":"dataset reading dataframe loading way. done dataset used internally ubiqiuty also construct analysis :","code":"er_data = readr::read_csv(\"in_vitro_er_data.csv\") cfg = system_load_data(cfg, dsname = \"er_data\", data_file = er_data)"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"defining-cohorts","dir":"Articles","previous_headings":"The analysis script: analysis_in_vitro.R","what":"Defining cohorts","title":"Analysis of Static Systems, an In Vitro Example","text":"estimation tutorial cohorts defined individually. rather tedious. See need cohort every unique combination C_A0 C_B0 dataset. going loop unique value treat column create cohort. variable tmp_treat contains value current treatment first thing get records current treatment: subset data used define initial condition parameters current cohort using cp field (see help system_define_cohort() information option). way treat column constructed can use cohort name. allow us link simulated output original dataset post processing section . inputs set NULL change dosing. set simulation option dynamic FALSE, initial condition set values current treatment, inputs, system effectively behaving like vitro system.","code":"treat_recs = dplyr::filter(er_data, treat == tmp_treat) cohort = list( name = tmp_treat, cf = list( treat = c(tmp_treat)), cp = list( C_A0 = treat_recs$C_A0[1], C_B0 = treat_recs$C_B0[1]), inputs = NULL, outputs = NULL, dataset = \"er_data\")"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"postprocessing","dir":"Articles","previous_headings":"The analysis script: analysis_in_vitro.R","what":"Postprocessing","title":"Analysis of Static Systems, an In Vitro Example","text":"rely normal figure generation reporting elements. example can take simulated output estimation erp original data dataset er_data create meaningful diagnostic plots. can link two datasets using treat column original dataset COHORT column erp$pred:","code":"df_orig = er_data |> dplyr::select(C_A0, C_B0, ave_eff, treat) |> dplyr::distinct() df_est = erp$pred |> dplyr::filter(!SMOOTH) |> dplyr::rename(treat = COHORT) df_plot = dplyr::full_join(df_est, df_orig, by=\"treat\") |> dplyr::mutate(C_B0 = as.factor(C_B0)) library(ggplot2) p = ggplot(data=df_plot) + geom_point(aes(x=C_A0, y=OBS, group=C_B0, color=C_B0)) + geom_line(aes(x=C_A0, y=PRED, group=C_B0, color=C_B0)) + scale_x_log10()"},{"path":"https://r.ubiquity.tools/articles/In_Vitro.html","id":"contents-of-system-in_vitro-txt","dir":"Articles","previous_headings":"","what":"Contents of system-in_vitro.txt","title":"Analysis of Static Systems, an In Vitro Example","text":"","code":"# Author: John Harrold # # Analysis of an in vitro system. The system below was taken from: # # Chakraborty A, Jusko WJ. Pharmacodynamic interaction of recombinant human # interleukin-10 and prednisolone using in vitro whole blood lymphocyte # proliferation. J Pharm Sci. 2002 May;91(5):1334-42. doi: 10.1002/jps.3000. # PMID: 11977109. # # #-------------# # | Parameters | # #-------------# # # System parameters # name value lower upper units editable grouping # bound bound IC50_A 1.0 eps Inf ----- yes Efficacy
IC50_B 50.0 eps Inf ----- yes Efficacy
Imax_A 1.0 eps Inf ----- yes Efficacy
Imax_B 1.0 eps Inf ----- yes Efficacy
PSI 10.0 eps Inf ----- yes Efficacy
G_A 0.6 eps Inf ----- yes Efficacy
G_B 1.4 eps Inf ----- yes Efficacy
Vp_A 1.0 eps Inf ml yes PK
CL_A 1.0 eps Inf ml/hr yes PK
Vp_B 1.0 eps Inf ml yes PK
CL_B 1.0 eps Inf ml/hr yes PK
C_A0 0.0 eps Inf ----- yes IC
C_B0 0.0 eps Inf ----- yes IC # #-------------------# # |Input Information | # #-------------------# # # Bolus Events # ------------ # times/events state values scale units ; [ 0 ]; 1.0; hours ; Cp_A; [1.0 ]; 1.0/Vp_A; mg ; Cp_B; [1.0 ]; 1.0/Vp_B; mg # By default these values are zero but can be overwritten when # doing analysis of in vitro data. Cp_A = C_A0 Cp_B = C_B0 XI = IC50_A/IC50_B COMP_A = SIMINT_POWER[Cp_A][G_A]/(SIMINT_POWER[PSI*IC50_A][G_A]) COMP_B = SIMINT_POWER[XI*Cp_B][G_B]/(SIMINT_POWER[PSI*IC50_A][G_B]) COMP_Imax = Imax_A + Imax_B - Imax_A*Imax_B EFF_num = Imax_A*COMP_A + Imax_B*COMP_B + COMP_Imax*COMP_A*COMP_B EFF_den = COMP_A + COMP_B + COMP_A*COMP_B + 1.0 EFF = 100.0*(1.0-EFF_num/EFF_den) # #-----------------------------# # | ODEs, and State Information | # #-----------------------------# CL_A/Vp_A*Cp_A CL_B/Vp_B*Cp_B # #---------# # | Outputs | # #---------# Cp_A_mg_ml = Cp_A Cp_B_mg_ml = Cp_B Effect = EFF # prop_err 1.0 eps Inf ----- yes IC # prop=prop_err # #---------# # | Options # # #---------# # specify different time scales 1.0"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Modeling Language","text":"core, ubiquity modeling language set scripts meant facilitate model development deployment. focus document model description language. plain text file, referred system file. line contains descriptor (e.g. ) defines aspect model, comments made hash sign (#). follows overview different components language can used create system file.","code":""},{"path":[]},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"system-parameters-p","dir":"Articles","previous_headings":"Parameters","what":"System parameters
","title":"Modeling Language","text":"system parameter specified name, value, lower bound, upper bound, units, whether editable ShinyApp ‘type’ parameter (grouping ShinyApp). values eps (machine precision, smallest value zero) inf (infinity) can used. example specify parameter koffR value .1 positive parameter KDR value .04 also positive following used:","code":"# name value lb ub units editable type
koffR 0.1 eps inf 1/hr yes Target
KDR 0.04 eps inf nM yes Target"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"parameter-sets","dir":"Articles","previous_headings":"Parameters","what":"Parameter sets","title":"Modeling Language","text":"Often model developed incorporate different situations scenarios. example, model may used describe healthy diseased individuals. differences simply parametric nature, can cumbersome code model multiple times (parameterization). framework provides mechanism including multiple parameterizations withing system file. Consider system want describe antibody disposition. humans described two compartment model, mice single compartment needed. First create set parameters describing human scenario. mean parameters taken literature [DM]: parameter created using
descriptor part default parameter set. short name1 parameter set. longer verbose name can given well, seen ShinyApp. human parameter set can labeled using PSET descriptor following way: default parameter set short name name, “mAb Human” value shown user ShinyApp. Next, add parameterization mice simply create new set following way: alone create new parameter set short name mouse, exact copy default parameter set. identify parametric differences mouse human use PSET following way: Consider clearance parameter entry want murine half-life antibody [VR]: use set name (mouse) parameter name (CL) overwrite default specified value 7.71e-6. aspects parameter (bounds, edit flag, etc.) default value.","code":"
Weight 70.0 eps inf kg yes System # Organism weight
CL 0.0129 eps inf L/hr yes System # Systemic Clearance
Q 0.0329 eps inf L/hr yes System # Inter-compartmental clearance
Vp 3.1 eps inf L yes System # Vol. central compartment
Vt 2.8 eps inf L yes System # Vol. peripheral compartment mAb in Human mAb in Mouse 0.020 # 20 gram mouse 7.71e-6 0.0 1.6e-3 1 # arbitrary 7.71e-6"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"secondary-parameters-as-and-ad","dir":"Articles","previous_headings":"Parameters","what":"Secondary parameters and ","title":"Modeling Language","text":"static secondary parameter refers parameter change simulation. specified using <> descriptor can written terms system parameters previously defined static secondary parameters. can used differential equations, defining initial conditions, input scaling model outputs. similar secondary parameters defined $PK block NONMEM. example, wanted define rate elimination terms system parameters clearance CL volume distribution Vp following used: dynamic secondary parameters refers parameter can change simulation. typically means defined, using descriptor, terms state another dynamic secondary parameter. can used differential equations model outputs. similar parameters defined $DES block NONMEM. example wanted use concentration central compartment Cp dependent amount compartment Ap volume compartment Vp following used:","code":" kel = CL/Vp Cp = Ap/Vp"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"variance-parameters-vp","dir":"Articles","previous_headings":"Parameters","what":"Variance parameters ","title":"Modeling Language","text":"Variance parameters specified using format system parameters () : difference descriptor used grouping set Variance. used performing parameter estimation simulating residual variability.","code":"# name value lower_bound upper_bound units editable grouping SLOPE 0.01 eps inf 1/hr yes Variance"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"parameter-estimation-information-est","dir":"Articles","previous_headings":"Parameters","what":"Parameter estimation information ?","title":"Modeling Language","text":"Currently applies nlmixr2/rxode . Essentially parameters listed fixed. descriptor specifies information parameters estimation. Sometimes necessary estimate parameters log space. can specify parmaeters log transform (LT). wanted log transform parameters P1, P2, P3 following: NOTE Monolix outputs work correctly need logtransform parameters log-normal IIV assigned. default parameters specified estimation. want estimate subset parameters (P), say P1 P2, can use following:","code":" P1; P2; P3 P1; P2"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"variability-defining-the-variancecovariance-matrix-iiv-iivcor","dir":"Articles","previous_headings":"Parameters","what":"Variability: defining the variance/covariance Matrix ? & ?","title":"Modeling Language","text":"variable name assigned inter-individual variability (IIV) correlation/covariance (IIVCOR) term makes sense user may used. following sample codes variable names (eg: ETACL) likely make sense population modeler NONMEM user. define IIV term named ETACL variance 0.15 use following: next need associate IIV term system parameter. associate IIV term clearance (system parameter CL) specify log normal distribution (LN) simply write: Alternatively normal (N) distribution can used. Next specify IIV term ETAV variance 0.1. IIV term also log normal distribution applied parameter V: Now can define covariance (-diagonal elements) CL V 0.01 using: order isn’t important IIV terms can reversed","code":" 0.15 CL 0.10 V 0.01"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"iiv-and-parameter-sets-iivset-iivcorset","dir":"Articles","previous_headings":"Parameters","what":"IIV and parameter sets ? & ?","title":"Modeling Language","text":"default parameter sets inter individual variability specified using descriptors. associate specific set IIVs parameter set use descriptors. set descriptors operate differently parameter set descriptors (). just overwrites default values inherits default variance/covariance information. alter IIV information parameter set reset IIV information parameter set. entire variance covariance matrix need specified parameter set. parameter set MYPSET defined following used define IIV parameters Q CL: system parameters IIV information parameter set.","code":" 0.05 Q 0.25 CL 0.01"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"differential-equations","dir":"Articles","previous_headings":"","what":"Differential equations","title":"Modeling Language","text":"differential equations system can defined simply writing . Alternative can ‘built’ using different descriptors provided . Part flexibility ubiquity lies ability combine different notations. construct model (see section : Bringing together) combination five following methods can used: Differential equations Reaction rates =?=> Equilibrium relationships <=kforward:kreverse=> Sources sinks Movement compartments ","code":""},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"writing-odes-ode","dir":"Articles","previous_headings":"Differential equations","what":"Writing ODEs ","title":"Modeling Language","text":"Portions differential equations can specified ? state compartment. define dA/dT koffR*C - konR**B write: might convenient specify ODE across several lines, making things readable. Just use multiple statements appended together. give result example :","code":" koffR*C - konR*A*B koffR*C - konR*A*B"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"rate-equations","dir":"Articles","previous_headings":"Differential equations","what":"Rate equations =?=>","title":"Modeling Language","text":"may convenient write chemical reactions rather differential equations. can done using general form: stoichiometric coefficients, beginning CR CP , brackets need specified one. reaction order assumed equal stoichiometric coefficient reactant. specific example Consider decomposition hydrogen peroxide water oxygen: H_2O_2 \\xrightarrow{k_{deg}} H_2O + \\frac{1}{2}O_2 system format written following manner: translated following differential equations: \\frac{dH_2O_2}{dt}=-k_{deg}H_2O_2 \\\\ \\frac{dH_2O}{dt}= k_{deg}H_2O_2 \\\\ \\frac{dO_2}{dt}= 0.5k_{deg}H_2O_2 also defined differential equations using ?. equivalent: rates (e.g. kdeg) need defined either system secondary parameter. can put saturable terms, Michaelis-Menten kinetics.","code":"[CR1]Reactant1 + [CR2]Reactant2 + ... =kf=> [CP1]Product1 + [CP2]Product2 + ... H2O2 =kdeg=> H2O + [0.5]O2 - kdeg*H2O2 kdeg*H2O2 0.5*kdeg*H2O2"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"equilibrium-relationships-kforwardkreverse","dir":"Articles","previous_headings":"Differential equations","what":"Equilibrium relationships <=kforward:kreverse=>","title":"Modeling Language","text":"Forward reverse reaction rates can written separately: can written equilibrium equations forward (konR) reverse (koffR) rates specified : specify reaction differential equations, following also used: stoichiometric coefficients also define reaction order . example, create following equilibrium reaction: 2A + 3B \\mathop{\\rightleftarrows}^{\\mathrm{k_f}}_{\\mathrm{k_r}} 4C rate notation used system file: produce following terms differential equations: \\frac{dA}{dt} = 2k_rC^4 - 2k_fA^2B^3 \\\\ \\frac{dB}{dt} = 3k_rC^4 - 3k_fA^2B^3 \\\\ \\frac{dC}{dt} =-4k_rC^4 + 4k_fA^2B^3 write equilibrium reaction differential equations following used: See generic functions SIMINT_POWER[][].","code":"A + B =konR=> C C =koffR=> A + B A + B <=konR:koffR=> C koffR*C - konR*A*B koffR*C - konR*A*B -koffR*C + konR*A*B [2]A + [3]B <=kf:kr=> [4]C = 2*kr*SIMINT_POWER[C][4] - 2*kf*SIMINT_POWER[A][2]*SIMINT_POWER[B][3] = 3*kr*SIMINT_POWER[C][4] - 3*kf*SIMINT_POWER[A][2]*SIMINT_POWER[B][3] = -4*kr*SIMINT_POWER[C][4] + 4*kf*SIMINT_POWER[A][2]*SIMINT_POWER[B][3]"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"sources-and-sinks-s","dir":"Articles","previous_headings":"Differential equations","what":"Sources and sinks ","title":"Modeling Language","text":"method allows turnover described terms synthesis degradation terms. produced rate ksynA (mass quantities), degraded rate kdegA, modeled concentration units sources specified left hand side sinks (elimination) specified left hand side . Multiple sources sinks can separated semicolons. example compartment volume V writing differential equation:","code":"ksynA/V kdeg*A koffR*C - konR*A*B + ksynA/V - kdeg*A"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"movement-between-compartments-c","dir":"Articles","previous_headings":"Differential equations","what":"Movement between compartments ","title":"Modeling Language","text":"mass moves two physical spaces different volumes need specify, compartment, species, volume rate transport. descriptor allows us just identify compartment information separated semicolons (order important) movement central compartment volume V tissue space volume Vt rates kps ksp respectively specified following manner: equivalent following differential equation:","code":"Species; Volume; Rate Species; Volume; Rate A; V; kps At; Vt; ksp -kps*A + ksp*At*Vt/V +kps*A*V/Vt - ksp*At"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"bringing-it-all-together","dir":"Articles","previous_headings":"","what":"Bringing it all together","title":"Modeling Language","text":"final example consider target-mediated drug disposition system . system can defined set ODES: simply defined terms underlying processes:","code":" Cp*kpt*Vp/Vt - Ct*ktp -Cp*kpt + Ct*ktp*Vt/Vp - kel*Cp + koff*CpTp - kon*Cp*Tp + ksyn/Vp - kint*Tp + koff*CpTp - kon*Cp*Tp - kint*CpTp - koff*CpTp + kon*Cp*Tp # tissue distribution Ct; Vt; ktp Cp; Vp; kpt # equilibrium Cp + Tp <=kon:koff=> CpTp # Turnover ksyn/Vp kint*Tp kel*Cp kint*CpTp"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"initial-conditions-i","dir":"Articles","previous_headings":"Bringing it all together","what":"Initial conditions ","title":"Modeling Language","text":"default initial conditions zero. can specify non-zero initial condition using <> string set ‘state’ ‘value’ Value can combination numbers, system parameters static secondary parameters <. Consider turnover system value ksyn kdeg specified parameters: can calculate initial value target : can specify initial value target :","code":" state = value
ksyn 0.1 eps inf 1/hr yes Target
kdeg 0.04 eps inf nM yes Target T_IC = ksyn/kdeg T = T_IC"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"model-inputs","dir":"Articles","previous_headings":"","what":"Model inputs","title":"Modeling Language","text":"Inputs model include typical interventions bolus dosing continuous infusions. However inputs refers mathematical inputs. Typically covariates may attributes system (gender, specific genotype), treated inputs. defining inputs necessary provide typical/placeholder values. provide default values ShinyApp interface well scripting level (Matlab R) can overwritten user.","code":""},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"bolus-dosing-btimes-bevents","dir":"Articles","previous_headings":"Model inputs","what":"Bolus dosing , ","title":"Modeling Language","text":" descriptor used define bolus dosing. Dosing information broken list times bolus injections occur list events containing amount specified compartment receive. scale used convert bolus dosing information proscribed units (mg daily) units system coded (mg/mL hours). dosing done days 0, 1, 2… simulation time hours, scale dosing times 24.events contain magnitude bolus given time. want dose central compartment Cp mg/kg central compartment mg/mL need scale body weight (e.g. 70 kg) volume central compartment (system static secondary parameter Vp) scale 70/Vp. just want create palceholder can following: want setup default dosing shiny app scripts, can somethign complicated. multiple compartments receiving bolus, times must include times bolus may applied system. state receive bolus particular time, magnitude time 0. illustrate consider following dosing schedule: example want dose two different drugs two different states/compartments. Drug 1 (D1) dosed Cp1 drug 2 (D2) Cp2. Dosing mg/kg concentrations mg/ml. dosing time days, simulation time units hours. dosing D1 8 & 2 mpk days 0 & 6. D2 dosed 5 mpk day 9. Assume V1 V2 compartmental volumes D1 D2 ml, subject body weight 70 kg. convert doses mpk mg/ml. default doses can overwritten ShinyApp within scripts.","code":"# type state values scale units ; [0]; 24; days ; Cp; [0]; 70/Vc; mpk # type state values scale units ; [0 6 9]; 24; days ; Cp1; [8 2 0]; 70/V1; mpk ; Cp2; [0 0 5]; 70/V2; mpk"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"continuous-infusions-r","dir":"Articles","previous_headings":"Model inputs","what":"Continuous infusions ","title":"Modeling Language","text":"Rates infusion defined using descriptor. Like bolus values, infusion rates two components. component specifies switching times (e.g. switching 10 mg/hr 0). switching time corresponding rate infusion. infusion rate held constant next time. Also like bolus specification scale associated infusion times levels converts proscriptive units units simulation. Consider following example: two entries create infusion rate called myrate. can used system specifications (e.g., myrate/Vp). first row specifies times rate changed (0 30 minutes). system coded terms hours, scale 1/60 must used. levels indicate rate 1 mg/min switched 30 minutes. converted mg/hr using scale 60. can add many paired rate entries need describe many infusion interventions necessary. Note: just want placeholder can just set values [0].","code":"# name time/levels values scale units ; times; [0 30]; 1/60; min ; levels; [1 0]; 60; mg/min"},{"path":[]},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"simple-covariates","dir":"Articles","previous_headings":"Model inputs","what":"Simple covariates","title":"Modeling Language","text":"simulation purposes covariates (normally found dataset) need defined. Covariates can either constant change time. times values must scale system. following defines value covariate RACE: Covariates can also change time. case consider subject weight (WGT). begins 70 measurements made several time points. Next can alter simulations interpret values setting type covariate. default weight linearly interpolated (type = linear), however can hold weight constant next measurement encountered (last value carried forward) declaring type step Now model parameterized male female subjects can define two parameter sets (described ) account : values covariate can changed set ‘female’:","code":"; times; [0]; hours ; values; [1]; ethnicity ; times; [ 0 1680 3360 5040 10080]; hours ; values; [70 65 60 58 56]; kg step Male Female ; times; [ 0 1680 3360 10080] ; values; [60 55 52 50]"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"complicated-covariates","dir":"Articles","previous_headings":"Model inputs","what":"Complicated covariates","title":"Modeling Language","text":"Detailed time course profiles can created well. example, create covariate profile zero time 0-1 time 1 jumps 8 decreases rate 1 per unit time time 5 stays value 4 time 12. might profile like following:","code":"# name time/values values units ; times; [0 .999 1 5 12]; hours ; values; [0 0 8 4 4 ]; -- linear"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"model-outputs","dir":"Articles","previous_headings":"","what":"Model outputs","title":"Modeling Language","text":"Outputs defined terms states, parameters, secondary parameters, input rates, covariates listed . format used : example: Outputs begin QC, like QC_CLtot , displayed ShinyApp. intended make available scripting level quality control (QC) purposes.","code":" name = expression A_obs = A Coverage = A/(KD + A) QC_CLtot = Cp*CL/Vp + Cp*Vmax/(Km+Cp)"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"output-error-model-oe","dir":"Articles","previous_headings":"Model outputs","what":"Output error model ?","title":"Modeling Language","text":"links parameters defined using specific outputs defined using . can define either add additive /prop proportional error: OUTPUT can name output defined . expression model type (add additive, prop proportional) equal sign name variance paramter () use. use one error model type separate statments ; example define variance parameters add_err prop_err want use proportional error model output Cp use: use additive proportional error following work: certain target-specific considerations. example using Matlab R just wanted weighted least squares estimation proportional prediction squared use following fix prop_err 1. least squares estimation following fix add_err 1. represent default values though ’s possible overwrite . Matlab R workflows define variance cohort level, error models system file overwritten. ## Functions operators standard operators behave expected (+, -, *, & /) languages use consistently. however certain operators functions differ languages. example, consider power function (^b). FORTRAN **b, Matlab ^b, C pow(,b). Given objectives (write create multiple formats), can quite challenging. solution used convert language specific functions operators generic functions. power operator : converted appropriate output format depending output target. following generic functions can used:","code":"` expression` prop=prop_err add=add_err; prop=prop_err prop=prop_err add=add_err SIMINT_POWER[a][b]"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"current-simulation-time","dir":"Articles","previous_headings":"Model outputs","what":"Current simulation time","title":"Modeling Language","text":"systems want access simulation time. can use internal variable SIMINT_TIME.","code":""},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"modeling-quasi-equilibrium-of-target-mediated-drugs","dir":"Articles","previous_headings":"Model outputs","what":"Modeling quasi-equilibrium of target-mediated drugs","title":"Modeling Language","text":"free amount drug Cfree binding receptor affinity KD given total values Ctot Rtot following can calculated using following equation: C_{free}=\\frac{1}{2} \\left[ (C_{tot}-R_{tot}-K_D) + \\sqrt{(C_{tot}-R_{tot}-K_D)^2 + 4K_DC_{tot}} \\right] can tedious, especially using generic functions . make easier can use following generic function: get Rfree, just switch first two arguments:","code":" Cfree = SIMINT_QEQ[Ctot][Rtot][KD] Rfree = SIMINT_QEQ[Rtot][Ctot][KD]"},{"path":"https://r.ubiquity.tools/articles/Language.html","id":"timescales","dir":"Articles","previous_headings":"","what":"Timescales","title":"Modeling Language","text":"system default units constructed, indicated comments model. can useful (generating figures example) show simulations different time scales. Now can achieved multiplying time outputs correct scaling factor. However requires end user (1) remember original timescale (2) correctly scale value. Now particularly challenging mathematical perspective, introduces chance error. possible, instead, specify time scale information using descriptor. system coded hours, following define timescales default (hours), days, weeks months: used ShinyApp command line Matlab R","code":" 1.0 1.0/24.0 1.0/24.0/7.0