Package 'ordinalMIC'

Title: Minimum Inhibitory Concentration Estimation from Ordinal Regression Models
Description: Provides tools to estimate minimum inhibitory concentration (MIC) and conduct rigorous pairwise comparisons (delta, fold‑change, and difference of difference tests) from cumulative‑link models fitted with 'ordinal::clm'.
Authors: Carson Stacy [aut, cre]
Maintainer: Carson Stacy <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0
Built: 2026-05-13 07:35:08 UTC
Source: https://github.com/clstacy/ordinalMIC

Help Index


autoplot method for mic_solve objects

Description

Quick ggplot2 visualisations of the main outputs from mic_solve(). Three panels are supported:

  • "mic" - forest plot of group-wise MIC estimates with asymmetric CIs.

  • "delta" - forest plot of deltaMIC pairwise differences.

  • "ratio" - forest plot of MIC ratios (log scale).

Usage

## S3 method for class 'mic_solve'
autoplot(
  object,
  type = c("mic", "delta", "ratio", "DoD_delta", "DoD_ratio"),
  x = NULL,
  color_by = NULL,
  dot_size = 0.5,
  ...
)

Arguments

object

An object returned by mic_solve().

type

One of "mic", "delta", or "ratio", "DoD_delta", or "DoD_ratio".

x

Variable for x axis plotting

color_by

Optional column name used to color and dodge replicate points. Default: first column in newdata.

dot_size

Size of the dots in the dotplot. Default: 0.5.

...

Additional arguments passed to ggplot2::ggplot().

Value

A ggplot object.

Author(s)

Carson Stacy

Examples

if (requireNamespace("ordinal", quietly = TRUE) &&
    requireNamespace("ggplot2", quietly = TRUE)) {
  df <- data.frame(score  = ordered(sample(0:4, 120, TRUE)),
                   conc   = runif(120, 0, 4),
                   strain = factor(sample(c("A","B"), 120, TRUE)))
  fit <- ordinal::clm(score ~ strain * log1p(conc), data = df)
  res <- mic_solve(fit, expand.grid(strain = levels(df$strain)),
                   conc_name = "conc")
  ggplot2::autoplot(res, type = "mic")
}

Estimate MICs and Compare Groups

Description

High‑level wrapper that returns:

  • delta_mic_results – additive pairwise differences (Δ‑MIC).

  • ratio_mic_results – multiplicative pairwise ratios.

  • dod_ratio_resultsdifference‑of‑differences on the ratio scale (ratio‑of‑ratios, a classic interaction on the log scale).

  • dod_delta_resultsdifference‑of‑differences on the additive scale (Δ of Δs).

Usage

mic_solve(
  clm_fit,
  newdata = NULL,
  conc_name,
  transform_fun = log1p,
  inv_transform_fun = expm1,
  alpha = 0.05,
  compare_pairs = "all",
  pvalue_scale = c("lp", "logmic")
)

Arguments

clm_fit

Fitted object from ordinal::clm().

newdata

Data frame with factor combinations to evaluate.

conc_name

Character string giving the raw concentration column.

transform_fun

Transformation used in the model (default log1p).

inv_transform_fun

Inverse transformation (default expm1).

alpha

Confidence‑level significance (default 0.05).

compare_pairs

One of "all" (default) to retain every pairwise comparison, or "share_any" to exclude contrasts where the two groups share no covariate levels in newdata.

pvalue_scale

Which pivot the main P_value uses for pairwise tests: "lp" (difference in lp = log1p(MIC), recommended for calibration) or "logmic" (current Wald on log(MIC) for ratios and MIC scale for deltas).

Value

An object of class "mic_solve" containing the tables above plus mic_estimates.

Examples

if (requireNamespace("ordinal", quietly = TRUE)) {
  ## Toy ordinal dataset
  set.seed(1)
  fit <- ordinal::clm(score ~ strain * treatment + log1p(conc), data = yeast_df)
  res <- mic_solve(fit, conc_name = "conc")
  head(res$ratio_mic_results)
}

tidy method for mic_solve objects

Description

tidy method for mic_solve objects

Usage

tidy.mic_solve(
  x,
  table = c("mic", "delta", "ratio", "DoD_delta", "DoD_ratio"),
  ...
)

Arguments

x

An object of class mic_solve.

table

A character string specifying which table to return. Options are "mic", "delta", "ratio", "DoD_delta", and "DoD_ratio".

...

Additional arguments (not used).

Value

A tibble containing the requested table from the mic_solve object.


Simulated Yeast Stress-Survival Data

Description

An example dataset with ordinal spot scores (0 = no growth … 4 = full growth) for treated and untreated wild-type and mutant yeast across a peroxide gradient.

Usage

data(yeast_df)

Format

A data frame with 132 rows and 4 variables:

score

Ordered factor 0 < 1 < 2 < 3 < 4

conc

Numeric concentration units

strain

Factor: "WT" or "Mut"

treatment

Factor: "None" or "Salt"

rep

Replicate id (integer)

Examples

data(yeast_df)
head(yeast_df)