Skip to contents

Plots a relatedness matrix using ggplot2 with config options.

Usage

ggRelatednessMatrix(
  mat,
  config = list(),
  interactive = FALSE,
  tooltip_cols = NULL,
  ...
)

ggrelatednessmatrix(
  mat,
  config = list(),
  interactive = FALSE,
  tooltip_cols = NULL,
  ...
)

Arguments

mat

A square numeric matrix of relatedness values (precomputed, e.g., from ped2add).

config

A list of graphical and display parameters. See Details for available options.

interactive

Logical; if TRUE, returns an interactive plotly object.

tooltip_cols

A character vector of column names to include in tooltips.

...

Additional arguments passed to ggplot2 layers.

Value

A ggplot object displaying the relatedness matrix as a heatmap.

Details

Config options include:

color_palette

A vector of colors for the heatmap (default: Reds scale)

scale_midpoint

Numeric midpoint for diverging color scale (default: 0.25)

title

Plot title

cluster

Logical; should rows/cols be clustered (default: TRUE)

xlab, ylab

Axis labels

text_size

Axis text size

Examples

# Example relatedness matrix
set.seed(123)
mat <- matrix(runif(100, 0, 1), nrow = 10)
rownames(mat) <- paste0("ID", 1:10)
colnames(mat) <- paste0("ID", 1:10)

# Plot the relatedness matrix
ggRelatednessMatrix(mat,
  config = list(
    color_palette = c("white", "gold", "red"),
    scale_midpoint = 0.5,
    cluster = TRUE,
    title = "Relatedness Matrix",
    xlab = "Individuals",
    ylab = "Individuals",
    text_size = 8
  )
)