Learn R Programming

pedtools (version 1.1.0)

ped_modify: 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, parent, id = NULL, verbose = TRUE)

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

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

removeIndividuals(x, ids, verbose = TRUE)

branch(x, id)

# S3 method for 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.

parent

The ID label (coercible to character) of a single pedigree member, which will be the father or mother (depending on its gender) of the new child.

id

The ID label of some existing pedigree member.

subset

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

...

Not used.

Value

The modified ped object.

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 a common use of addChildren(), namely adding a single child to a pedigree member. Note that its argument parent is gender-neutral, unlike in addChildren() where you have to know the parental genders. Also note that the other parent is always created as a new individual. Thus, applying addDaughter() twice with the same parent will create half sisters.

In removeIndividuals() all descendants of ids are also removed. Any individuals (spouses) left unconnected to the remaining pedigree are also removed.

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

See Also

ped(), relabel(), swapSex()

Examples

Run this code
# NOT RUN {
x = nuclearPed(1)

# To see the effect of each command below, use plot(x) in between.
x = addSon(x, 3)
x = addParents(x, id = 4, father = 6, mother = 7)
x = removeIndividuals(x, 4)

# }

Run the code above in your browser using DataLab