Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

marker_prop

Marker properties


Description

These functions are used to retrieve various properties of marker objects. Each function accepts as input either a single marker object, a ped object, or a list of ped objects.

Usage

emptyMarker(x, ...)

## Default S3 method:
emptyMarker(x, ...)

## S3 method for class 'marker'
emptyMarker(x, ...)

## S3 method for class 'ped'
emptyMarker(x, markers = seq_len(nMarkers(x)), ...)

## S3 method for class 'list'
emptyMarker(x, markers = seq_len(nMarkers(x)), ...)

nTyped(x, ...)

## Default S3 method:
nTyped(x, ...)

## S3 method for class 'marker'
nTyped(x, ...)

## S3 method for class 'ped'
nTyped(x, markers = seq_len(nMarkers(x)), ...)

## S3 method for class 'list'
nTyped(x, markers = seq_len(nMarkers(x)), ...)

nAlleles(x, ...)

## Default S3 method:
nAlleles(x, ...)

## S3 method for class 'marker'
nAlleles(x, ...)

## S3 method for class 'ped'
nAlleles(x, markers = seq_len(nMarkers(x)), ...)

## S3 method for class 'list'
nAlleles(x, markers = seq_len(nMarkers(x)), ...)

isXmarker(x, ...)

## Default S3 method:
isXmarker(x, ...)

## S3 method for class 'marker'
isXmarker(x, ...)

## S3 method for class 'ped'
isXmarker(x, markers = seq_len(nMarkers(x)), ...)

## S3 method for class 'list'
isXmarker(x, markers = seq_len(nMarkers(x)), ...)

allowsMutations(x, ...)

## Default S3 method:
allowsMutations(x, ...)

## S3 method for class 'marker'
allowsMutations(x, ...)

## S3 method for class 'ped'
allowsMutations(x, markers = seq_len(nMarkers(x)), ...)

## S3 method for class 'list'
allowsMutations(x, markers = seq_len(nMarkers(x)), ...)

Arguments

x

A single marker object or a ped object (or a list of such)

...

Not used.

markers

A vector of names or indices of markers attached to x, in the case that x is a ped object or a list of such. By default all attached markers are selected.

Details

emptyMarker() returns TRUE for markers with no genotypes. If the input is a list of pedigrees, all must be empty for the result to be TRUE.

nTyped() returns the number of typed individuals for each marker. Note that if the input is a list of pedigrees, the function returns the sum over all components.

nAlleles() returns the number of alleles of each marker.

isXmarker() returns TRUE for markers whose chrom attribute is either "X" or 23.

allowsMutations returns TRUE for markers whose mutmod attribute is non-NULL and differs from the identity matrix.

Value

If x is a single marker object, the output is a vector of length 1.

If x is a ped object, or a list of such, the output is a vector of the same length as markers (which includes all attached markers by default), reporting the property of each marker.

Examples

cmp1 = nuclearPed(1)
cmp2 = singleton(10)
loc = list(alleles = 1:2)
x = setMarkers(list(cmp1, cmp2), locus = rep(list(loc), 3))

#-------- nAlleles() ------------
# All markers have 2 alleles
stopifnot(identical(nAlleles(x), c(2L,2L,2L)))

#-------- emptyMarkers() ------------
# Add genotype for indiv 1 at marker 1
genotype(x[[1]], 1, 1) = 1:2

# Check that markers 2 and 3 are empty
stopifnot(identical(emptyMarker(x), c(FALSE,TRUE,TRUE)),
          identical(emptyMarker(x[[1]]), c(FALSE,TRUE,TRUE)),
          identical(emptyMarker(x[[2]]), c(TRUE,TRUE,TRUE)),
          identical(emptyMarker(x, markers = c(3,1)), c(TRUE,FALSE)))

#-------- nTyped() ------------
stopifnot(identical(nTyped(x), c(1L,0L,0L)))

# Add genotypes for third marker
genotype(x[[1]], marker = 3, id = 1:3) = 1
genotype(x[[2]], marker = 3, id = 10) = 2

# nTyped() returns total over all components
stopifnot(identical(nTyped(x), c(1L,0L,4L)))

#-------- allowsMutations() ------------
# Marker 2 allows mutations
mutmod(x, 2) = list("prop", rate = 0.1)

stopifnot(identical(allowsMutations(x), c(FALSE,TRUE,FALSE)),
          identical(allowsMutations(x, markers = 2:3), c(TRUE,FALSE)))

#-------- isXmarker() ------------
# Make marker 3 X-linked
chrom(x[[1]], 3) = "X"
chrom(x[[2]], 3) = "X"

stopifnot(identical(isXmarker(x), c(FALSE,FALSE,TRUE)))

pedtools

Creating and Working with Pedigrees and Marker Data

v0.9.7
GPL-3
Authors
Magnus Dehli Vigeland [aut, cre] (<https://orcid.org/0000-0002-9134-4962>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.