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

plotObservedVsSimulated(): error when DataCombined only contains observed or simulated results #1012

Closed
PavelBal opened this issue Jul 4, 2022 · 2 comments · Fixed by #945

Comments

@PavelBal
Copy link
Member

PavelBal commented Jul 4, 2022

myCombDat <- DataCombined$new()

# load the simulation
sim <- loadTestSimulation("MinimalModel")
simResults <- importResultsFromCSV(
  simulation = sim,
  filePaths = getTestDataFilePath("Stevens_2012_placebo_indiv_results.csv")
)

myCombDat$addSimulationResults(
  simResults,
  quantitiesOrPaths = c(
    "Organism|Lumen|Stomach|Dapagliflozin|Gastric retention",
    "Organism|Lumen|Stomach|Dapagliflozin|Gastric emptying",
    "Organism|Lumen|Stomach|Metformin|Gastric retention"
  )
)

Following datasets were specified to be grouped but not found:
Organism|Lumen|Stomach|Dapagliflozin|Gastric emptying
Organism|Lumen|Stomach|Dapagliflozin|Gastric retention
Organism|Lumen|Stomach|Metformin|Gastric retention

Error in `dplyr::arrange()` at OSPSuite-R/R/utilities-units.R:585:2:
! Problem with the implicit `transmute()` step.
✖ Problem while computing `..1 = .rowidInternal`.
Caused by error:
! object '.rowidInternal' not found
Run `rlang::last_error()` to see where the error occurred.
Warning messages:
1: Unknown or uninitialised column: `yUnitSplit`. 
2: Unknown or uninitialised column: `molWeightSplit`. 

Instead, it should produce an empty plot (and, if defined in the plot configuration, title subtitle and so on).

@PavelBal
Copy link
Member Author

PavelBal commented Jul 4, 2022

Same for observed only

@IndrajeetPatil
Copy link
Member

In both cases, the function will return a NULL with an informative warning about what went wrong.

library(ospsuite)

dataSet1 <- DataSet$new(name = "Dataset1")
dataSet1$setValues(1, 1)
dataSet1$yDimension <- ospDimensions$`Concentration (molar)`
dataSet1$molWeight <- 1

myCombDat <- DataCombined$new()
plotObservedVsSimulated(myCombDat)
#> Warning in plotObservedVsSimulated(myCombDat): No plot can be created because
#> the entered `DataCombined` object does not contain any datasets.
#> NULL

myCombDat$addDataSets(dataSet1)
plotObservedVsSimulated(myCombDat)
#> Following datasets were specified to be grouped but not found:
#> Dataset1
#> 
#> Warning in plotObservedVsSimulated(myCombDat): No plot can be created because
#> the entered `DataCombined` object does not contain any observed-simulated
#> datasets that can be paired.
#> NULL

Created on 2022-07-04 by the reprex package (v2.0.1.9000)

IndrajeetPatil added a commit that referenced this issue Jul 4, 2022
IndrajeetPatil added a commit that referenced this issue Jul 18, 2022
* initialize `plotObservedVsSimulated()`

* naming

* preliminary test

* show message only once across groups

* interpolation in edge case

* DRY in setting same properties across plots

* also test custom plot

* for now, only one line

* also test smoother

* update snapshots

* fix tests

* fix tests

* Use `foldDistance` arg from tlf

* Need the latest version

* fix documentation issue

This issue was introduced in #995

* introduce tolerance

* Use unit-dependent thresholds

* linear smoother by default

* add example to aggregated data function

* Update DefaultPlotConfiguration.Rd

* correct fold distance

* deal with linear scale

* update snapshot

* set smoother to NULL

* use long dash

* use expand

* add expand option

* better

* use messages instead

* minor

* catch with tlf

* update snapshots

* pass args to legend config

* update other plots as well

* legend key text should be left-aligned

* address code review comments

* test adding more fold distances work

* Return `NULL` when `DataCombined` is empty

Closes #1010
Closes #1011

* Handle edge case in paired plot

Closes #1012

* remove `smoother` arg

* update snapshots

* fix legend alignment issue

* legendCaption -> legendKeys

* catch up with tlf

* also include residual values

* add error bars to the plot

* comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants