View source: R/ggPedigreeInteractive.R
| ggPedigreeInteractive | R Documentation |
Generates an interactive HTML widget built on top of the static ggPedigree output. All layout, styling, and connection logic are inherited from ggPedigree(); this function simply augments the plot with Plotly hover, zoom, and pan functionality.
ggPedigreeInteractive(
ped,
famID = "famID",
personID = "personID",
momID = "momID",
dadID = "dadID",
patID = "patID",
matID = "matID",
twinID = "twinID",
spouseID = "spouseID",
status_column = NULL,
tooltip_columns = NULL,
focal_fill_column = NULL,
overlay_column = NULL,
config = list(optimize_plotly = TRUE),
debug = FALSE,
return_widget = TRUE,
hints = NULL,
code_male = NULL,
sexVar = "sex"
)
ped |
A data frame containing the pedigree data. Needs personID, momID, dadID, and sex columns. |
famID |
Character string specifying the column name for family IDs. Defaults to "famID". |
personID |
Character string specifying the column name for individual IDs. Defaults to "personID". |
momID |
Character string specifying the column name for mother IDs. Defaults to "momID". |
dadID |
Character string specifying the column name for father IDs. Defaults to "dadID". |
patID |
Character string specifying the column name for paternal lines Defaults to "patID". |
matID |
Character string specifying the column name for maternal lines Defaults to "matID". |
twinID |
Character string specifying the column name for twin IDs. Defaults to "twinID". |
spouseID |
Character string specifying the column name for spouse IDs. Defaults to "spouseID". |
status_column |
Character string specifying the column name for affected status. Defaults to NULL. |
tooltip_columns |
Character vector of column names to show when hovering. Defaults to c("personID", "sex"). Additional columns present in 'ped' can be supplied – they will be added to the Plotly tooltip text. Defaults to NULL, which uses the default tooltip columns. |
focal_fill_column |
Character string specifying the column name for focal fill color. |
overlay_column |
Character string specifying the column name for overlay alpha values. |
config |
A list of configuration options for customizing the plot. See getDefaultPlotConfig for details of each option. The list can include:
|
debug |
Logical. If TRUE, prints debugging information. Default: FALSE. |
return_widget |
Logical; if TRUE (default) returns a plotly htmlwidget. If FALSE, returns the underlying plotly object (useful for further customization before printing). |
hints |
Data frame with hints for layout adjustments. Default: NULL. |
code_male |
Integer or string. Value identifying males in the sex column. (typically 0 or 1) Default: 1 |
sexVar |
Character string specifying the column name for sex. Defaults to "sex". |
A plotly htmlwidget (or plotly object if 'return_widget = FALSE')
ggPedigree.core, ggPedigree, vignette("v20_interactiveplots"), vignette("v21_extendedinteractiveplots"), vignette("v32_plots_morecomplexity")
library(BGmisc)
data("potter")
ggPedigreeInteractive(potter, famID = "famID", personID = "personID")
data(hazard)
ggPedigreeInteractive(
hazard,
famID = "famID",
personID = "ID",
momID = "momID",
dadID = "dadID",
config = list(
code_male = 0,
status_column = "affected",
label_nudge_y = .25,
label_include = TRUE,
include_tooltip = TRUE,
label_method = "geom_text",
sex_color_include = TRUE
),
tooltip_columns = c("personID", "birthYr", "onsetYr", "deathYr")
) |>
plotly::layout(
title = "Hazard Pedigree (interactive)",
hoverlabel = list(bgcolor = "white"),
margin = list(l = 50, r = 50, t = 50, b = 50)
) |>
plotly::config(displayModeBar = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.