homozygote: Extract Features of Genotype objects

Description Usage Arguments Details Value Author(s) See Also Examples

Description

homozygote creates an vector of logicals that are true when the alleles of the corresponding observation are the identical.

heterozygote creates an vector of logicals that are true when the alleles of the corresponding observation differ.

carrier create a logical vector or matrix of logicals indicating whether the specified alleles are present.

allele.count returns the number of copies of the specified alleles carried by each observation.

allele extract the specified allele(s) as a character vector or a 2 column matrix.

allele.names extract the set of allele names.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
homozygote(x,  allele.name, ...)
heterozygote(x, allele.name, ...)
carrier(x, allele.name, ...)
## S3 method for class 'genotype'
carrier(x, allele.name=allele.names(x),
        any=!missing(allele.name), na.rm=FALSE, ...)
allele.count(x, allele.name=allele.names(x),any=!missing(allele.name),
             na.rm=FALSE)
allele(x, which=c(1,2) )
allele.names(x)

Arguments

x

genotype object

...

optional parameters (ignored)

allele.name

character value or vector of allele names

any

logical value. When TRUE, a single count or indicator is returned by combining the results for all of the elements of allele. If FALSE separate counts or indicators should be returned for each element of allele. Defaults to FALSE if allele is missing. Otherwise defaults to TRUE.

na.rm

logical value indicating whether to remove missing values. When true, any NA values will be replaced by 0 or FALSE as appropriate. Defaults to FALSE.

which

selects which allele to return. For first allele use 1. For second allele use 2. For both (the default) use c(1,2).

Details

When the allele.name argument is given, heterozygote and homozygote return TRUE if exactly one or both alleles, respectively, match the specified allele.name.

Value

homozygote and heterozygote return a vector of logicals.

carrier returns a logical vector if only one allele is specified, or if any is TRUE. Otherwise, it returns matrix of logicals with one row for each element of allele.

allele.count returns a vector of counts if only one allele is specified, or if any is TRUE. Otherwise, it returns matrix of counts with one row for each element of allele.

allele returns a character vector when one allele is specified. When 2 alleles are specified, it returns a 2 column character matrix.

allele.names returns a character vector containing the set of allele names.

Author(s)

Gregory R. Warnes greg@warnes.net

See Also

genotype, HWE.test, summary.genotype, locus gene marker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
example.data   <- c("D/D","D/I","D/D","I/I","D/D","D/D","D/D","D/D","I/I","")
g1  <- genotype(example.data)
g1

heterozygote(g1)
homozygote(g1)

carrier(g1,"D")
carrier(g1,"D",na.rm=TRUE)

# get count of one allele 
allele.count(g1,"D")

# get count of each allele
allele.count(g1)  # equivalent to
allele.count(g1, c("D","I"), any=FALSE)

# get combined count for both alleles
allele.count(g1,c("I","D"))

# get second allele
allele(g1,2)

# get both alleles
allele(g1)

genetics documentation built on March 1, 2021, 9:06 a.m.