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

Set Parameter using MoBiToolboxForR #477

Open
CBiesdorf opened this issue Mar 11, 2020 · 11 comments
Open

Set Parameter using MoBiToolboxForR #477

CBiesdorf opened this issue Mar 11, 2020 · 11 comments

Comments

@CBiesdorf
Copy link

@CBiesdorf CBiesdorf commented Mar 11, 2020

Hi,

I am trying to use R to run the population simulations but when I try to change a parameter, for example, dose, I get the error below.

dci_info <- setParameter(value = 0.0006,
path_id = 12433,
options=list(Type="variable"),
DCI_Info = dci_info)

Error in setParameter(value = 6e-04, path_id = 12433, options = list(Type = "variable"), :
Parameter with path_id 12433 does not exist for specified type variable

How can I fix it?

@PavelBal

This comment has been minimized.

Copy link
Member

@PavelBal PavelBal commented Mar 12, 2020

You have to set this paramater as "variable" during the initialization of the simulation.

One way to do this is to use the argument whichInitParam with the value allNonFormula:

DCI_Info <- initSimulation(pathToXML, whichInitParam = "allNonFormula")

This way you will be able to change all parameters that are defined by a constant. If you want to change formula-defined parameters (e.g. Dose if it is given by the DosePerBodyWeight), you have to specify this parameters:

initStruct <- list
#Repeat the next line for each parameter you want to change
initStruct <- initParameter(path_id = 12433, initializeIfFormula = "always", initStruct = initStruct)
#Initialize the simulation using initStruct
DCI_Info <- initSimulation(pathToXML, ParamList = initStruct)
@CBiesdorf

This comment has been minimized.

Copy link
Author

@CBiesdorf CBiesdorf commented Mar 16, 2020

Thank you @PavelBal . That was very helpful!

I am trying to run the population simulations in R, so I was wondering if there is any script available to do it. I am trying to use the headers of the excel population file to set up the parameter paths, but when I export the population excel file from PK-SIM the headers are not the same as the path in the model file (the model file has in the path the simulation name first, which it is not in the population excel file). Or maybe I am missing an easiest way to set the population simulations.
Any thoughts?

@msevestre

This comment has been minimized.

Copy link
Member

@msevestre msevestre commented Mar 16, 2020

@CBiesdorf Your best bet is to give the OSPSuite-R package a try (a complete rewrite of the MobiToolBox for R). It supports popuation simulations, SA etc..
It's not officialy released yet (hopefully end of April) but fairly stable at the moment

@CBiesdorf

This comment has been minimized.

Copy link
Author

@CBiesdorf CBiesdorf commented Mar 16, 2020

Thank you @msevestre
Where can I find the .zip file to install the OSPSuite-R package or directories to download it?

@msevestre

This comment has been minimized.

Copy link
Member

@msevestre msevestre commented Mar 16, 2020

https://github.com/Open-Systems-Pharmacology/OSPSuite-R/

The package will be officially released with V9 that comes out at the end of April. If you want to try the beta, you have to download the package, please download this package
https://ci.appveyor.com/project/open-systems-pharmacology-ci/ospsuite-r/build/artifacts

Obviously, the package will be in our release section for V9 . For now, it's only on demand
Also note that while the API is fairly stable, a few methods are going to change around UserDefinedPKParameters

You will need to have .NET 4.7.2 framework installed (which you probably have) as well as VC++ runtime (which you may have already. If not https://aka.ms/vs/16/release/vc_redist.x64.exe)

The package comes with vignettes, help for all methods etc.. Documentation is still WIP however

@CBiesdorf

This comment has been minimized.

Copy link
Author

@CBiesdorf CBiesdorf commented Mar 16, 2020

Thanks @msevestre .

I was able to install the package, but can not load it. Getting the following error:

library(ospsuite)
Loading required package: rClr
Loading the dynamic library for Microsoft .NET runtime...
Loaded Common Language Runtime version 4.0.30319.42000

Error: package or namespace load failed for ‘ospsuite’:
.onLoad failed in loadNamespace() for 'ospsuite', details:
call: rClr::clrCallStatic("OSPSuite.R.Api", "InitializeOnce", apiConfig$ref)
error: Type: System.DllNotFoundException
Message: Unable to load DLL 'OSPSuite.FuncParserNative.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Method: IntPtr CreateParsedFunction()
Stack trace:
at OSPSuite.FuncParser.ParsedFunctionImports.CreateParsedFunction()
at OSPSuite.FuncParser.ParsedFunction..ctor()
at OSPSuite.Core.Services.ExplicitFormulaParser..ctor(IEnumerable1 variableNames, IEnumerable1 parameterNames)
at OSPSuite.Core.Domain.Formulas.FormulaWithFormulaString.<>c.<.cctor>b__15_0(IEnumerable1 v, IEnumerable1 p)
at OSPSuite.Core.Domain.Formulas.ExplicitFormula.createFormulaParser(IEnumerable1 references) at OSPSuite.Core.Domain.Formulas.ExplicitFormula.CalculateFor(IEnumerable1 usedObjects, IUsingFormula dependentObj
In addition: Warning message:
package ‘ospsuite’ was built under R version 3.6.3

Any thoughts?

@msevestre

This comment has been minimized.

Copy link
Member

@msevestre msevestre commented Mar 16, 2020

@CBiesdorf Did you install the C++ runtime as written above?

@CBiesdorf

This comment has been minimized.

Copy link
Author

@CBiesdorf CBiesdorf commented Mar 20, 2020

Thanks @msevestre
I have reinstalled the C++ and now I am able to use the ospsuite package.
The description of SA, PK parameters and Parameter Identification is not available in the vignettes. Is it already available somewhere else?

@msevestre

This comment has been minimized.

Copy link
Member

@msevestre msevestre commented Mar 20, 2020

@CBiesdorf Not yet. Parameter Identificaton won't be part of the package for v1.0, It will be added later on.

There are a bunch of scripts in the package showing how to perform SA.
https://github.com/Open-Systems-Pharmacology/OSPSuite-R/tree/develop/tests/dev

If you look at some of them, you should be able to see how to run a SA for example

@CBiesdorf

This comment has been minimized.

Copy link
Author

@CBiesdorf CBiesdorf commented Mar 24, 2020

Thank you @msevestre
SA for individual simulation is working!

How about the PK analyses for population simulation?
I can run the population simulation but when I try to export the PK analyses using the script (https://github.com/Open-Systems-Pharmacology/OSPSuite-R/blob/develop/tests/dev/script-pk-analyses.R), I get the error:
Error: object 'DynamicPKParameter' not found

@msevestre

This comment has been minimized.

Copy link
Member

@msevestre msevestre commented Mar 25, 2020

Yes. Dynamic parameters do not exist anymore. The script is outdated. Simply remove everything around dynamic parameters and you should be good to go.

Also I'd suggest to update to the latest version of the OSPSuite-R. This version will be one of the last one before the release probably

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.