Skip to contents

Builds the node and edge tables consumed by visNetwork::visNetwork() from a pedigree data frame: one node per individual, sex-coded to a node shape, positioned by generation; one directed edge per known sire and one per known dam, pointing from parent to child.

Usage

makePedigreeDiagramData(ped, twinRelations = NULL)

Arguments

ped

data frame with id, sire, dam, sex, and gen columns (sire/dam NA for unknown parents; gen an integer generation number, 0 for founders, as produced by findGeneration). Two optional columns are used when present: a logical affected column, which adds an affected-status line to title and fills affected nodes with color.background "#CC79A7" (all other nodes are white, "#FFFFFF"); and a character name column, which is shown in label (long names are truncated) and in title.

twinRelations

optional data.frame with columns id1, id2, code (see checkTwinRelations). Not validated here; validate with checkTwinRelations first. NULL (default) adds no connector edges, so edges has only from and to.

Value

A list with two data frames: nodes (id, label, shape, level, title, color.background) and edges (from, to, plus dashes/label/color when twinRelations is supplied). title is an HTML hover-tooltip string giving ID, sex, generation, sire, and dam (and affected status and name when those optional columns are present).

Examples

library(nprcgenekeepr)
diagramData <- makePedigreeDiagramData(nprcgenekeepr::examplePedigree)