Skip to content

Commit

Permalink
Merge branch 'develop' into 1261_utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
pchelle committed Sep 6, 2024
2 parents 8d1b9bd + 252a166 commit 7371e16
Show file tree
Hide file tree
Showing 35 changed files with 127 additions and 107 deletions.
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## New features

> [!NOTE]
> Users can now check out [Reporting Engine Test Reports](https://github.com/Open-Systems-Pharmacology/RE-Test-Reports) and access a bunch of template workflows including their R code, models, data and corresponding reports.
- Demography task received significant updates:
- The [article for demography](../articles/demography.html) has been updated with more comprehensive examples using more representative virtual populations and illustrating the effects of population workflows and settings (#1095, #1102)
- Categorical parameters, such as Gender, are now accounted for demography range plots and displayed as boxplots (#1088)
Expand All @@ -11,10 +14,11 @@
- Mass balance plots can leverage user-defined settings from json files as illustrated in the [mass balance article](../articles/mass-balance.html) (#1118)
- Normalized mass balance plots now use time-dependent cumulative drug mass for normalization (#1039, #1118)
- Qualification DDI plots received the following improvements
- Delta symbol (δ) from Guest *et al.* formula is indicated in table caption (1069)
- Delta symbol (δ) from Guest *et al.* formula is indicated in table caption (#1069)
- Guest criterion (δ) can be tuned through the configuration plan (#789)
- DDI plot format is quadratic by default (#1051)
- Formatting to word reports can translate additional `html` tags (#382)
- Goodness of Fit task leverages `groupID` from `Output` objects to group multiple outputs in same time profile and residual plots (#1188).<br>`groupID` is also leveraged in the plots of residuals across the simulations (#1251).

## Minor improvements and bug fixes

Expand All @@ -23,6 +27,7 @@
- Number of bins in demography and PK parameter range plots is consistent with input (#1128)
- Link/bookmark targets in word reports are better placed (#1084)
- Qualification time profiles work when no observed data is contained (#1082)
- Qualification PKRatio uses *ml/min/kg* as default clearance - *CL* - unit (#1242)
- Static images in qualification reports are better handled (#955, #1071)
- Figure captions are displayed below the figure in the reports (#1053)
- Word report is updated if it already existed (#1055)
Expand Down
21 changes: 12 additions & 9 deletions R/captions.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ captions <- list(
),
demography = list(
parameterSection = function(sectionId, parameterName) {
paste("##", parameterName, "distributions", anchor(sectionId))
paste("## ", parameterName, " distributions", anchor(sectionId), sep = "")
},
xParameterSection = function(sectionId, parameterName) {
paste("## ", parameterName, "-dependence ", anchor(sectionId), sep = "")
paste("## ", parameterName, "-dependence", anchor(sectionId), sep = "")
},
yParameterSection = function(sectionId, parameterName) {
paste("###", parameterName, anchor(sectionId))
paste("### ", parameterName, anchor(sectionId), sep = "")
},
populationSection = function(sectionId, simulationSetName, descriptor, level = 4) {
tagLevel <- paste0(rep("#", level), collapse = "")
sectionTitle <- paste(tagLevel, "For", reportSimulationSet(simulationSetName, descriptor))
return(paste(sectionTitle, anchor(sectionId)))
return(paste(sectionTitle, anchor(sectionId), sep = ""))
},
histogramLegend = function(data, observed = FALSE) {
if (observed) {
Expand Down Expand Up @@ -163,10 +163,10 @@ captions <- list(
paste0("PK parameters for ", reportSimulationSet(simulationSetName, descriptor))
},
outputSection = function(pathName, pathID) {
paste("## PK Parameters of", pathName, anchor(pathID))
paste("## PK Parameters of ", pathName, anchor(pathID), sep = "")
},
parameterSection = function(parameterName, parameterID) {
paste("###", parameterName, anchor(parameterID))
paste("### ", parameterName, anchor(parameterID), sep = "")
},
boxplot = function(parameterName, pathName, simulationSetName, descriptor, plotScale = "linear") {
paste(
Expand Down Expand Up @@ -324,19 +324,22 @@ getTimeRangeCaption <- function(timeRangeName, reference, simulationSetName) {
if (isIncluded(timeRangeName, ApplicationRanges$total)) {
return(paste(
"### For total simulation time range",
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "total"))
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "total")),
sep = ""
))
}
if (isIncluded(timeRangeName, ApplicationRanges$firstApplication)) {
return(paste(
"### For first application range",
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "first"))
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "first")),
sep = ""
))
}
if (isIncluded(timeRangeName, ApplicationRanges$lastApplication)) {
return(paste(
"### For last application range",
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "last"))
anchor(paste0(reference, "-", removeForbiddenLetters(simulationSetName), "-", "last")),
sep = ""
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/configuration-plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ConfigurationPlan <- R6::R6Class(
# Issue #1084: new reference title get anchor at the end of title
addTextChunk(
fileName = self$getSectionMarkdown(id),
text = paste(self$getSectionTitle(id), anchor(sectionReference))
text = paste(self$getSectionTitle(id), anchor(sectionReference), sep = "")
)
# Add section content
sectionContent <- private$.sections$content[selectedId]
Expand Down
18 changes: 9 additions & 9 deletions R/error-checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -669,25 +669,25 @@ checkSamePopulationIds <- function(setIds,
#' @keywords internal
checkMetaDataIsConsistent <- function(metaData) {
groupId <- unique(metaData$group)
if(!isOfLength(unique(metaData$unit), 1)){
if (!isOfLength(unique(metaData$unit), 1)) {
warning(
messages$inconsistentMetaData(
values = metaData$unit,
id = groupId,
values = metaData$unit,
id = groupId,
dataType = "units"
),
),
call. = FALSE
)
)
}
if(!isOfLength(unique(metaData$residualScale), 1)){
if (!isOfLength(unique(metaData$residualScale), 1)) {
warning(
messages$inconsistentMetaData(
values = metaData$residualScale,
id = groupId,
values = metaData$residualScale,
id = groupId,
dataType = "residualScale"
),
call. = FALSE
)
}
return()
}
}
10 changes: 6 additions & 4 deletions R/gof-plot-task.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ GofPlotTask <- R6::R6Class(
addTextChunk(
fileName = self$fileName,
text = paste(
"##", self$title, "for", simulationSetName,
anchor(paste0(self$reference, "-", removeForbiddenLetters(simulationSetName)))
"## ", self$title, " for ", simulationSetName,
anchor(paste0(self$reference, "-", removeForbiddenLetters(simulationSetName))),
sep = ""
)
)
for (result in taskResults) {
Expand Down Expand Up @@ -76,7 +77,8 @@ GofPlotTask <- R6::R6Class(
fileName = self$fileName,
text = paste(
"## Residuals across all simulations",
anchor(paste0(self$reference, "-residuals-across-all-simulations"))
anchor(paste0(self$reference, "-residuals-across-all-simulations")),
sep = ""
)
)
for (result in taskResults) {
Expand Down Expand Up @@ -136,7 +138,7 @@ GofPlotTask <- R6::R6Class(
resetReport(self$fileName)
addTextChunk(
fileName = self$fileName,
text = paste("#", self$title, anchor(self$reference))
text = paste("# ", self$title, anchor(self$reference), sep = "")
)
if (!is.null(self$outputFolder)) {
dir.create(file.path(self$workflowFolder, self$outputFolder), showWarnings = FALSE)
Expand Down
30 changes: 15 additions & 15 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,46 +255,46 @@ messages <- list(
warningNAFoundInPKAnalysisFile = function(filePath) {
paste0(highlight("NaN"), " found in PK analysis file '", highlight(filePath), "'.")
},
warningPKAnalysesMissingIds = function(ids, setName){
warningPKAnalysesMissingIds = function(ids, setName) {
paste0(
"Missing ", highlight("IndividualIds"), " in PKAnalysis file for simulation set '",
"Missing ", highlight("IndividualIds"), " in PKAnalysis file for simulation set '",
highlight(setName), "': ",
paste0("'", highlight(ids), "'", collapse = ", ")
)
},
warningPKAnalysesMissingIds = function(ids, setName){
warningPKAnalysesMissingIds = function(ids, setName) {
paste0(
"Missing ", highlight("IndividualIds"), " in PKAnalysis file for simulation set '",
"Missing ", highlight("IndividualIds"), " in PKAnalysis file for simulation set '",
highlight(setName), "': ",
paste0("'", highlight(ids), "'", collapse = ", ")
)
},
warningMissingFromReferenceSet = function(path, simulationSetName, pkParameters = NULL){
if(is.null(pkParameters)){
warningMissingFromReferenceSet = function(path, simulationSetName, pkParameters = NULL) {
if (is.null(pkParameters)) {
return(
paste0(
"Output path '", highlight(path),
"' was NOT defined for reference simulation set '", highlight(simulationSetName),
"Output path '", highlight(path),
"' was NOT defined for reference simulation set '", highlight(simulationSetName),
"'. Ouptut path and its PK Parameters were added to the list of figures to export."
)
)
}
return(
paste0(
"The following PK Parameters '",
paste(highlight(pkParameters), collapse = "', '"),
"' were NOT defined for the Ouptut path '", highlight(path),
"' in the reference simulation set '", highlight(simulationSetName),
"The following PK Parameters '",
paste(highlight(pkParameters), collapse = "', '"),
"' were NOT defined for the Ouptut path '", highlight(path),
"' in the reference simulation set '", highlight(simulationSetName),
"'. The PK Parameters were added to the list of figures to export."
)
)
},
inconsistentMetaData = function(values, id, dataType = "units"){
inconsistentMetaData = function(values, id, dataType = "units") {
paste0(
"Inconsistent ", highlight(dataType),
"Inconsistent ", highlight(dataType),
" found within Group ID '", highlight(id), "': '",
paste0(highlight(unique(values)), collapse = "', '"), "'."
)
)
},
#----- Info messages ----
runStarting = function(runName, subRun = NULL) {
Expand Down
7 changes: 4 additions & 3 deletions R/plot-task.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ PlotTask <- R6::R6Class(
addTextChunk(
fileName = self$fileName,
text = paste(
"##", self$title, "for", simulationSetName,
anchor(paste0(self$reference, "-", removeForbiddenLetters(simulationSetName)))
"## ", self$title, " for ", simulationSetName,
anchor(paste0(self$reference, "-", removeForbiddenLetters(simulationSetName))),
sep = ""
)
)
for (result in taskResults) {
Expand Down Expand Up @@ -113,7 +114,7 @@ PlotTask <- R6::R6Class(
resetReport(self$fileName)
addTextChunk(
fileName = self$fileName,
text = paste("#", self$title, anchor(self$reference))
text = paste("# ", self$title, anchor(self$reference), sep = "")
)
if (!is.null(self$outputFolder)) {
dir.create(file.path(self$workflowFolder, self$outputFolder), showWarnings = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/population-plot-task.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PopulationPlotTask <- R6::R6Class(
resetReport(self$fileName)
addTextChunk(
fileName = self$fileName,
text = paste("#", self$title, anchor(self$reference))
text = paste("# ", self$title, anchor(self$reference), sep = "")
)
for (result in taskResults) {
# Get both absolute and relative paths for figures and tables
Expand Down
8 changes: 6 additions & 2 deletions R/qualification-ddi.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,10 @@ plotQualificationDDIs <- function(configurationPlan, settings) {
# Subheading result includes anchor tag to be referenced in TOC
textChunk = paste(
paste0(rep("#", sectionLevel + 1), collapse = ""),
" ",
subplotTypeName,
anchor(paste0(sectionID, "-ddi-subunit-", length(ddiResults) + 1))
anchor(paste0(sectionID, "-ddi-subunit-", length(ddiResults) + 1)),
sep = ""
),
includeTextChunk = TRUE
)
Expand All @@ -562,8 +564,10 @@ plotQualificationDDIs <- function(configurationPlan, settings) {
# Subheading result includes anchor tag to be referenced in TOC
textChunk = paste(
paste0(rep("#", sectionLevel + 2), collapse = ""),
" ",
subplotTypeLevel,
anchor(paste0(sectionID, "-ddi-subunit-", length(ddiResults) + 1))
anchor(paste0(sectionID, "-ddi-subunit-", length(ddiResults) + 1)),
sep = ""
),
includeTextChunk = TRUE
)
Expand Down
8 changes: 4 additions & 4 deletions R/simulation-set.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SimulationSet <- R6::R6Class(
validateIsString(simulationFile)
validateIsFileExtension(simulationFile, "pkml")
validateIsUnitFromDimension(timeUnit, "Time")

# For optional input, usually null is allowed
# but not here as it would mean that nothing would be reported
validateIsIncluded(c(applicationRanges), ApplicationRanges)
Expand All @@ -66,22 +66,22 @@ SimulationSet <- R6::R6Class(
validateIsFileExtension(massBalanceFile, "json")
self$massBalanceSettings <- jsonlite::fromJSON(massBalanceFile, simplifyVector = FALSE)[["MassBalancePlots"]]
}

# Before loading the simulation, check if the file exists
validateFileExists(simulationFile)
simulation <- ospsuite::loadSimulation(simulationFile, addToCache = FALSE)
validateVector(minimumSimulationEndTime, type = "numeric", valueRange = c(0, Inf), nullAllowed = TRUE)
# Following checks require simulation info
endTime <- max(
minimumSimulationEndTime,
minimumSimulationEndTime,
ospsuite::toUnit(
quantityOrDimension = "Time",
values = simulation$outputSchema$endTime,
targetUnit = timeUnit
)
)
validateVectorRange(timeOffset, type = "numeric", valueRange = c(0, endTime))

# Test and validate outputs and their paths
validateOutputObject(c(outputs), simulation, nullAllowed = TRUE)
validateDataSource(dataSource, c(outputs), nullAllowed = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/utilities-goodness-of-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ getResidualsPlotResultsInGroup <- function(data, metaData, outputId, structureSe
plotConfiguration = qqPlotConfiguration
)
goodnessOfFitCaptions[[resultId$resQQPlot]] <- getGoodnessOfFitCaptions(structureSet, "resQQPlot", residualScale, settings)

return(list(
plots = goodnessOfFitPlots,
captions = goodnessOfFitCaptions
Expand Down
2 changes: 1 addition & 1 deletion R/utilities-mass-balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ plotMeanMassBalance <- function(structureSet, settings = NULL) {
sectionId <- defaultFileNames$resultID(length(massBalanceResults) + 1, "mass_balance")
massBalanceResults[[sectionId]] <- saveTaskResults(
id = sectionId,
textChunk = paste("###", plotSettings$Name, anchor(sectionId)),
textChunk = paste("### ", plotSettings$Name, anchor(sectionId), sep = ""),
includeTextChunk = TRUE
)
}
Expand Down
Loading

0 comments on commit 7371e16

Please sign in to comment.