Skip to content

Clean up and generate base docu with claude#6

Merged
VanessaBa merged 3 commits into
mainfrom
clean-up-with-claude
May 15, 2026
Merged

Clean up and generate base docu with claude#6
VanessaBa merged 3 commits into
mainfrom
clean-up-with-claude

Conversation

@VanessaBa

@VanessaBa VanessaBa commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced TB PBPK/PD modeling platform with dose-sensitivity analysis workflow.
    • Added Quarto reports for TB scenarios and dose-sensitivity visualization.
    • Implemented modular drug parameter transformation and PKML module generation.
  • Documentation

    • Comprehensive platform guides, model documentation, and step-by-step workflow instructions.
    • Added data schemas and results directory specifications.
  • Refactor

    • Reorganized simulation runners for improved modularity and configuration flexibility.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 1e298e0d-203b-4fa0-986b-22961832a488

📥 Commits

Reviewing files that changed from the base of the PR and between 0750265 and 57e86b1.

⛔ Files ignored due to path filters (1)
  • Data/EBA_dose.csv is excluded by !**/*.csv
📒 Files selected for processing (38)
  • Code/InputCode/TestParameters.R
  • Code/README.md
  • Code/Scenarios/defaultScenario.R
  • Code/runDoseSensitivity.R
  • Code/runTBScenarios.R
  • Code/utils.R
  • Code/utils/doseSensitivity.R
  • Code/utils/generateDrugModulePkmls.R
  • Code/utils/simulate-scenarios.R
  • Code/utils/transformDrugParams.R
  • Code/utils/utils.R
  • Code/workflowConfig.R
  • Data/README.md
  • Data/originalParameters/EMB.txt
  • Data/originalParameters/INH.txt
  • Data/originalParameters/MOX.txt
  • Data/originalParameters/PZA.txt
  • Data/originalParameters/RIF.txt
  • Data/originalParameters/RPT.txt
  • Data/originalParameters/RPT2.txt
  • Data/originalParameters/RPT3.txt
  • Documentation/TB - PZA - mono.md
  • Documentation/TB model documentation.md
  • Documentation/TB model with generic drug.md
  • Documentation/Tuberculosis_workflow.qmd
  • Models/PKML/README.md
  • Models/README.md
  • Models/Simulations/TB - BMHRZE.pkml
  • NEWS.md
  • ProjectConfiguration.json
  • README.md
  • Reports/README.md
  • Reports/TBScenarios_report.qmd
  • Reports/TB_report.qmd
  • Reports/doseSensitivity_report.qmd
  • Reports/references.bib
  • Results/SimulationResults/README.md
  • utils/utils.R
💤 Files with no reviewable changes (6)
  • Code/InputCode/TestParameters.R
  • Reports/TB_report.qmd
  • utils/utils.R
  • Code/Scenarios/defaultScenario.R
  • Code/utils.R
  • ProjectConfiguration.json

📝 Walkthrough

Walkthrough

This PR transforms a generic ESQLabs R project template into a complete tuberculosis PBPK/PD modeling platform. It reorganizes utility functions into modular helpers, parameterizes two core simulation scripts via centralized configuration, adds drug parameter datasets, provides comprehensive technical and workflow documentation, and includes Quarto reports for scenario and dose-sensitivity analysis visualization.

Changes

TB Platform Implementation

Layer / File(s) Summary
Core Utility Functions and Specialized Modules
Code/utils/utils.R, Code/utils/doseSensitivity.R, Code/utils/generateDrugModulePkmls.R, Code/utils/transformDrugParams.R
New Code/utils/utils.R provides core helpers: exportPlotsToPNG, createResults, combineResults, format_plot, my_theme, and calculateEBA. Three specialized modules handle dose-sensitivity orchestration (runDoseSensitivity, plotDoseSensitivity), template-driven PKML generation, and drug parameter parsing/transformation into Excel workbooks.
Centralized Workflow Configuration
Code/workflowConfig.R
Single-source-of-truth configuration file defining drug names, model types, dose-sensitivity controls, parameterized drugConfigs list (scenario names, dose vectors, paths, units), and TB scenario selection and output folder settings.
Dose Sensitivity Script Parameterization
Code/runDoseSensitivity.R
Refactored from hard-coded per-drug definitions to drugConfigs-driven loop; conditional control-flag initialization; streamlined data preparation with pivoting, joining, and filtering by drug/dose/suffix; active PNG export to Results/Figures/.
TB Scenarios Script Parameterization
Code/runTBScenarios.R
Refactored to support optional scenario selection by name or index; configurable result loading vs. simulation; extended plot generation with grid-name iteration and tryCatch error handling; conditional theme/formatting and PNG export.
Drug Parameter Data Files and Documentation
Data/originalParameters/*.txt, Data/README.md
Added eight drug parameter sets (EMB, INH, MOX, PZA, RIF, RPT, RPT2, RPT3) with kinetic constants, kill/grow parameters, and scaling factors; expanded Data README with detailed EBA_dose.csv schema and data organization.
End-to-End Workflow Documentation
Documentation/Tuberculosis_workflow.qmd
Quarto document with workflow overview table and four step-by-step sections: drug parameter transformation, PKML generation, dose-sensitivity analysis, and TB scenario simulations, each with code examples and parameter guidance.
TB Model Technical Documentation
Documentation/TB model documentation.md, Documentation/TB model with generic drug.md, Documentation/TB - PZA - mono.md
Three markdown files documenting TB model architecture (growth/immune modules, drug effects), a generic drug scaffold template with compartments/processes/parameterization, and a complete PZA monotherapy specification with PK/PD dynamics, dosing, and integration recipes.
TB Scenario and Dose-Sensitivity Reports
Reports/TBScenarios_report.qmd, Reports/doseSensitivity_report.qmd
Two Quarto reports: TBScenarios_report renders pre-simulated or generated scenario plots per monotherapy and combination regimens with conditional error handling; doseSensitivity_report renders tables and faceted log-scale plots comparing simulated EBA against dose/Cmax/Cavg with observed clinical data.
Project-Level Documentation and Configuration
README.md, NEWS.md, ProjectConfiguration.json, Models/README.md, Results/SimulationResults/README.md, Reports/README.md, Reports/references.bib
Updated root README with TB platform overview, exact prerequisites (R 4.5.0, Quarto ≥1.4), getting-started steps, and four-step workflow guidance; replaced NEWS.md with TB platform v1.0.0 release notes; updated scenario entries in ProjectConfiguration.json; expanded Models and Results READMEs with folder structure and CSV schemas; added report enumeration and rendering instructions; added BibTeX references.
Removed Legacy Code
Code/utils.R, Code/Scenarios/defaultScenario.R, Code/InputCode/TestParameters.R, Reports/TB_report.qmd
Emptied Code/utils.R (replaced by Code/utils/utils.R); removed defaultScenario function; removed getTestParameters helper; deleted old TB_report.qmd and its simulation/plotting chunks.

🎯 4 (Complex) | ⏱️ ~45 minutes

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request establishes a comprehensive PBPK/PD simulation platform for anti-tuberculosis drugs, introducing automated workflows for parameter transformation, model generation, and clinical scenario reporting. The changes include refactored simulation scripts for improved maintainability and extensive documentation. Feedback identifies several logic errors in data filtering where numeric values are incorrectly compared to time-window strings, as well as fragile hardcoded plot layer indexing. Additionally, improvements are suggested for robust parameter parsing and ensuring correct data types during EBA calculations.

Comment thread Code/utils/utils.R
Comment on lines +83 to +86
observedData <- esqlabsR::loadObservedData(
projectConfiguration = projectConfiguration,
sheets = NULL
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The createResults function accepts dataSheets and customDataSets as arguments, but the implementation ignores them. loadObservedData is called with sheets = NULL, and customDataSets are never merged into the observedData list. This breaks the ability to load specific data sheets or provide custom datasets.

  observedData <- esqlabsR::loadObservedData(
    projectConfiguration = projectConfiguration,
    sheets = dataSheets
  )
  if (!is.null(customDataSets)) {
    observedData[names(customDataSets)] <- customDataSets
  }

Comment thread Code/runDoseSensitivity.R
combined_noBDQ <- combined_cavg %>% filter(Drug != 'BDQ')
observedEBAs_long_noBDQ <- observedEBAs_long %>%
filter(Drug != 'BDQ') %>%
filter(EBA_value != '2-14')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The filter filter(EBA_value != '2-14') appears to be a logic error. EBA_value contains numeric log-reduction values, while '2-14' refers to a time window suffix. This filter was likely intended to exclude the EBA2-14 type by checking the suffix column.

  filter(suffix != '2-14')

Comment thread Code/runTBScenarios.R
plots[[p]] <- plots[[p]] + my_theme(1)
plots[[p]]$layers[[7]]$aes_params$size <- 5
if (length(plots[[p]]$layers) >= 7) {
plots[[p]]$layers[[7]]$aes_params$size <- 5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Modifying plot layers using a hardcoded index (layers[[7]]) is fragile. If the plot structure changes (e.g., due to updates in createPlotsFromExcel or different data inputs), this will target the wrong layer or fail. It is safer to iterate through layers and check the geom type or use the format_plot helper function.


combined_noBDQ <- combined_cavg %>% filter(Drug != 'BDQ')
observed_noBDQ <- observedEBAs_long %>%
filter(Drug != 'BDQ', EBA_value != '2-14')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The filter EBA_value != '2-14' is likely incorrect as EBA_value is numeric. It should probably filter on the suffix column to exclude the 2–14 day time window.

    filter(Drug != 'BDQ', suffix != '2-14')

keys <- vapply(parts, function(x) x[2], "")
vals <- vapply(parts, function(x) x[3], "")

drug <- vals[keys == "name"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assignment drug <- vals[keys == "name"] assumes the key "name" exists exactly once in the input file. If it is missing or duplicated, the subsequent data.frame construction will fail due to a dimension mismatch. Consider using a more robust selection like vals[which(keys == "name")[1]].

Comment thread Code/utils/utils.R
relConc <- dfRes %>%
filter(Time > ebaStartTimes[e], Time < ebaEndTimes[e]) %>%
select(all_of(concPaths))
cmaxs[e] <- max(relConc)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since relConc is a data frame (result of select()), calling max(relConc) may lead to unexpected results or errors depending on the R version and data structure. It is safer to use unlist() to ensure the maximum is calculated across all values in the selected columns, consistent with the mean(unlist(relConc)) call on the next line.

      cmaxs[e] <- max(unlist(relConc))


combined_noBDQ <- combined_cavg %>% filter(Drug != 'BDQ')
observedEBAs_long_noBDQ <- observedEBAs_long %>%
filter(Drug != 'BDQ', EBA_value != '2-14')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The filter EBA_value != '2-14' is likely a typo for suffix != '2-14'. EBA_value contains the numeric results of the simulation, not the time window labels.

  filter(Drug != 'BDQ', suffix != '2-14')

@VanessaBa
VanessaBa merged commit ebce434 into main May 15, 2026
2 checks passed
@VanessaBa
VanessaBa deleted the clean-up-with-claude branch May 29, 2026 15:14
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 this pull request may close these issues.

1 participant