Learn R Programming

pedprobr (version 0.9.5)

oneMarkerDistribution: Genotype distribution for a single marker

Description

Computes the genotype probability distribution of one or several pedigree members, possibly conditional on known genotypes for the marker.

Usage

oneMarkerDistribution(
  x,
  ids,
  marker = 1,
  loopBreakers = NULL,
  grid.subset = NULL,
  partialmarker = NULL,
  output = c("array", "table", "sparse"),
  verbose = TRUE
)

Value

The output format depends on the output argument:

  • "array": A named k-dimensional array, where k = length(ids), with the joint genotype distribution for the ids individuals, conditional on the known genotypes if present.

  • "table": A data frame with k+1 columns, where each row corresponds to a genotype combination, and the last column prob gives the probability.

  • "sparse": A data frame with the same structure as the "table" output, but only combinations with non-zero probability are included.

Arguments

x

A ped object or a list of such.

ids

A vector of ID labels of one or more members of x.

marker

Either a marker object or the name (or index) of a marker attached to x. If x has multiple components, only the latter is allowed.

loopBreakers

(Only relevant if the pedigree has loops). A vector with ID labels of individuals to be used as loop breakers. If NULL (default) loop breakers are selected automatically. See pedtools::breakLoops().

grid.subset

(Optional; not relevant for most users.) A numeric matrix describing a subset of all marker genotype combinations for the ids individuals. The matrix should have one column for each of the ids individuals, and one row for each combination: The genotypes are described in terms of the matrix M = allGenotypes(n), where n is the number of alleles for the marker. If the entry in column j is the integer k, this means that the genotype of individual ids[j] is row k of M.

partialmarker

(Deprecated) An alias for marker.

output

A character string, either "array" (default), "table" or "sparse". See Value.

verbose

A logical.

See Also

twoMarkerDistribution()

Examples

Run this code

# Trivial example: Hardy-Weinberg probabilities for an equifrequent SNP
s = singleton(id = 1) |> addMarker(alleles = 1:2, afreq = c(0.5, 0.5))
oneMarkerDistribution(s, ids = 1)

# Conditioning on a partial genotype
s = setGenotype(s, ids = 1, geno = "1/-")
oneMarkerDistribution(s, ids = 1)

# Genotype distribution for a child of heterozygous parents
trio = nuclearPed(father = "fa", mother = "mo", child = "ch") |>
  addMarker(fa = "1/2", mo = "1/2")
oneMarkerDistribution(trio, ids = "ch")

# Joint distribution of the parents, given that the child is heterozygous
trio = addMarker(trio, ch = "1/2")
ids = c("fa", "mo")
oneMarkerDistribution(trio, ids = ids, marker = 2)

# Table output of the previous example
oneMarkerDistribution(trio, ids = ids, marker = 2, output = "table")
oneMarkerDistribution(trio, ids = ids, marker = 2, output = "sparse")

# A different example: The genotype distribution of an individual (id = 8)
# whose half cousin (id = 9) is homozygous for a rare allele.
y = halfCousinPed(degree = 1) |>
  addMarker("9" = "a/a", afreq = c(a = 0.01, b = 0.99))

oneMarkerDistribution(y, ids = 8)

# Multi-component (trivial) example
z = singletons(1:2) |> addMarker(`1` = "1/2", `2` = "1/2", alleles = 1:2)
oneMarkerDistribution(z, 1:2)
oneMarkerDistribution(z, 1:2, output = "sparse")

Run the code above in your browser using DataLab