Skip to content

Laura-Villain/OSPSuite-R

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSPSuite-R

AppVeyor build status codecov

Overview

The ospsuite-R package provides the functionality of loading, manipulating, and simulating the simulations created in the Open Systems Pharmacology Software tools PK-Sim and MoBi.

Documentation

If you are reading this on GitHub README, please refer to the online documentation for more details on the package.

In particular, we would recommend that you read the articles in the following order:

Installation

The ospsuite-R package is compatible with version 3.6.x AND version 4.x.x of R. One of its dependency, rClr needs to be installed specifically for the targeted R version. Please follow the installation instructions below.

ospsuite requires following packages to be installed:

From CRAN:

Must be downloaded manually:

Under Windows

The release version of the package comes as a binary *.zip and can be downloaded from here.

If you use RStudio IDE, you can use the Install option in the Packages pane and select the option Install from -> Package Archive File to install a package from binary *.zip files.

To install manually, follow these instructions:

# Install dependencies (e.g. R6) which are on CRAN
install.packages('R6')

# Install `{rClr}` from local file 
# (`pathTo_rCLR.zip` here should be replaced with the actual path to the `.zip` file)
install.packages(pathTo_rCLR.zip, repos = NULL)

# Install `{ospsuite.utils}` from local file 
# (`pathTo_ospsuite.utils.zip` here should be replaced with the actual path to the `.zip` file)
install.packages(pathTo_ospsuite.utils.zip, repos = NULL)

# Install `{tlf}` from local file 
# (`pathTo_tlf.zip` here should be replaced with the actual path to the `.zip` file)
install.packages(pathTo_tlf.zip, repos = NULL)

# Install `{ospsuite}` from local file
# (`pathToOSPSuite.zip` here should be replaced with the actual path to the `.zip` file)
install.packages(pathToOSPSuite.zip, repos = NULL)

The package also requires the Visual C++ Runtime that is installed with OSPS and can be manually downloaded here.

Under Linux

The ospsuite package has been tested under Linux distributions CentOS 7 and Ubuntu 18. Some functionality, such as creating individuals, is not available under Linux. Installation under Linux requires several prerequisites, the detailed instructions can be found in the Wiki. For other Linux distributions Docker containers can be used (Dockerfiles based on CentOS 7 and Ubuntu 18 are available under https://github.com/Open-Systems-Pharmacology/OSPSuite-R/releases )

Build from source

You can clone the GIT repository and build the package from source.

How to update dependencies from nuget?

  • git submodule update --init --recursive to install all submodules
  • Make sure you have ruby install and that it is available in your path
  • Run rake postclean or simply double click on postclean.bat. This will update all nuget packages and copy the dependencies in the package inst/lib folder.

Usage

In general, every workflow starts with loading a simulation that has been exported to the *.pkml format. The method loadSimulation() returns the corresponding simulation that is used as input of other methods. The user can then change values of parameters and initial conditions, run the simulation, and retrieve the simulated results.

library(ospsuite)

# Load a simulation
simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite")
sim <- loadSimulation(simFilePath)

# Get the parameter "Dose"
doseParamPath <- "Applications|IV 250mg 10min|Application_1|ProtocolSchemaItem|Dose"
doseParam <- getParameter(doseParamPath, sim)

# Change the dose to 350mg. The values has to be converted to base unit, first
newValue <- toBaseUnit(quantity = doseParam, values = 350, unit = "mg")
setParameterValues(parameters = doseParam, values = newValue)

# Simulate
simResults <- runSimulation(simulation = sim)
# Retrieve the results
simulatedValues <- getOutputValues(simulationResults = simResults)

# Plot time-concentration profile
plot(simulatedValues$data$Time, simulatedValues$data$`Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)`,
type = "l",
xlab = "Time [min]",
ylab = "Concentration [µmol/l]")

More detailed description of the methods and the typical workflows can be found in the vignettes. You can see the list of all vignettes available for ospsuite by calling-

vignette(package = "ospsuite")

To open a specific vignette, call-

# Insert the name of the vignette you want to view as the argument
vignette("introduction-ospsuite")

Known issues

  • Loading ospsuite might fail if your systems locale is not set to English, e.g.:
载入需要的程辑包: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’:
loadNamespace()里算'ospsuite'时.onLoad失败了,详细内容:
调用: rClr::clrCall(dimensionTask, "AllAvailableUnitNamesFor", enc2utf8(dimension))
错误: Type: System.Collections.Generic.KeyNotFoundException
Message: Dimension 'CV mmHg*s虏/ml' not available in DimensionFactory.
...

-- On Windows, set Settings > Language > Administrative language settings > Current language for non-Unicode programs to English (United States) and reboot. -- On Linux, set the environment variable LC_ALL before starting R:

export LC_ALL=en_US.UTF-8
  • RStudio crashes when trying to load a workspace. The ospsuite package uses the features implemented in PK-Sim and MoBi by creating .NET objects (e.g. a simulation) and using them from R. These objects cannot be saved as part of the workspace and reloaded on next start. When trying to do so, RStudio simply crashes. There is no possibility to overcome this limitation. To prevent RStudio from crashing, make sure to disable the check-box "Restore .RData into workspace at startup" in the options of RStudio. Keep in mind that you can also change this setting for specific projects.

Code of Conduct

Everyone interacting in the Open Systems Pharmacology community (codebases, issue trackers, chat rooms, mailing lists etc.) is expected to follow the Open Systems Pharmacology code of conduct.

Contribution

We encourage contribution to the Open Systems Pharmacology community. Before getting started please read the contribution guidelines. If you are contributing code, please be familiar with the coding standards.

License

OSPSuite-R is released under the GPLv2 License.

All trademarks within this document belong to their legitimate owners.

Packages

No packages published

Languages

  • R 87.3%
  • RMarkdown 11.8%
  • Other 0.9%