Learn R Programming

pedtools

Introduction

The goal of pedtools is to provide a lightweight, but comprehensive tool set for creating, manipulating and visualizing pedigrees with or without marker data. Common pedigree structures are quickly produced with tailor-made functions, while a range of utilities enable modifications like adding or removing individuals, extracting subsets, loop breaking, and merging pedigrees. The plotting feature imports machinery from the kinship2 package.

pedtools is the hub of the pedsuite, a collection of R packages for pedigree analysis, including applications in forensic and medical genetics. The pedsuite has its own GitHub repository and a dedicated website offering more information.

Citation

If you use pedtools in a publication, please cite the book Pedigree Analysis in R (Vigeland, 2021. Academic Press. ISBN:9780128244302).

Online app

Try the online app QuickPed for building and analysing pedigrees here: https://magnusdv.shinyapps.io/quickped/

Installation

To get pedtools, install from CRAN as follows:

install.packages("pedtools")

Alternatively, fetch the latest development version from GitHub:

devtools::install_github("magnusdv/pedtools")

Example

The following example illustrates a step-by-step creation of a pedigree with a marker object.

library(pedtools)

# Start with two half brothers
x = halfSibPed(type = "paternal")

# Make 5 female
x = swapSex(x, 5)

# Add a sister to 5 (parents are 2 and 3)
x = addDaughter(x, parents = 2:3)

# Add inbred child
x = addSon(x, parents = 4:5)

# Create marker
x = addMarker(x, "7" = "a/b")

# Plot pedigree with genotypes
plot(x, marker = 1, hatched = 7)

The process of building pedigrees is perfectly suited for R’s pipe operator |>. For example, the above pedigree could have been created as follows:

x = halfSibPed(type = "paternal") |>
  swapSex(5) |>
  addDaughter(parents = 2:3) |>
  addSon(parents = 4:5) |>
  addMarker("7" = "a/b")

For details about what pedtools can do, and many other examples, the vignette is a good place to start.

Copy Link

Version

Install

install.packages('pedtools')

Monthly Downloads

1,087

Version

2.12.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Magnus Vigeland

Last Published

November 5th, 2026

Functions in pedtools (2.12.0)

isHomozygous

Find homozygous genotypes
locusAttributes

Get or set locus attributes
nMarkers

The number of markers attached to a pedigree
newMarker

Internal marker constructor
marker_attach

Attach markers to pedigrees
marker

Marker objects
marker_select

Select or remove attached markers
marker_prop

Marker properties
newPed

Internal ped constructor
founderInbreeding

Inbreeding coefficients of founders
marker_setattr

Set marker attributes
maskPed

Mask and unmask pedigree datasets
is.ped

Is an object a ped object?
is.marker

Test if something is a marker
ped

Pedigree construction
ped_internal

Internal ordering of pedigree members
ped_subgroups

Pedigree subgroups
plotPedList

Plot a collection of pedigrees.
print.ped

Printing pedigrees
print.nucleus

S3 methods
plotmethods

Internal plot methods
marker_getattr

Get marker attributes
marker_inplace

Set marker attributes
ped_modify

Add/remove pedigree members
ped_basic

Create basic pedigrees
setSNPs

Attach SNP loci to a pedigree
ped_utils

Pedigree utilities
swapGenotypes

Swap genotypes between individuals
splitGenotypes

Split genotype columns into allele columns
writePed

Write a pedigree to file
ped_complex

Complex pedigree structures
readPed

Read a pedigree from file
randomPed

Random pedigree
mergePed

Merge two pedigrees
mendelianCheck

Check for Mendelian errors
pedtools-package

pedtools: Creating and Working with Pedigrees and Marker Data
setMutmod

Set a mutation model
setMarkersFromMatrix

Attach markers from an allele matrix
plot.ped

Plot pedigree
transferMarkers

Transfer marker data
validatePed

Pedigree errors
relabel

Get or modify pedigree labels
sameGenotype

Find markers for which two individuals have the same genotype
sortGenotypes

Sort the alleles in each genotype
as.ped

Conversions to ped objects
as.data.frame.ped

Convert ped to data frame
as_kinship2_pedigree

Convert pedigree to kinship2 format
distributeMarkers

Distribute markers evenly along a set of chromosomes
addAllele

Add allele
as.matrix.ped

Convert ped to matrix
extractSingletons

Extract singletons from pedigree
expectedHomozygosity

Expected homozygosity and heterozygosity
connectedComponents

Connected pedigree components
breakLoops

Pedigree loops
getGenotypes

Genotype matrix
inbreedingLoops

Inbreeding loops
getMap

Tabulate marker positions
getAlleles

Allele matrix manipulation
getComponent

Pedigree component
harmoniseMarkers

Harmonise markers across components in a ped list
freqDatabase

Allele frequency database
famid

Family identifier
getSex

Get or set the sex of pedigree members