Skip to contents

For a single variant (row index), computes deviation contrasts (each condition vs grand mean) and all pairwise contrasts from the mash posterior mean and covariance. Supports condition grouping for weighted contrasts.

Usage

fit_mash_contrast(
  index,
  orig_mean,
  posterior_mean,
  posterior_vcov,
  grouping = NULL
)

Arguments

index

Integer row index of the variant in the posterior matrices.

orig_mean

Matrix of original effect sizes (variants x conditions). Used to determine which conditions are "tested" (non-zero).

posterior_mean

Matrix of mash posterior means (variants x conditions).

posterior_vcov

3D array of posterior covariance matrices (conditions x conditions x variants).

grouping

Named integer vector mapping condition names to group IDs. Conditions with the same positive group ID are treated as replicates (e.g., multiple datasets for the same cell type). Use 0 for ungrouped. If NULL (default), all conditions are treated independently.

Value

A single-row data.frame with columns mean_contrast_*, se_contrast_*, p_contrast_* for both deviation and pairwise contrasts. Returns NULL if fewer than 2 tested conditions.