[Implemented] Specification for plotObservedVsSimulated()
#809
Replies: 12 comments 4 replies
-
As for wide versus tidy, you need the data to be in the wide format irrespective of what package you choose, doesn't matter if it's tlf, ggplot2, or base. Paired data that needs to be plotted as a scatterplot will always have to be in wide format. It will be confusing for the users for it not to be. # tlf
plotObsVsPred(
data = df,
dataMapping = ObsVsPredDataMapping$new(
x = "yValuesObserved",
y = "yValuesPredicted",
)
)
# ggplot2
ggplot(df, aes(yValuesObserved, yValuesPredicted)) +
geom_point()
# base
plot(df$yValuesObserved, df$yValuesPredicted) |
Beta Was this translation helpful? Give feedback.
-
@PavelBal Should the labels for this plot contain information about dimensions and units, like in profile plots? |
Beta Was this translation helpful? Give feedback.
-
Yes And let's rename it to |
Beta Was this translation helpful? Give feedback.
-
In profile plots, datasets that are not part of any group are assigned to their own group. But, in case of the current function, those datasets should be left out of the plot, correct? In the example plot, e.g., there are no datasets included in the plot that don't belong to any group. |
Beta Was this translation helpful? Give feedback.
-
Each plotted "data set" is a combination of simulation results and observed data. So even in case of multiple observed data are assigned to the same group, but no simulatio result, these data are not to be plotted. The same goes for simulated results - if multiple simulated results are in one group, but no observed data - do not consider. Maybe like this:
Will result in following pairs:
|
Beta Was this translation helpful? Give feedback.
-
What about a warning when the dataset are being discarded so that the user knows, that something is not quite right? |
Beta Was this translation helpful? Give feedback.
-
I personally do not see a necessity for a warning, but if you think so.. |
Beta Was this translation helpful? Give feedback.
-
How about the following? The library(dplyr)
df <- dplyr::tribble(
~name, ~dataType, ~group,
"Sim1", "Simulated", "GroupA",
"Sim2", "Simulated", "GroupA",
"Obs1", "Observed", "GroupB",
"Obs2", "Observed", "GroupB",
"Sim3", "Simulated", "GroupC",
"Obs3", "Observed", "GroupC",
"Sim4", "Simulated", "GroupD",
"Obs4", "Observed", "GroupD",
"Obs5", "Observed", "GroupD",
"Sim5", "Simulated", "GroupE",
"Sim6", "Simulated", "GroupE",
"Obs7", "Observed", "GroupE",
"Sim7", "Simulated", "GroupF",
"Sim8", "Simulated", "GroupF",
"Obs8", "Observed", "GroupF",
"Obs9", "Observed", "GroupF",
"Sim9", "Simulated", NA,
"Obs10", "Observed", NA
)
.removeUnpairableDatasets <- function(data) {
# How many rows were originally present
originalDatasets <- unique(data$name)
# Remove datasets that don't belong to any group.
data <- dplyr::filter(data, !is.na(group))
# Remove groups (and the datasets therein) with only one type (either only
# observed or only simulated) of dataset.
data <- data %>%
dplyr::group_by(group) %>%
dplyr::filter(length(unique(dataType)) > 1L) %>%
dplyr::ungroup()
# How many rows are present after filtering
finalDatasets <- unique(data$name)
# Warn the user about the filtering if it took place
if (length(finalDatasets) < length(originalDatasets)) {
missingDatasets <- originalDatasets[!originalDatasets %in% finalDatasets]
message(
"Following non-grouped or unpairable datasets have been removed:\n",
paste0(missingDatasets, collapse = "\n")
)
}
return(data)
}
df <- .removeUnpairableDatasets(df)
#> Following non-grouped or unpairable datasets have been removed:
#> Sim1
#> Sim2
#> Obs1
#> Obs2
#> Sim9
#> Obs10
df
#> # A tibble: 12 x 3
#> name dataType group
#> <chr> <chr> <chr>
#> 1 Sim3 Simulated GroupC
#> 2 Obs3 Observed GroupC
#> 3 Sim4 Simulated GroupD
#> 4 Obs4 Observed GroupD
#> 5 Obs5 Observed GroupD
#> 6 Sim5 Simulated GroupE
#> 7 Sim6 Simulated GroupE
#> 8 Obs7 Observed GroupE
#> 9 Sim7 Simulated GroupF
#> 10 Sim8 Simulated GroupF
#> 11 Obs8 Observed GroupF
#> 12 Obs9 Observed GroupF Created on 2022-05-09 by the reprex package (v2.0.1.9000) Also, to be consistent with Lines 544 to 555 in e2e1e65 |
Beta Was this translation helpful? Give feedback.
-
Is this in the ballpark of what you had in mind? library(ospsuite)
# load the simulation
sim <- loadTestSimulation("MinimalModel")
simResults <- importResultsFromCSV(
simulation = sim,
filePaths = getTestDataFilePath("Stevens_2012_placebo_indiv_results.csv")
)
# import observed data (will return a list of DataSet objects)
dataSet <- loadDataSetsFromExcel(
xlsFilePath = getTestDataFilePath("CompiledDataSetStevens2012.xlsx"),
importerConfiguration = loadDataImporterConfiguration(getTestDataFilePath("ImporterConfiguration.xml"))
)
# create a new instance and add datasets
myCombDat <- DataCombined$new()
myCombDat$addSimulationResults(
simResults,
quantitiesOrPaths = c(
"Organism|Lumen|Stomach|Dapagliflozin|Gastric retention",
"Organism|Lumen|Stomach|Dapagliflozin|Gastric emptying",
"Organism|Lumen|Stomach|Metformin|Gastric retention"
)
)
myCombDat$addDataSets(dataSet)
myCombDat$setGroups(
names = c(
"Organism|Lumen|Stomach|Dapagliflozin|Gastric emptying",
"Stevens_2012_placebo.Sita_dist",
"Organism|Lumen|Stomach|Dapagliflozin|Gastric retention",
"Stevens_2012_placebo.Sita_proximal",
"Organism|Lumen|Stomach|Metformin|Gastric retention",
"Stevens_2012_placebo.Sita_total"
),
groups = c("distal", "distal", "proximal", "proximal", "total", "total")
)
# default
plotObservedVsSimulated(myCombDat) |
Beta Was this translation helpful? Give feedback.
-
@PavelBal |
Beta Was this translation helpful? Give feedback.
-
@pchelle i. |
Beta Was this translation helpful? Give feedback.
-
@pchelle Any update on this? Will you be making these changes in tlf itself? Thanks. |
Beta Was this translation helpful? Give feedback.
-
Related to #674
Signature
Implementation plan
Rough expected output:
Decision points:
N.B. The option already rejected by the team is scratched out.
thresholdversus interpolationMember methodversus functionTasks
Each task will get its own PR.
toObservedVsPredictedDataFrame()
functionplotObservedVsSimulated()
Beta Was this translation helpful? Give feedback.
All reactions