Learn R Programming

ggpedigree

ggpedigree provides modern tools for visualizing family trees and pedigree structures using both ggplot2 and plotly. Specifically, it enables the creation of static and interactive pedigree plots that can accommodate complex family relationships, including duplicated individuals and various mating structures.

The package complements the behavior genetics toolkit BGmisc [Garrison et al. (2024) doi:10.21105/joss.06203] for tasks such as pedigree validation and computing relatedness matrices. Core plotting functions (ggPedigree(), ggPedigreeInteractive(), calculateCoordinates()) work on any rectangular pedigree and ship with built-in example data, while relatedness workflows reuse matrix builders from BGmisc. Due to the impending deprecation of kinship2, version 1.0 incorporates the layout helper functions from kinship2. The pedigree alignment algorithms are adapted from ‘kinship2’ [Sinnwell et al. (2014) doi:10.1159/000363105]. We gratefully acknowledge the original authors: Jason Sinnwell, Terry Therneau, Daniel Schaid, and Elizabeth Atkinson for their foundational work.

See the package vignettes for end-to-end tutorials, including relatedness matrices and interactive plots.

Installation

You can install the released version of ggpedigree from CRAN with:

install.packages("ggpedigree")

To install the development version of ggpedigree from GitHub use:

# install.packages("devtools")
devtools::install_github("R-Computing-Lab/ggpedigree")

Demonstration

Here is a basic example of how to use ggpedigree to visualize a pedigree structure. The potter dataset contains simulated pedigree data for the Weasley family from the Harry Potter series.

library(ggpedigree) # ggPedigree lives here
library(BGmisc) # helper utilities & example data
potter <- BGmisc::potter # load example data
ggPedigree(potter,
  famID = "famID",
  personID = "personID"
)
ggPedigree(potter,
  famID = "famID",
  personID = "personID",
  config = list(
    color_theme = "greyscale"
  )
)

Citation

If you use ggpedigree in your research or wish to refer to it, please cite the following:

citation(package = "ggpedigree")

Garrison S (2026). ggpedigree: Visualizing Pedigrees with ‘ggplot2’ and ‘plotly’. R package version 1.1.0.3, https://github.com/R-Computing-Lab/ggpedigree/.

A BibTeX entry for LaTeX users is

@Manual{,
  title = {ggpedigree: Visualizing Pedigrees with 'ggplot2' and 'plotly'},
  author = {S. Mason Garrison},
  year = {2026},
  note = {R package version 1.1.0.3},
  url = {https://github.com/R-Computing-Lab/ggpedigree/},
}

Contributing

Contributions to the ggpedigree project are welcome. For guidelines on how to contribute, please refer to the Contributing Guidelines. Issues and pull requests should be submitted on the GitHub repository. For support, please use the GitHub issues page.

Branching and Versioning System

The development of ggpedigree follows a GitFlow branching strategy:

  • Feature Branches: All major changes and new features should be developed on separate branches created from the dev branch. Name these branches according to the feature or change they are meant to address.
  • Development Branch: The dev branch is the main development branch where all feature branches are merged. This branch contains the latest changes and is used for testing and development purposes.
  • Main Branch (main): The main branch mirrors the stable state of the project as seen on CRAN. Only fully tested and approved changes from the dev branch are merged into main to prepare for a new release.

License

ggpedigree is licensed under the GNU General Public License v3.0. For more details, see the LICENSE.md file.

Copy Link

Version

Install

install.packages('ggpedigree')

Monthly Downloads

470

Version

1.1.0.3

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

S. Mason Garrison

Last Published

January 11th, 2026

Functions in ggpedigree (1.1.0.3)

.addTwins

Add Twins to ggplot Pedigree Plot
formatTooltip

Format tooltip text
.computeCurvedMidpoint

Compute point along a curved segment (quadratic Bézier)
.restoreNames

Restore user-specified column names in a connections data frame
.preparePhenotypeByDegreeData

Prepare data for ggPhenotypeByDegree This function prepares the data frame for plotting by calculating necessary columns and ensuring required columns are present.
.adjustSpacing

Adjust spacing in ggPedigree coordinate columns
ggPhenotypeByDegree.core

Core plotting function for ggPhenotypeByDegree This function generates the core ggplot object based on the prepared data frame.
generateSpouseList

Generate a spouselist matrix
ggPhenotypeByDegree

Plot correlation of genetic relatedness by phenotype
ggRelatednessMatrix

Plot a relatedness matrix as a heatmap (ggpedigree style)
ggpedigree-package

ggpedigree: Visualizing Pedigrees with 'ggplot2' and 'plotly'
kinship2_align.pedigree

Align a pedigree for plotting
ggRelatednessMatrix.core

Core Function for ggRelatednessMatrix
getDefaultPlotConfig

Shared Default Plotting Configuration
kinship2_alignped4

Compute optimal horizontal spacing for pedigree alignment
.makeSymmetricKey

Generate a symmetric key for two IDs
ggPedigreeInteractive

Interactive pedigree plot (Plotly wrapper around ggPedigree)
ggPedigree

Plot a custom pedigree diagram
getMidpoints

Compute midpoints across grouped coordinates
kinship2_autohint

Automatically generate alignment hints for pedigree plotting
optimizePlotlyPedigree

Optimize Plotly Pedigree Plot
kinship2_alignped1

Align pedigree - Process a single subject and their spouses
getRelativeCoordinates

Get coordinate positions of relatives for each individual
ggPedigree.core

Core Function for ggPedigree
kinship2_alignped3

Merge two aligned pedigree structures
.pick_first

Pick First Matching Rule
kinship2_check.hint

Check kinship2 hints for consistency
optimizeStaticPedigree

Optimize Static Pedigree Plot
kinship2_alignped2

Align pedigree - Process a set of siblings
processExtras

Process duplicate appearances of individuals in a pedigree layout
relink

Relink IDs to closest duplicate appearance based on coordinates
redsquirrels

Kluane Red Squirrel Data
kinship2_duporder

Find all duplicated IDs on a level, and return
recodeMissingIDs

Recode Missing IDs in Pedigree Data
kinship2_plotPedigree

plotPedigree A wrapped function to plot simulated pedigree from function simulatePedigree. This function require the installation of package kinship2.
pedigree

Create a pedigree or pedigreeList object
transformPed

Process Pedigree Data
warsofroses

Wars of the Roses Pedigree Data
kinship2_kindepth

Calculate the depth (generation level) of subjects in a pedigree
kinship2_bitSize

Calculate the bit size of a pedigree
preparePedigreeData

Prepare Pedigree Data
kinship2_shift

Shift a subject and his twins left or right among siblings used in autohint to resolve duplicate positions
optimizePedigree

Optimize Pedigree Plot
calculateCoordinates

Calculate coordinates for plotting individuals in a pedigree
closest_dup

Find the closest duplicate appearance based on coordinates
calculateConnections

Calculate connections for a pedigree dataset
ASOIAF

A pedigree of ice and fire
computeDistance

Compute distance between two points
buildPlotConfig

build Config
addFocalFillColumn

Add Focal Fill Column to Pedigree Data
buildSpouseSegments

Build spouse segments
countSiblings

Count siblings of each individual
createFillColumn

Get fill column for ggPedigree
.addScales

Add Scales to ggplot Pedigree Plot
.addNodes

Add Nodes to ggplot Pedigree Plot
.addOverlay

Add Overlay to ggplot Pedigree Plot
countOffspring

Count offspring of each individual
.addSelfSegment

Add Self Segments to ggplot Pedigree Plot
.addAnnotate

Add annotates to ggplot Pedigree Plot
.addLabels

Add Labels to ggplot Pedigree Plot
alignPedigreeWithRelations

Align pedigree with additional relations
alignPedigreeWithHints

Align pedigree with hints for plotting This function aligns a pedigree object using hints if provided, or defaults to the default alignment settings.