DataCombined | R Documentation |
A class for storing simulated and/or observed in a single data frame, which can be further used in data wrangling or data visualization pipelines.
Additionally, it allows:
Grouping different simulated and/or observed datasets.
Transforming data with given offsets and scale factors.
ospsuite.utils::Printable
-> DataCombined
names
A vector of unique names of datasets contained in the
DataCombined
class instance.
groupMap
A data frame specifying which datasets have been grouped
together and the name and the nature (observed or simulated?) of the
data. If a dataset was not assigned to any group, this is denoted by
NA
in the data frame.
dataTransformations
A data frame with offset and scale factor values were specified by the user for each dataset.
addDataSets()
Adds observed data.
DataCombined$addDataSets(dataSets, names = NULL, groups = NULL, silent = FALSE)
dataSets
An instance (or a list
of instances) of the DataSet
class.
names
A string or a list
of strings assigning new names. These new
names can be either for renaming DataSet
objects, or for renaming
quantities/paths in SimulationResults
object. If an entity is not to be
renamed, this can be specified as NULL
. E.g., in names = list("oldName1" = "newName1", "oldName2" = NULL)
), dataset with name "oldName2"
will not
be renamed. The list can either be named or unnamed. Names act as unique
identifiers for data sets in the DataCombined
object and, therefore,
duplicate names are not allowed.
groups
A string or a list of strings specifying group name
corresponding to each data set. If an entry within the list is NULL
, the
corresponding data set is not assigned to any group (and the corresponding
entry in the group
column will be an NA
). If provided, groups
must
have the same length as dataSets
and/or simulationResults$quantityPath
.
If no grouping is specified for any of the dataset, the column group
in
the data frame output will be all NA
.
silent
A binary flag showing if warnings should be triggered when
data sets are overwritten in the DataCombined
object
DataCombined
object containing observed data.
addSimulationResults()
Add simulated data using instance of SimulationResults
class.
DataCombined$addSimulationResults( simulationResults, quantitiesOrPaths = NULL, population = NULL, individualIds = NULL, names = NULL, groups = NULL, silent = FALSE )
simulationResults
Object of type SimulationResults
produced by
calling runSimulations
on a Simulation
object.
quantitiesOrPaths
Quantity instances (element or vector) typically
retrieved using getAllQuantitiesMatching
or quantity path (element or
vector of strings) for which the results are to be returned. (optional)
When providing the paths, only absolute full paths are supported (i.e., no
matching with '*' possible). If quantitiesOrPaths is NULL
(default
value), returns the results for all output defined in the results.
population
population used to calculate the simulationResults
(optional). This is used only to add the population covariates to the
resulting data table.
individualIds
numeric
IDs of individuals for which the results
should be extracted. By default, all individuals from the results are
considered. If the individual with the provided ID is not found, the ID is
ignored.
names
A string or a list
of strings assigning new names. These new
names can be either for renaming DataSet
objects, or for renaming
quantities/paths in SimulationResults
object. If an entity is not to be
renamed, this can be specified as NULL
. E.g., in names = list("oldName1" = "newName1", "oldName2" = NULL)
), dataset with name "oldName2"
will not
be renamed. The list can either be named or unnamed. Names act as unique
identifiers for data sets in the DataCombined
object and, therefore,
duplicate names are not allowed.
groups
A string or a list of strings specifying group name
corresponding to each data set. If an entry within the list is NULL
, the
corresponding data set is not assigned to any group (and the corresponding
entry in the group
column will be an NA
). If provided, groups
must
have the same length as dataSets
and/or simulationResults$quantityPath
.
If no grouping is specified for any of the dataset, the column group
in
the data frame output will be all NA
.
silent
A binary flag showing if warnings should be triggered when
data sets are overwritten in the DataCombined
object
DataCombined
object containing simulated data.
setGroups()
Adds grouping information to (observed and/or simulated) datasets.
DataCombined$setGroups(names, groups)
names
A list of dataset names which need to be grouped. Note that
if you have specified new names
while adding datasets (using
$addDataSets()
and $addSimulationResults()
methods), you will need
to use these new names to specify group assignment. The same dataset
can't be assigned to two different groupings in the same
$setGroups()
call. In other words, elements of names
argument
should be unique.
groups
A list specifying which datasets belong to which group(s).
Please note that the order in which groups are specified should match
the order in which datasets were specified for names
parameter. For
example, if data sets are named "x"
, "y"
, "z"
, and the desired
groupings for them are, respectively, "a"
, "b"
, this can be
specified as names = list("x", "y"), groups = list("a", "b")
.
Datasets for which no grouping is to be specified, can be left out of
the groups
argument. The column group
in the data frame output will
be NA
for such datasets. If you wish to remove an existing grouping
assignment for a given dataset, you can specify it as following:
list("x" = NA)
or list("x" = NULL)
. This will not change any of the
other groupings.
DataCombined
object with grouped datasets.
setDataTypes()
set the type of data (observed or simulated) for datasets.
DataCombined$setDataTypes(names, dataTypes)
names
a character vector of dataset names which dataTypes need to be changed.
dataTypes
a character vector of dataTypes ("observed"
or
"simulated"
) to be assigned to the datasets (in order of names
.
DataCombined
object with modified dataTypes datasets.
removeGroupAssignment()
Remove existing groupings for (observed and/or simulated) datasets.
DataCombined$removeGroupAssignment(names)
names
A list of dataset names whose group assignment needs to be
removed. Note that if you have specified new names
while adding
datasets (using $addDataSets()
and $addSimulationResults()
methods), you will need to use these new names to specify group
assignment. The elements of names
argument should be unique.
DataCombined
object with updated group assignments.
setDataTransformations()
Transform raw data with required offsets and scale factors.
DataCombined$setDataTransformations( forNames = NULL, xOffsets = 0, yOffsets = 0, xScaleFactors = 1, yScaleFactors = 1, reset = FALSE )
forNames
A list of names specifying which observed datasets and/or
paths in simulated dataset to transform with the specified
transformations. Default is NULL
, i.e., the transformations, if any
specified, will be applied to all rows of the data frame.
xOffsets, yOffsets, xScaleFactors, yScaleFactors
Either a single
numeric value or a list of numeric values specifying offsets and
scale factors to apply to raw values. The default offset is 0
, while
default scale factor is 1
, i.e., the data will not be modified. If a
list is specified, it should be the same length as forNames
argument.
reset
IF TRUE
, only data transformations that are specified will
be retained. Not specified transformations will be reset to their defaults.
Default behavior is FALSE
, e.g., setting only xOffsets
will not reset
xScaleFactors
if those have been set previously.
A data frame with respective raw quantities transformed using specified offset and scale factor values.
For X and Y variables:
newValue = (rawValue + offset) * scaleFactor
For error term:
newErrorValue = rawErrorValue * scaleFactor
toDataFrame()
A method to extract a tibble data frame of simulated and/or observed data (depending on instances of which classes have been added to the object).
Note that the order in which you enter different object doesn't matter because the returned data frame is arranged alphabetically by dataset name.
DataCombined$toDataFrame()
In the returned tibble data frame, the following columns will always be present:
name - group - dataType - xValues - xDimension - xUnit - yValues - yErrorValues - yDimension - yUnit - yErrorType - yErrorUnit - molWeight
print()
Print the object to the console.
DataCombined$print()
clone()
The objects of this class are cloneable with this method.
DataCombined$clone(deep = FALSE)
deep
Whether to make a deep clone.
The molecular weight (in molWeight
column) is in g/mol
units.
Other data-combined:
calculateResiduals()
,
convertUnits()
# simulated data
simFilePath <- system.file("extdata", "Aciclovir.pkml", package = "ospsuite")
sim <- loadSimulation(simFilePath)
simResults <- runSimulations(sim)[[1]]
outputPath <- "Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)"
# observed data
obsData <- lapply(
c("ObsDataAciclovir_1.pkml", "ObsDataAciclovir_2.pkml", "ObsDataAciclovir_3.pkml"),
function(x) loadDataSetFromPKML(system.file("extdata", x, package = "ospsuite"))
)
names(obsData) <- lapply(obsData, function(x) x$name)
# Create a new instance of `DataCombined` class
myDataCombined <- DataCombined$new()
# Add simulated results
myDataCombined$addSimulationResults(
simulationResults = simResults,
quantitiesOrPaths = outputPath,
groups = "Aciclovir PVB"
)
# Add observed data set
myDataCombined$addDataSets(obsData$`Vergin 1995.Iv`, groups = "Aciclovir PVB")
# Looking at group mappings
myDataCombined$groupMap
# Looking at the applied transformations
myDataCombined$dataTransformations
# Accessing the combined data frame
myDataCombined$toDataFrame()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.