# Interactive Pedigree Plotting with ggPedigreeInteractive

# Introduction

The `ggPedigreeInteractive()` function extends the static pedigree plots generated by `ggPedigree()` into fully interactive `Plotly` widgets. This allows users to explore pedigree data in a more dynamic way, with features such as hover text, zooming, and panning. This vignette walks through: - Basic usage of `ggPedigreeInteractive()` - Customizing the interactive plot - Adding tooltips for additional information

    # Load required packages
    library(BGmisc) # ships the sample 'potter' pedigree
    library(ggplot2) # used internally by ggPedigree*
    library(viridis) # viridis for color palettes
    library(plotly) # conversion layer for interactivity
    #>
    #> Attaching package: 'plotly'
    #> The following object is masked from 'package:ggplot2':
    #>
    #>     last_plot
    #> The following object is masked from 'package:stats':
    #>
    #>     filter
    #> The following object is masked from 'package:graphics':
    #>
    #>     layout
    library(ggpedigree) # the package itself

# Example data

The package includes a small toy pedigree for the Harry Potter universe:

    # Load the example data
    data("potter")
    # Display the first few rows of the dataset
    head(potter)
    #>   personID famID             name first_name surname gen momID dadID spouseID
    #> 1        1     1   Vernon Dursley     Vernon Dursley   1   101   102        3
    #> 2        2     1 Marjorie Dursley   Marjorie Dursley   1   101   102       NA
    #> 3        3     1    Petunia Evans    Petunia   Evans   1   103   104        1
    #> 4        4     1       Lily Evans       Lily   Evans   1   103   104        5
    #> 5        5     1     James Potter      James  Potter   1    NA    NA        4
    #> 6        6     1   Dudley Dursley     Dudley Dursley   2     3     1       NA
    #>   sex twinID zygosity
    #> 1   1     NA     <NA>
    #> 2   0     NA     <NA>
    #> 3   0     NA     <NA>
    #> 4   0     NA     <NA>
    #> 5   1     NA     <NA>
    #> 6   1     NA     <NA>

# Basic Usage

A minimal call is just:

    ggPedigreeInteractive(potter)

…but you will usually want to identify the core primary‑key columns in advance:

    plt <- ggPedigreeInteractive(
      potter,
      famID    = "famID",
      personID = "personID",
      momID    = "momID",
      dadID    = "dadID"
    ) |> plotly::hide_legend()

    plt

The above code generates an interactive pedigree plot of the Potter family tree. You can zoom in, pan around, and hover over nodes to see more information. You can do much more with the `ggPedigreeInteractive()` function, including customizing labels, colors, and tooltips. To experience the full list of options, refer to the online article.