
Convert a pedigree data frame into visNetwork-ready diagram data
Source:R/makePedigreeDiagramData.R
makePedigreeDiagramData.RdBuilds 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.
Arguments
- ped
data frame with
id,sire,dam,sex, andgencolumns (sire/damNAfor unknown parents;genan integer generation number, 0 for founders, as produced byfindGeneration). Two optional columns are used when present: a logicalaffectedcolumn, which adds an affected-status line totitleand fills affected nodes withcolor.background"#CC79A7"(all other nodes are white,"#FFFFFF"); and a characternamecolumn, which is shown inlabel(long names are truncated) and intitle.- twinRelations
optional data.frame with columns
id1,id2,code(seecheckTwinRelations). Not validated here; validate withcheckTwinRelationsfirst.NULL(default) adds no connector edges, soedgeshas onlyfromandto.
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)