Learn R Programming

paramlink (version 0.7-0)

createPedigree: Create simple pedigrees

Description

These are utility functions for creating rudimentary linkdat objects with common pedigree structures. The function nuclearPed creates a nuclear family with a specified number of male/female offspring, while cousinPed and halfCousinPed create pedigrees linking two (half) cousins of a specified degree.

Usage

nuclearPed(noffs, sex)
cousinPed(degree)
halfCousinPed(degree)

Arguments

noffs
a positive integer, the number of offspring in the nuclear family.
sex
a vector of length noffs; indicating the gender (1=male, 2=female) of the offspring. If missing, all offspring are taken to be males.
degree
a non-negative integer: 0=siblings, 1=first cousins; 2=second cousins, a.s.o.

Value

Details

All individuals are created as unaffected. Use swapAff to edit this (see Examples). Use swapSex to change gender of pedigree members. The cousins created by cousinPed and halfCousinPed have zero removal. Removals are easily contructed using addOffspring or removeIndividuals (see Examples).

See Also

swapAff, swapSex, removeIndividuals, addOffspring, relabel

Examples

Run this code
# A nuclear family with 2 boys and 3 girls, 
# where the father and the two boys are affected.
x = nuclearPed(noffs=5, sex=c(1,1,2,2,2))
x = swapAff(x, ids=c(1,3,4))

# A pedigree showing a pair of third cousins
y = cousinPed(3)
plot(y)

# Adding a child on one side, to create third cousins once removed. 
# The pedigree plot above helps identifying which individual 
# should have the extra child
y = addOffspring(y, father=15, noffs=1)

# Half sibs:
z = halfCousinPed(0)

# Alternative construction:
z2 = nuclearPed(noffs=1, sex=1)
z2 = addOffspring(z2, father=1, noffs=1, sex=2)
z2 = relabel(z2, new=1:5,old=c(1,2,4,3,5))
stopifnot(all.equal(z,z2))

Run the code above in your browser using DataLab