Package 'pharmax.viz'

Title: Pharmacometric Visualization for the pharmax Ecosystem
Description: One-line pharmacometric diagnostic plots with modern aesthetics. Creates goodness-of-fit panels, spaghetti plots, and publication-ready exports with consistent theming for pharmacometric workflows.
Authors: Malek Okour
Maintainer: Malek Okour <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0.9000
Built: 2026-05-27 11:01:02 UTC
Source: https://github.com/pharmax-org/pharmax

Help Index


pharmax color palette

Description

pharmax color palette

Usage

px_colors(n = 8)

Arguments

n

Number of colors.

Value

Character vector of hex colors.


Forest plot for estimates and intervals

Description

Forest plot for estimates and intervals

Usage

px_forest(
  data,
  term = "term",
  estimate = "estimate",
  lower = "lower",
  upper = "upper",
  reference = 0,
  mode = "light"
)

Arguments

data

Data frame with estimate and interval columns.

term

Term label column.

estimate

Estimate column.

lower

Lower interval column.

upper

Upper interval column.

reference

Reference line value.

mode

Theme mode passed to theme_pharmax().

Value

A ggplot2 object.


Goodness-of-fit diagnostic panel

Description

Creates a four-panel diagnostic plot: DV vs PRED, DV vs IPRED, CWRES vs TIME, and CWRES vs PRED.

Usage

px_gof(data, log_scale = TRUE, mode = "light")

Arguments

data

Data frame with at least DV and PRED columns.

log_scale

Use log10 axes for observed-vs-predicted panels.

mode

Theme mode passed to theme_pharmax().

Value

A patchwork plot object.


NPDE diagnostic panel

Description

NPDE diagnostic panel

Usage

px_npde(
  data,
  npde = "NPDE",
  time = "TIME",
  prediction = "PRED",
  mode = "light"
)

Arguments

data

Data frame containing an NPDE-like column.

npde

NPDE column name.

time

Optional time column.

prediction

Optional prediction column.

mode

Theme mode passed to theme_pharmax().

Value

A patchwork plot object.


Compose pharmax plots

Description

Compose pharmax plots

Usage

px_plot_grid(
  ...,
  ncol = 2,
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  mode = "light"
)

Arguments

...

ggplot2 or patchwork plots, or a single list of plots.

ncol

Number of columns.

title

Optional grid title.

subtitle

Optional grid subtitle.

caption

Optional grid caption.

mode

Theme mode passed to theme_pharmax().

Value

A patchwork plot object.


Residual diagnostic panel

Description

Creates residual-vs-time, residual-vs-prediction, histogram, and QQ panels.

Usage

px_residuals(
  data,
  residual = NULL,
  time = "TIME",
  prediction = "PRED",
  mode = "light"
)

Arguments

data

Data frame containing residual columns.

residual

Residual column. Auto-detects CWRES, IWRES, then RES.

time

Time column used for residual-vs-time when available.

prediction

Prediction column used for residual-vs-prediction when available.

mode

Theme mode passed to theme_pharmax().

Value

A patchwork plot object.


Save a pharmax plot

Description

Save a pharmax plot

Usage

px_save(plot, filename, width = 8, height = 6, dpi = 300, ...)

Arguments

plot

A ggplot2 or patchwork plot.

filename

Output filename.

width

Width in inches.

height

Height in inches.

dpi

Resolution.

...

Additional arguments passed to ggplot2::ggsave().

Value

The input filename, invisibly.


Individual PK concentration-time profiles

Description

Individual PK concentration-time profiles

Usage

px_spaghetti(
  data,
  group = NULL,
  log_y = FALSE,
  facet_by = NULL,
  highlight_ids = NULL,
  mode = "light"
)

Arguments

data

Data frame with ID, TIME, and DV columns.

group

Optional grouping variable for color.

log_y

Use a log10 y-axis.

facet_by

Optional column to facet by.

highlight_ids

Optional vector of subject IDs to highlight.

mode

Theme mode passed to theme_pharmax().

Value

A ggplot2 object.


Lightweight visual predictive check

Description

Lightweight visual predictive check

Usage

px_vpc(
  data,
  time = "TIME",
  observed = "DV",
  simulated = "SIM",
  bins = NULL,
  probs = c(0.05, 0.5, 0.95),
  mode = "light"
)

Arguments

data

Data frame with observed and simulated values.

time

Time column.

observed

Observed concentration column.

simulated

Simulated concentration column.

bins

Number of time bins. If NULL, exact time values are used.

probs

Quantiles to show for observed and simulated values.

mode

Theme mode passed to theme_pharmax().

Value

A ggplot2 object.


pharmax color scale for ggplot2

Description

pharmax color scale for ggplot2

Usage

scale_color_pharmax(...)

scale_fill_pharmax(...)

Arguments

...

Arguments passed to ggplot2::discrete_scale().


The pharmax ggplot2 theme

Description

A clean, publication-ready theme for pharmacometric graphics.

Usage

theme_pharmax(base_size = 12, base_family = "", mode = c("light", "dark"))

Arguments

base_size

Base font size.

base_family

Base font family.

mode

Theme mode, either "light" or "dark".

Value

A ggplot2 theme object.

Examples

library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  theme_pharmax()