marker_setattr: Set marker attributes

marker_setattrR Documentation

Set marker attributes

Description

These functions set or modify various attributes of markers attached to a pedigree. They are sometimes more convenient (and pipe-friendly) than the in-place modifiers described in marker_inplace.

Usage

setGenotype(x, marker = NULL, ids = NULL, geno = NULL, id = NULL)

setAfreq(x, marker, afreq, strict = TRUE)

setAlleleLabels(x, marker, alleles)

setMarkername(x, marker = NULL, name)

setChrom(x, marker = NULL, chrom)

setPosition(x, marker = NULL, posMb)

Arguments

x

A ped object or a list of ped objects.

marker

A vector of indices or names of one or several markers attached to x.

geno

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

id, ids

A vector naming one or several pedigree members, or a function (e.g., founders()).

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.

strict

A logical. If TRUE (default) the new frequencies cannot remove or add any alleles.

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

name

A character of the same length as marker, containing marker names.

chrom

A character of the same length as marker, containing chromosome labels.

posMb

A numeric of the same length as marker, containing the physical marker positions in megabases (or NA).

Value

A copy of x with modified attributes.

Examples

x = nuclearPed() |>
  addMarker(alleles = 1:2) |>
  setMarkername(marker = 1, name = "M") |>
  setGenotype(marker = "M", ids = 1, geno = "1/2") |>
  setAfreq(marker = "M", afreq = c(`1` = 0.1, `2` = 0.9)) |>
  setChrom(marker = "M", chrom = 1) |>
  setPosition(marker = "M", posMb = 123.45)

# Alternatively, all of this could have been done on creation:
y = addMarker(nuclearPed(),
              `1` = "1/2",
              afreq = c(`1` = 0.1, `2` = 0.9),
              name = "M",
              chrom = 1,
              posMb = 123.45)
stopifnot(identical(x, y))


pedtools documentation built on Nov. 5, 2023, 5:06 p.m.