Skip to content

Commit

Permalink
Apply styler and update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pchelle committed Nov 22, 2023
1 parent 51fefeb commit 896ed75
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 37 deletions.
45 changes: 23 additions & 22 deletions R/utilities-mass-balance.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plotMeanMassBalance <- function(structureSet, settings = NULL) {
for (plotSettings in massBalanceSettings) {
compoundNames <- as.character(plotSettings$Molecules)
# Sub section using settings name
if(!isEmpty(plotSettings$Name)){
if (!isEmpty(plotSettings$Name)) {
sectionId <- defaultFileNames$resultID(length(massBalanceResults) + 1, "mass_balance")
massBalanceResults[[sectionId]] <- saveTaskResults(
id = sectionId,
Expand Down Expand Up @@ -198,7 +198,7 @@ plotMeanMassBalance <- function(structureSet, settings = NULL) {
"mass_balance",
structureSet$simulationSet$simulationSetName
)

pieChartData <- massBalanceData %>%
filter(Time == max(Time)) %>%
mutate(LegendWithPercent = paste(
Expand Down Expand Up @@ -227,10 +227,10 @@ plotMeanMassBalance <- function(structureSet, settings = NULL) {
id = pieChartID,
plot = pieChartPlot,
plotCaption = captions$massBalance$pieChart(
timeCaption,
timeCaption,
metaData$Time$unit,
compoundNames
)
)
)

# Table of mass balance time profiles
Expand Down Expand Up @@ -326,9 +326,9 @@ getMassBalanceDataMapping <- function(plotType) {
}

#' @title getApplicationResults
#' @description Get a data.frame of application results corresponding to
#' @description Get a data.frame of application results corresponding to
#' total drug mass as a function of time.
#' @param applications
#' @param applications
#' list of `Application` objects queried by the method `simulation$allApplicationsFor()`
#' @return A data.frame that includes `time`, `drugMass` and `totalDrugMass` as variables
#' @import ospsuite
Expand All @@ -339,13 +339,13 @@ getApplicationResults <- function(applications) {
applicationResults <- data.frame()
for (application in applications) {
applicationResults <- rbind.data.frame(
applicationResults,
data.frame(
time = application$startTime$value,
drugMass = application$drugMass$value
)
applicationResults,
data.frame(
time = application$startTime$value,
drugMass = application$drugMass$value
)
}
)
}
# Total drug mass is cumulative sum of all the applied drug mass
applicationResults <- applicationResults %>%
mutate(totalDrugMass = cumsum(drugMass))
Expand Down Expand Up @@ -376,25 +376,27 @@ getMassBalanceData <- function(groupings, compoundNames, simulation, simulationR
# Exclusion criteria
excludedMoleculePaths <- NULL
# If ExcludePreviousGroupings is TRUE, exclude molecules from previous groupings
if(group$ExcludePreviousGroupings %||% TRUE){
if (group$ExcludePreviousGroupings %||% TRUE) {
excludedMoleculePaths <- previouslyIncludedMoleculePaths
}
if (!is.null(group$Exclude)) {
excludedMolecules <- ospsuite::getAllMoleculesMatching(group$Exclude, simulation)
excludedMoleculePaths <- c(
excludedMoleculePaths,
sapply(excludedMolecules, function(molecule){molecule$path})
sapply(excludedMolecules, function(molecule) {
molecule$path
})
)
}
includedMolecules <- includedMolecules[!includedMoleculePaths %in% excludedMoleculePaths]
includedMoleculePaths <- setdiff(includedMoleculePaths, excludedMoleculePaths)
if(isEmpty(includedMoleculePaths)) {
if (isEmpty(includedMoleculePaths)) {
warning(messages$noMoleculePathsIncluded(group$Name), call. = FALSE)
next
}
validateMoleculesFromCompounds(includedMolecules, compoundNames)
checkMoleculesAlreadyIncluded(includedMoleculePaths, previouslyIncludedMoleculePaths)

previouslyIncludedMoleculePaths <- c(
previouslyIncludedMoleculePaths,
includedMoleculePaths
Expand All @@ -408,7 +410,7 @@ getMassBalanceData <- function(groupings, compoundNames, simulation, simulationR
}
)
moleculeAmounts <- rowSums(as.data.frame(moleculeAmounts))

massBalanceData <- rbind.data.frame(
massBalanceData,
data.frame(
Expand All @@ -424,7 +426,7 @@ getMassBalanceData <- function(groupings, compoundNames, simulation, simulationR

#' @title defaultMassBalanceGrouping
#' @description Get mass balance default inclusion/exclusion defined as groupings list
#' Default groups are
#' Default groups are
#' \itemize{
#' \item Plasma
#' \item BloodCells
Expand All @@ -440,18 +442,17 @@ getMassBalanceData <- function(groupings, compoundNames, simulation, simulationR
#' @import ospsuite
#' @keywords internal
defaultMassBalanceGroupings <- function(compoundNames) {

groupNames <- c(
"Plasma",
"Plasma",
"BloodCells",
"Interstitial",
"Intracellular",
"Endosome",
"Gallbladder",
"Urine",
"Feces"
)
)

defaultGroupings <- c(
lapply(
groupNames,
Expand Down
2 changes: 1 addition & 1 deletion man/CalculatePKParametersTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/GofPlotTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/GofTaskSettings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/MeanModelWorkflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PlotTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PopulationPlotTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PopulationSensitivityAnalysisTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PopulationSimulationSet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PopulationWorkflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/QualificationTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/QualificationWorkflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/SensitivityAnalysisTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/SimulationTask.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/defaultMassBalanceGroupings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getApplicationResults.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 896ed75

Please sign in to comment.