getAlleles {pedtools} | R Documentation |
Allele matrix manipulation
Description
Functions for getting and setting the genotypes of multiple individuals/markers simultaneously
Usage
getAlleles(x, ids = NULL, markers = NULL)
setAlleles(x, ids = NULL, markers = NULL, alleles)
Arguments
x |
A |
ids |
A vector of ID labels. If NULL (default) all individuals are included. |
markers |
A vector of indices or names of markers attaches to |
alleles |
A character of the same format and dimensions as the output of
|
Details
If the alleles
argument of setAlleles()
is not a matrix, it is recycled
(if necessary), and converted into a matrix of the correct dimensions. For
example, setting alleles = 0
gives a simple way of removing the genotypes
of some or all individuals (while keeping the markers attached).
Value
getAlleles()
returns a character matrix with length(ids)
rows and
2 * length(markers)
columns. The ID labels of x
are used as rownames,
while the columns are named <m1>.1
, <m1>.2
, ... where <m1>
is the
name of the first marker, a.s.o.
setAlleles()
returns a ped
object identical to x
, except for the
modified alleles. In particular, all locus attributes are unchanged.
See Also
Examples
# Setup: Pedigree with two markers
x = nuclearPed(1)
x = addMarker(x, `2` = "1/2", alleles = 1:2, name = "m1")
x = addMarker(x, `3` = "2/2", alleles = 1:2, name = "m2")
# Extract allele matrix
mat1 = getAlleles(x)
mat2 = getAlleles(x, ids = 2:3, markers = "m2")
stopifnot(identical(mat1[2:3, 3:4], mat2))
# Remove all genotypes
y = setAlleles(x, alleles = 0)
y
# Setting a single genotype
z = setAlleles(y, ids = "1", marker = "m2", alleles = 1:2)
# Alternative: In-place modification with `genotype()`
genotype(y, id = "1", marker = "m2") = "1/2"
stopifnot(identical(y,z))
### Manipulation of pedlist objects
s = transferMarkers(x, singleton("s"))
peds = list(x, s)
getAlleles(peds)
setAlleles(peds, ids = "s", marker = "m1", alleles = 1:2)