Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getSex

Get or set the sex of pedigree members


Description

Functions for retrieving or changing the sex of specified pedigree members.

Usage

getSex(x, ids, named = FALSE)

setSex(x, ids = NULL, sex)

swapSex(x, ids, verbose = TRUE)

Arguments

x

A ped object or a list of such.

ids

A character vector (or coercible to one) containing ID labels.

named

A logical: return a named vector or not.

sex

A numeric vector with entries 1 (= male), 2 (= female) or 0 (= unknown). If ids is NULL, sex must be named with ID labels. If sex is unnamed and shorter than ids it is recycled to length(ids).

verbose

A logical: Verbose output or not.

Value

  • getSex(x, ids) returns an integer vector of the same length as ids, with entries 0 (unknown), 1 (male) or 2 (female).

  • setSex(x, ids, sex) returns a ped object identical to x, but where the sex of ids is set according to the entries of sex

  • swapSex(x, ids) returns a ped object identical to x, but where the sex of ids (and their spouses) are swapped (1 <-> 2).

See Also

Examples

x = nuclearPed(father = "fa", mother = "mo", children = "ch")

stopifnot(all.equal(
  getSex(x, named = TRUE),
  c(fa = 1, mo = 2, ch = 1)
))

# Make child female
setSex(x, ids = "ch", sex = 2)

# Same, using a named vector
setSex(x, sex = c(ch = 2))

# Swapping sex is sometimes easier,
# since spouses are dealt with automatically
swapSex(x, ids = "fa")

# setting/getting sex in a pedlist
y = list(singleton(1, sex = 2), singleton(2), singleton(3))
sx = getSex(y, named = TRUE)
y2 = setSex(y, sex = sx)

stopifnot(identical(y, y2))

pedtools

Creating and Working with Pedigrees and Marker Data

v0.9.7
GPL-3
Authors
Magnus Dehli Vigeland [aut, cre] (<https://orcid.org/0000-0002-9134-4962>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.