| Title: | Pedigree-Based Heritability Estimation for Family Cohort Studies |
|---|---|
| Description: | Provides profile-likelihood variance-components estimation of narrow-sense heritability (h2) for quantitative traits in family cohort studies. Additive genetic relationship matrices are built from pedigrees via 'kinship2'. Phenotypes are inverse-normal transformed internally. Likelihood-ratio tests use a one-sided chi-squared boundary correction equivalent to SOLAR Eclipse. Ninety-five percent confidence intervals are derived from the profile likelihood rather than Wald approximations. Batch estimation over many traits returns tidy data frames ready for downstream visualisation (forest plots, heatmaps). |
| Authors: | Lucas França [aut, cre] (ORCID: <https://orcid.org/0000-0003-0853-1319>), Mario Leocadio-Miguel [aut] (ORCID: <https://orcid.org/0000-0002-7248-3529>) |
| Maintainer: | Lucas França <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-07-02 00:41:41 UTC |
| Source: | https://github.com/circadia-bio/R-itable |
Constructs the additive genetic relationship matrix A (= 2 x kinship matrix) for a set of study subjects, using a pedigree that may include additional founder parents not in the study sample.
build_grm( ped_df, study_ids = NULL, id_col = "id", pat_col = "pat", mom_col = "mom", sex_col = "sex" )build_grm( ped_df, study_ids = NULL, id_col = "id", pat_col = "pat", mom_col = "mom", sex_col = "sex" )
ped_df |
A data frame with at least the columns |
study_ids |
Character or integer vector of IDs for the study subjects
whose sub-matrix should be extracted. Defaults to all IDs in |
id_col, pat_col, mom_col, sex_col
|
Column names for the four required
pedigree fields. Defaults are |
The function calls kinship2::kinship() on the full pedigree (including
founders), then multiplies by 2 to obtain the additive relationship matrix,
and finally subsets to study_ids. Including founders in the pedigree
ensures that kinship coefficients between study subjects connected only
through founders are estimated correctly.
A symmetric numeric matrix of dimension
length(study_ids) x length(study_ids), with diagonal entries equal to
1 for non-inbred individuals and row/column names matching study_ids.
# Minimal two-generation pedigree: two couples, four offspring ped <- data.frame( id = 1:8, pat = c(0, 0, 0, 0, 1, 1, 3, 3), mom = c(0, 0, 0, 0, 2, 2, 4, 4), sex = c(1, 2, 1, 2, 1, 2, 1, 2) ) A <- build_grm(ped, study_ids = 5:8) round(A, 3)# Minimal two-generation pedigree: two couples, four offspring ped <- data.frame( id = 1:8, pat = c(0, 0, 0, 0, 1, 1, 3, 3), mom = c(0, 0, 0, 0, 2, 2, 4, 4), sex = c(1, 2, 1, 2, 1, 2, 1, 2) ) A <- build_grm(ped, study_ids = 5:8) round(A, 3)
A convenience wrapper around herit_vc() that iterates over a vector of
trait names, optionally across multiple covariate models, and returns a
tidy data frame.
herit_batch( traits, grm, data, covs_list = NULL, id_col = "IID", min_n = 80L, ci_level = 0.95, .progress = TRUE )herit_batch( traits, grm, data, covs_list = NULL, id_col = "IID", min_n = 80L, ci_level = 0.95, .progress = TRUE )
traits |
Character vector of trait column names in |
grm |
Numeric matrix: additive genetic relationship matrix as returned
by |
data |
Data frame containing ID, trait, and covariate columns. |
covs_list |
A named list of covariate vectors, where each element
defines one covariate model. If |
id_col |
Name of the individual ID column. Default |
min_n |
Minimum sample size to attempt estimation. Default |
ci_level |
Profile-likelihood CI level. Default |
.progress |
Logical. Show a cli progress bar. Default |
A data frame (tibble-compatible) with one row per successfully
fitted model and columns: label, trait, covariates, n, h2,
se, ci_lo, ci_hi, pval, sigma2_a, sigma2_e.
Failed / skipped models are silently omitted.
herit_vc(), build_grm(), plot_forest()
## Not run: A <- build_grm(my_pedigree, study_ids = my_data$IID) res <- herit_batch( traits = c("bmi", "systolic_bp", "hdl"), grm = A, data = my_data, covs_list = list( unadj = NULL, cov1 = c("age", "sex"), cov2 = c("age", "sex", "age2") ) ) # Significant adjusted models subset(res, grepl("cov2", label) & pval < 0.05) ## End(Not run)## Not run: A <- build_grm(my_pedigree, study_ids = my_data$IID) res <- herit_batch( traits = c("bmi", "systolic_bp", "hdl"), grm = A, data = my_data, covs_list = list( unadj = NULL, cov1 = c("age", "sex"), cov2 = c("age", "sex", "age2") ) ) # Significant adjusted models subset(res, grepl("cov2", label) & pval < 0.05) ## End(Not run)
Estimates narrow-sense heritability (h²) for a single quantitative trait using a profile-likelihood variance-components approach equivalent to SOLAR Eclipse. The phenotype is inverse-normal transformed internally.
herit_vc( trait, grm, data, covs = NULL, id_col = "IID", label = NULL, min_n = 80L, ci_level = 0.95, verbose = TRUE )herit_vc( trait, grm, data, covs = NULL, id_col = "IID", label = NULL, min_n = 80L, ci_level = 0.95, verbose = TRUE )
trait |
Character string: name of the trait column in |
grm |
Numeric matrix: the additive genetic relationship matrix for
all individuals in |
data |
Data frame containing |
covs |
Character vector of covariate column names, or |
id_col |
Name of the individual ID column in |
label |
Optional string label for this model (used in batch output).
If |
min_n |
Minimum number of complete observations required to attempt
estimation. Models with fewer observations return |
ci_level |
Confidence level for the profile-likelihood interval.
Default |
verbose |
Logical. Print progress to the console. Default |
Model: Omega = sigma2_p [h2 A + (1 - h2) I_n]
Optimisation: eigendecomposition of A followed by 1-D
profile-likelihood optimisation over h2 in (0, 1) using a coarse grid
to seed stats::optimize().
LRT: one-sided chi-squared(1) boundary correction – the null is on the boundary of the parameter space (h2 = 0), so the p-value is halved relative to a standard chi-squared test. This matches the SOLAR Eclipse convention.
CIs: derived by uniroot() on the profile log-likelihood, falling
back to a Wald interval if the root-finding fails.
A named list with elements:
labelModel label.
traitTrait name.
covariatesCovariate names joined by "+", or "".
nSample size after dropping missing values.
h2MLE of narrow-sense heritability.
seStandard error from profile-likelihood curvature (Wald).
ci_lo, ci_hi
Profile-likelihood confidence interval bounds.
pvalOne-sided LRT p-value with chi-squared(1) boundary correction.
var_covariatesProportion of phenotypic variance explained by
fixed-effect covariates (R² on INT-transformed phenotype). NA for
unadjusted models. Corresponds to the "variance explained" column in
Leocadio-Miguel et al. (2025).
sigma2_aAdditive genetic variance (sigma²_g in SOLAR notation).
sigma2_eResidual environmental variance (sigma²_e).
Returns NULL if n < min_n or if the GRM subset is degenerate.
build_grm(), herit_batch(), int_transform()
## Not run: # Build GRM then estimate heritability A <- build_grm(my_pedigree, study_ids = my_data$IID) res <- herit_vc("bmi", grm = A, data = my_data, covs = c("age", "sex", "age2")) str(res) ## End(Not run)## Not run: # Build GRM then estimate heritability A <- build_grm(my_pedigree, study_ids = my_data$IID) res <- herit_vc("bmi", grm = A, data = my_data, covs = c("age", "sex", "age2")) str(res) ## End(Not run)
Applies a rank-based inverse-normal transformation (INT) to a numeric vector, placing empirical quantiles onto a standard normal scale.
int_transform(x, ties = "average")int_transform(x, ties = "average")
x |
Numeric vector. |
ties |
Method passed to |
The Blom-style formula used is:
where is the rank of observation and is the
number of non-missing observations. This is the standard transformation used
in SOLAR Eclipse and most variance-components heritability software.
A numeric vector of the same length as x, with NAs in the same
positions and non-missing values transformed to approximate normality.
set.seed(1) x <- rexp(200, rate = 0.5) # right-skewed hist(x, main = "Raw") hist(int_transform(x), main = "INT")set.seed(1) x <- rexp(200, rate = 0.5) # right-skewed hist(x, main = "Raw") hist(int_transform(x), main = "INT")
Produces a ggplot2 forest plot from the output of herit_batch() or a
list of herit_vc() results coerced to a data frame.
plot_forest( results, model_filter = NULL, colour_by = "trait", sig_threshold = 0.05, title = NULL, x_limits = c(0, 1) )plot_forest( results, model_filter = NULL, colour_by = "trait", sig_threshold = 0.05, title = NULL, x_limits = c(0, 1) )
results |
Data frame as returned by |
model_filter |
Optional character vector of model name substrings to
keep (matched against |
colour_by |
Column to colour points by. Default |
sig_threshold |
Numeric. Traits with |
title |
Optional plot title string. |
x_limits |
Numeric vector of length 2 for the x-axis range.
Default |
Requires ggplot2 (listed in Suggests). An informative error is thrown
if it is not installed.
A ggplot2::ggplot object. Colours follow the Ritable_colours
palette by default (pink #FE9EC7 and blue #44ACFF as the primary pair).
herit_batch(), Ritable_colours
## Not run: res <- herit_batch(c("bmi", "hdl", "systolic_bp"), grm = A, data = my_data, covs_list = list(unadj = NULL, cov2 = c("age", "sex", "age2"))) plot_forest(res, model_filter = "cov2", title = "Adjusted heritability") ## End(Not run)## Not run: res <- herit_batch(c("bmi", "hdl", "systolic_bp"), grm = A, data = my_data, covs_list = list(unadj = NULL, cov2 = c("age", "sex", "age2"))) plot_forest(res, model_filter = "cov2", title = "Adjusted heritability") ## End(Not run)
A named character vector of the four brand colours used throughout R-itable figures and documentation.
Ritable_coloursRitable_colours
An object of class character of length 4.
pink#FE9EC7 – primary accent; significant traits, sex effect
blue#44ACFF – primary brand colour; estimates, CI lines
sky#89D4FF – secondary blue; muted elements, CI shading
cream#F9F6C4 – soft highlight; code backgrounds
Ritable_coloursRitable_colours