ped_modify: Add/remove pedigree members

ped_modifyR Documentation

Add/remove pedigree members

Description

Functions for adding or removing individuals in a 'ped' object.

Usage

addChildren(
  x,
  father = NULL,
  mother = NULL,
  nch = NULL,
  sex = 1,
  ids = NULL,
  verbose = TRUE
)

addSon(x, parents, id = NULL, verbose = TRUE)

addDaughter(x, parents, id = NULL, verbose = TRUE)

addParents(x, id, father = NULL, mother = NULL, verbose = TRUE)

removeIndividuals(
  x,
  ids,
  remove = c("descendants", "ancestors"),
  returnLabs = FALSE,
  verbose = TRUE
)

branch(x, id)

## S3 method for class 'ped'
subset(x, subset, ...)

Arguments

x

A ped object.

father, mother

Single ID labels. At least one of these must belong to an existing pedigree member. The other label may either: 1) belong to an existing member, 2) not belong to any existing member, or 3) be missing (i.e. not included in the function call). In cases 2 and 3 a new founder is added to the pedigree. In case 2 its label is the one given, while in case 3 a suitable label is created by the program (see Details).

nch

A positive integer indicating the number of children to be created. Default: 1.

sex

Gender codes of the created children (recycled if needed).

ids

A character vector (or coercible to such) with ID labels. In addChildren the (optional) ids argument is used to specify labels for the created children. If given, its length must equal nch. If not given, labels are assigned automatically as explained in Details.

verbose

A logical: Verbose output or not.

parents

A vector of 1 or 2 ID labels, of which at least one must be an existing member of x.

id

The ID label of a pedigree member.

remove

Either "ancestors" or "descendants" (default), dictating the method of removing pedigree members. Abbreviations are allowed.

returnLabs

A logical, by default FALSE. If TRUE, removeIndividuals() returns only the labels of all members to be removed, instead of actually removing them.

subset

A character vector (or coercible to such) with ID labels forming a connected sub-pedigree.

...

Not used.

Details

In addChildren() and addParents(), labels of added individuals are created automatically if they are not specified by the user. In the automatic case, the labelling depends on whether the existing labels are integer-like or not (i.e. if labels(x) equals as.character(as.integer(labels(x))).) If so, the new labels are integers subsequent to the largest of the existing labels. If not, the new labels are "NN_1", "NN_2", ... If any such label already exists, the numbers are adjusted accordingly.

addSon() and addDaughter() are wrappers for the most common use of addChildren(), namely adding a single child to a pedigree. Note that the parents can be given in any order. If only one parent is supplied, the other is created as a new individual.

removeIndividuals() removes the individuals indicated with ids along with all of their ancestors OR descendants, depending on the remove argument. Leftover spouses disconnected to the remaining pedigree are also removed. An error is raised if result is a disconnected pedigree.

The branch() function extracts the sub-pedigree formed by id and all his/her spouses and descendants.

Finally, subset() can be used to extract any connected sub-pedigree. (Note that in the current implementation, the function does not actually check that the indicated subset forms a connected pedigree; failing to comply with this may lead to obscure errors.)

Value

The modified ped object.

See Also

ped(), relabel(), swapSex()

Examples


x = nuclearPed(1) |>
  addSon(3) |>
  addParents(4, father = 6, mother = 7) |>
  addChildren(father = 6, mother = 7, nch = 3, sex = c(2,1,2))

# Remove 6 and 7 and their descendants
y1 = removeIndividuals(x, 6:7)

# Remove 8-10 and their parents
y2 = removeIndividuals(x, 8:10, remove = "ancestors")


pedtools documentation built on Nov. 5, 2023, 5:06 p.m.