Learn R Programming

nprcgenekeepr (version 3.0.0)

getPyramidPlot: Create an age-sex pyramid plot of a pedigree

Description

The pedigree provided must have the following columns: sex and age. This needs to be augmented to allow pedigrees structures that are provided by the nprcgenekeepr package.

Usage

getPyramidPlot(
  ped = NULL,
  binWidth = 2L,
  ageUnit = "years",
  colorScheme = "default",
  showCounts = TRUE,
  ageLabelCex = 1
)

Value

The return value of par("mar") when the function was called.

Arguments

ped

The pedigree information in data.frame format

binWidth

numeric bin width for age groups (default 2). The value is truncated to a whole number and is at least 1, so 0.5 gives 1 and 2.9 gives 2.

ageUnit

character either "years" (default) or "months".

colorScheme

character color scheme: "default" (blue/pink) or "viridis" (colorblind-friendly).

showCounts

logical whether to show count values on bars (default TRUE).

ageLabelCex

numeric expansion factor for age labels (default 1.0).

Details

Only living animals are plotted: when ped has an exit column, animals with a non-NA exit are dropped, and only animals with sex "M" or "F" are counted. The age axis is, however, sized from the oldest animal in ped, including deceased ones. When ped is NULL (the default), the packaged qcPed example data are used. An unrecognized colorScheme silently falls back to "default".

Examples

Run this code
library(nprcgenekeepr)
data(qcPed)
getPyramidPlot(qcPed)
getPyramidPlot(qcPed, binWidth = 5, colorScheme = "viridis")

Run the code above in your browser using DataLab