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)
)

Arguments

results

Data frame as returned by herit_batch(), containing at least columns label, trait, h2, ci_lo, ci_hi, pval.

model_filter

Optional character vector of model name substrings to keep (matched against label). E.g. "cov2" to show only the age + sex + age-squared model.

colour_by

Column to colour points by. Default "trait". Set to NULL for a monochrome plot.

sig_threshold

Numeric. Traits with pval below this threshold are shown with a filled point; others with an open point. Default 0.05.

title

Optional plot title string.

x_limits

Numeric vector of length 2 for the x-axis range. Default c(0, 1).

Value

A ggplot2::ggplot object. Colours follow the itable_colours palette by default (pink #FE9EC7 and blue #44ACFF as the primary pair).

Details

Requires ggplot2 (listed in Suggests). An informative error is thrown if it is not installed.

Examples

if (FALSE) { # \dontrun{
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")
} # }