locusAttributes {pedtools} | R Documentation |
Get or set locus attributes
Description
Retrieve or modify the attributes of attached markers
Usage
getLocusAttributes(
x,
markers = NULL,
checkComps = FALSE,
attribs = c("alleles", "afreq", "name", "chrom", "posMb", "mutmod")
)
setLocusAttributes(
x,
markers = NULL,
locusAttributes,
matchNames = NA,
erase = FALSE
)
Arguments
x |
A |
markers |
A character vector (with marker names) or a numeric vector
(with marker indices). If NULL (default), the behaviour depends on
|
checkComps |
A logical. If TRUE, and |
attribs |
A subset of the character vector |
locusAttributes |
A list of lists, with attributes for each marker. |
matchNames |
A logical, only relevant if |
erase |
A logical. If TRUE, all previous attributes of the selected
markers are erased. If FALSE, attributes not affected by the submitted
|
Details
The default setting markers = NULL
select markers automatically, depending
on the matchNames
argument. If matchNames = FALSE
, all markers are chosen
If matchNames = TRUE
, markers will be matched against the name
entries in
locusAttributes
(and an error issued if these are missing).
Note that the default value NA
of matchNames
is changed to TRUE if all
entries of locusAttributes
have a name
component which matches the name a
an attached marker.
Possible attributes given in locusAttributes
are as follows (default values
in parenthesis):
-
alleles
: a character vector with allele labels -
afreq
: a numeric vector with allele frequencies (rep.int(1/L, L)
, whereL = length(alleles)
) -
name
: marker name (NA) -
chrom
: chromosome number (NA) -
posMb
: physical location in megabases (NA) -
mutmod
: mutation model, or model name (NULL) -
rate
: mutation model parameter (NULL)
Value
-
getLocusAttributes
: a list of lists -
setLocusAttributes
: a modified version ofx
.
Examples
x = singleton(1)
x = addMarkers(x, marker(x, name = "m1", alleles = 1:2))
x = addMarkers(x, marker(x, name = "m2", alleles = letters[1:2], chrom = "X"))
# Change frequencies at both loci
y = setLocusAttributes(x, markers = 1:2, loc = list(afreq = c(.1, .9)))
getMarkers(y, 1)
# Set the same mutation model at both loci
z = setLocusAttributes(x, markers = 1:2, loc = list(mutmod = "proportional", rate = .1))
mutmod(z, 1)
# By default, the markers to be modified are identified by name
locs = list(list(name = "m1", alleles = 1:10),
list(name = "m2", alleles = letters[1:10]))
w = setLocusAttributes(x, loc = locs)
getMarkers(w, 1:2)
# If `erase = TRUE` attributes not explicitly given are erased
w2 = setLocusAttributes(x, loc = locs, erase = TRUE)
chrom(w2, 2) # not "X" anymore
# The getter and setter are inverses
newx = setLocusAttributes(x, loc = getLocusAttributes(x))
stopifnot(identical(x, newx))