Skip to content

Conversation

@mduncans
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

@mduncans mduncans left a comment

Choose a reason for hiding this comment

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

PR Review: Transforms Mod (v0.2.0)

Summary

This PR introduces a comprehensive parameter comment and metadata system for NONMEM models

What This PR Does

1. Parameter Comment System (S7 Classes)

Introduces a structured metadata system built on S7 classes:

  • ThetaComment, OmegaComment, SigmaComment: Per-parameter containers storing name, display, description, unit (THETA/SIGMA), parameterization, and associated_theta (OMEGA only)
  • ModelComments: Aggregate container that validates cross-references (e.g., OMEGA associated_theta names must exist in theta)
  • Source tracking: Each field tracks its provenance (model file, lookup file, user-supplied, or default)

2. Comment Parsing Infrastructure

Two parsing modes controlled via pharos.toml:

  • type1 mode: pharos supported type1 comments
  • raw mode (default): Flexible parsing from free-form comment text

Entry point is get_model_parameter_info() which returns a ModelComments object.

3. TOML Lookup Enrichment

  • apply_lookup() / apply_lookup_defaults() fill missing fields of a ModelComments object from external TOML file
  • Case-insensitive matching by parameter name or NONMEM name
  • Provenance tracking records which lookup file provided each value

4. Pharos Parameter Transform Calculations

New functions in src/rust/nonmem/src/output_files/transforms.rs:

  • compute_cv(): Coefficient of variation with transform-aware formulas
  • compute_rse(): Relative standard error percentage
  • compute_ci(): Confidence intervals with optional back-transformation
  • transform_value(): Back-transform estimates to natural scale

All support vectorized inputs with length-1 recycling semantics.

5. Query Helpers

  • get_parameter_names(): NONMEM → user name/display mapping
  • get_parameter_transform() / get_parameter_unit(): Per-parameter metadata retrieval
  • get_theta_names() / get_eta_labels(): Label generation for tables/plots

6. Model Method Improvements

  • summary.hyperion_nonmem_model() added as S3 method
  • str.hyperion_nonmem_model() hides verbose token fields
  • $ and [[ accessors prevent direct access to internal token fields
  • Improved print formatting with build_model_display_parts() refactor

@mduncans mduncans merged commit 4de4c93 into main Jan 28, 2026
6 checks passed
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.

2 participants