Learn R Programming

nprcgenekeepr (version 3.0.0)

makePedigreeDiagramData: Convert a pedigree data frame into visNetwork-ready diagram data

Description

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)

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).

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.

Examples

Run this code
library(nprcgenekeepr)
diagramData <- makePedigreeDiagramData(nprcgenekeepr::examplePedigree)

Run the code above in your browser using DataLab