An R6 class for analyzing multiple biomarkers simultaneously. Fits separate models for each biomarker using brms and provides comparison tools. Supports hierarchical modeling with group-level effects.

Public fields

titre

Matrix of antibody titres (columns = biomarkers)

infected

Binary vector of infection status (0/1)

biomarker_names

Names of biomarkers

models

List of fitted SeroCOP objects

group

Optional factor vector for hierarchical modeling

Methods


Method new()

Create a new SeroCOPMulti object

Usage

SeroCOPMulti$new(titre, infected, biomarker_names = NULL, group = NULL)

Arguments

titre

Matrix of antibody titres (rows = samples, cols = biomarkers)

infected

Binary vector (0/1) of infection outcomes

biomarker_names

Optional vector of biomarker names

group

Optional grouping variable for hierarchical modeling

Returns

A new SeroCOPMulti object


Method fit_all()

Fit models for all biomarkers

Usage

SeroCOPMulti$fit_all(
  chains = 4,
  iter = 2000,
  warmup = floor(iter/2),
  cores = 1,
  ...
)

Arguments

chains

Number of MCMC chains (default: 4)

iter

Number of iterations per chain (default: 2000)

warmup

Number of warmup iterations (default: iter/2)

cores

Number of cores for parallel processing (default: 1)

...

Additional arguments passed to brms::brm

Returns

Self (invisibly)


Method compare_biomarkers()

Compare biomarkers on AUC and LOO metrics

Usage

SeroCOPMulti$compare_biomarkers()

Returns

Data frame with comparison metrics


Method plot_comparison()

Plot biomarkers on AUC vs LOO plane

Usage

SeroCOPMulti$plot_comparison(add_labels = TRUE)

Arguments

add_labels

Logical, add biomarker labels (default: TRUE)

Returns

A ggplot object


Method plot_all_curves()

Plot all fitted curves

Usage

SeroCOPMulti$plot_all_curves()

Returns

A ggplot object


Method extract_group_parameters()

Extract group-specific parameters for all biomarkers (hierarchical models only)

Usage

SeroCOPMulti$extract_group_parameters()

Returns

A data.frame with group-specific parameter estimates for each biomarker


Method plot_group_curves()

Plot group-specific curves for all biomarkers (hierarchical models only)

Usage

SeroCOPMulti$plot_group_curves(
  title = "Group-Specific Correlates by Biomarker"
)

Arguments

title

Plot title

Returns

A ggplot object (returns NULL if not a hierarchical model)


Method extract_cop_multi()

Extract the correlate of protection conditional on exposure for all biomarkers.

Usage

SeroCOPMulti$extract_cop_multi(correlate_of_risk_list, upper_bound = 0.7)

Arguments

correlate_of_risk_list

List of numeric vectors of correlates of risk for each biomarker.

upper_bound

Numeric value for the upper bound (default: 0.7).

Returns

List of numeric vectors of correlates of protection for each biomarker.


Method clone()

The objects of this class are cloneable with this method.

Usage

SeroCOPMulti$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# Create multi-biomarker data
titres <- matrix(rnorm(600), ncol = 3)
colnames(titres) <- c("IgG", "IgA", "Neutralization")
infected <- rbinom(200, 1, 0.3)

# Initialize and fit
multi_model <- SeroCOPMulti$new(titre = titres, infected = infected)
multi_model$fit_all(chains = 4, iter = 2000)

# Compare biomarkers
multi_model$compare_biomarkers()
multi_model$plot_comparison()

# With hierarchical effects
age_group <- sample(c("Young", "Middle", "Old"), 200, replace = TRUE)
hier_model <- SeroCOPMulti$new(titre = titres, infected = infected, group = age_group)
hier_model$fit_all(chains = 4, iter = 2000)
hier_model$plot_group_curves()
hier_model$extract_group_parameters()
} # }