marker: Marker objects

View source: R/marker.R

markerR Documentation

Marker objects

Description

Creating a marker object associated with a pedigree. The function marker() returns a marker object, while addMarker() first creates the marker and then attaches it to x.

Usage

marker(
  x,
  ...,
  geno = NULL,
  allelematrix = NULL,
  alleles = NULL,
  afreq = NULL,
  chrom = NA,
  posMb = NA,
  name = NA,
  mutmod = NULL,
  rate = NULL,
  NAstrings = c(0, "", NA, "-"),
  validate = TRUE,
  validateMut = validate
)

addMarker(
  x,
  ...,
  geno = NULL,
  allelematrix = NULL,
  alleles = NULL,
  afreq = NULL,
  chrom = NA,
  posMb = NA,
  name = NA,
  mutmod = NULL,
  rate = NULL,
  locusAttr = NULL,
  NAstrings = c(0, "", NA, "-"),
  validate = TRUE
)

Arguments

x

A ped object.

...

One or more expressions of the form id = genotype, where id is the ID label of a member of x, and genotype is a numeric or character vector of length 1 or 2 (see Examples).

geno

A character vector of length pedsize(x), with genotypes written in the format "a/b".

allelematrix

A matrix with 2 columns and pedsize(x) rows. If this is non-NULL, then ... must be empty.

alleles

A character containing allele names. If not given, and afreq is named, names(afreq) is used. The default action is to take the sorted vector of distinct alleles occurring in allelematrix, geno or ....

afreq

A numeric of the same length as alleles, indicating the population frequency of each allele. A warning is issued if the frequencies don't sum to 1 after rounding to 3 decimals. If the vector is named, and alleles is not NULL, an error is raised if setequal(names(afreq), alleles) is not TRUE. If afreq is not specified, all alleles are given equal frequencies.

chrom

A single integer: the chromosome number. Default: NA.

posMb

A nonnegative real number: the physical position of the marker, in megabases. Default: NA.

name

A character string: the name of the marker. Default: NA.

mutmod, rate

Mutation model parameters to be passed on to pedmut::mutationModel(); see there for details. Note: mutmod corresponds to the model parameter. Default: NULL (no mutation model).

NAstrings

A character vector containing strings to be treated as missing alleles. Default: c("", "0", NA, "-").

validate

A logical indicating if the validity of the marker object should be checked. Default: TRUE.

validateMut

A logical indicating if the mutation model (if present) should be checked.

locusAttr

A list with names alleles, afreq, chrom, name, posMb, mutmod, rate (or a subset of these). This can be used as an alternative to entering the arguments as function parameters.

Value

An object of class marker. This is an integer matrix with 2 columns and one row per individual, and the following attributes:

  • alleles (a character vector with allele labels)

  • afreq (allele frequencies; default rep.int(1/length(alleles), length(alleles)))

  • chrom (chromosome number; default = NA)

  • posMb (physical location in megabases; default = NA)

  • name (marker identifier; default = NA)

  • mutmod (a list of two (male and female) mutation matrices; default = NULL)

See Also

Get/set marker attributes: marker_getattr, marker_setattr.

Retrieve various marker properties: marker_prop, nMarkers(),

Add alleles to an existing marker: addAllele()

Attach multiple markers: marker_attach

Examples

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

# An empty SNP with alleles "A" and "B"
marker(x, alleles = c("A", "B"))

# Creating and attaching to `x`
addMarker(x, alleles = c("A", "B"))

# Alleles/frequencies can be given jointly or separately
stopifnot(identical(
  marker(x, afreq = c(A = 0.01, B = 0.99)),
  marker(x, alleles = c("A", "B"), afreq = c(0.01, 0.99)),
  ))

# Genotypes can be assigned individually ...
marker(x, fa = "1/1", mo = "1/2")

# ... or using the `geno` vector (all members in order)
marker(x, geno = c("1/1", "1/2", NA))


# Attaching a marker to the pedigree
m = marker(x) # By default a SNP with alleles 1,2
x = setMarkers(x, m)

# A marker with a "proportional" mutation model,
# with different rates for males and females
mutrates = list(female = 0.1, male = 0.2)
marker(x, alleles = 1:2, mutmod = "prop", rate = mutrates)


magnusdv/pedtools documentation built on April 9, 2024, 7:35 a.m.