View source: R/ggRelatednessMatrix.R
ggRelatednessMatrix | R Documentation |
Plots a relatedness matrix using ggplot2 with config options.
ggRelatednessMatrix(
mat,
config = list(),
interactive = FALSE,
tooltip_columns = NULL,
personID = "personID",
...
)
ggrelatednessmatrix(
mat,
config = list(),
interactive = FALSE,
tooltip_columns = NULL,
personID = "personID",
...
)
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_columns |
A character vector of column names to include in tooltips. |
personID |
Character; name of the column containing unique person identifiers. |
... |
Additional arguments passed to ggplot2 layers. |
Config options include:
A vector of colors for the heatmap (default: Reds scale)
Numeric midpoint for diverging color scale (default: 0.25)
Plot title
Logical; should rows/cols be clustered (default: TRUE)
Axis labels
Axis text size
A ggplot object displaying the relatedness matrix as a heatmap.
# 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(
matrix_color_palette = c("white", "gold", "red"),
color_scale_midpoint = 0.5,
matrix_cluster = TRUE,
plot_title = "Relatedness Matrix",
axis_x_label = "Individuals",
axis_y_label = "Individuals",
axis_text_size = 8
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.