Plot a relatedness matrix as a heatmap (ggpedigree style)
Source:R/ggRelatednessMatrix.R
ggRelatednessMatrix.Rd
Plots a relatedness matrix using ggplot2 with config options.
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.
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
)
)