Skip to contents

Formats a tidy data frame of narrow-sense heritability estimates (h2) into a publication-ready table. Column-name defaults match the output of R-itable::herit_batch() directly.

Column-name arguments accept character strings (quoted names).

Usage

tbl_heritability(
  data,
  metric = "trait",
  h2 = "h2",
  ci_low = "ci_lo",
  ci_high = "ci_hi",
  p = "pval",
  sigma2_a = NULL,
  sigma2_e = NULL,
  model = NULL,
  domains = list(),
  fdr = FALSE,
  fdr_within = NULL,
  digits = 2,
  p_digits = 3,
  output = c("gt", "html", "latex")
)

Arguments

data

A tidy data frame with one row per trait x covariate model.

metric

Character string. Name of the trait/phenotype column. Default "trait" (matches herit_batch()).

h2

Character string. Name of the h2 estimate column. Default "h2".

ci_low

Character string. Name of the lower 95% CI bound column. Default "ci_lo" (matches herit_batch()).

ci_high

Character string. Name of the upper 95% CI bound column. Default "ci_hi" (matches herit_batch()).

p

Character string. Name of the one-sided LRT p-value column. Default "pval" (matches herit_batch()).

sigma2_a

Character string or NULL. Name of the additive genetic variance column. Default NULL.

sigma2_e

Character string or NULL. Name of the residual variance column. Default NULL.

model

Character string or NULL. Name of a column identifying covariate models. Pass "covariates" when using herit_batch() output. Default NULL.

domains

A named list mapping trait names to domain/section labels.

fdr

Logical. Apply BH FDR correction (default FALSE).

fdr_within

Character string or NULL. Column name to group FDR correction within.

digits

Integer. Decimal places for h2 and variance components (default 2).

p_digits

Integer. Decimal places for p-values (default 3).

output

Character string. One of "gt" (default), "html", or "latex".

Value

A clerk_tbl object with type "heritability".

Examples

tbl_heritability(
  clerk_h2_example,
  model    = "covariates",
  sigma2_a = "sigma2_a",
  sigma2_e = "sigma2_e",
  fdr      = TRUE,
  output   = "gt"
) |> clerk_render(title = "Heritability estimates for cortical shape metrics")
Heritability estimates for cortical shape metrics
covariates 95% CI p σ²a σ²e p (FDR)
All variables
K (tension) unadj 0.48 [0.28, 0.70] <0.001 0.31 0.34 <0.001
S (shape) unadj 0.73 [0.57, 0.88] <0.001 0.47 0.18 <0.001
I (isometric) unadj 0.45 [0.27, 0.64] <0.001 0.29 0.36 <0.001
K (tension) cov1 0.61 [0.45, 0.79] <0.001 0.40 0.25 <0.001
S (shape) cov1 0.81 [0.62, 1.00] <0.001 0.53 0.12 <0.001
I (isometric) cov1 0.69 [0.54, 0.87] <0.001 0.45 0.20 <0.001
K (tension) cov2 0.62 [0.40, 0.82] <0.001 0.40 0.25 <0.001
S (shape) cov2 0.84 [0.67, 1.00] <0.001 0.55 0.10 <0.001
I (isometric) cov2 0.67 [0.48, 0.83] <0.001 0.44 0.21 <0.001
K (tension) cov3 0.63 [0.46, 0.79] <0.001 0.41 0.24 <0.001
S (shape) cov3 0.81 [0.59, 0.99] <0.001 0.53 0.12 <0.001
I (isometric) cov3 0.67 [0.46, 0.88] <0.001 0.44 0.21 <0.001