genotype: Genotype calculator

Description Usage Arguments Details Value Methods (by class) Examples

View source: R/geno_predict.R

Description

Given a set of IBD probabilities, genotypes are calculated. Can take as input a single matrix containing all homologue probabilities of a single individual; or a list of matrices, where each element contains the probabilities of all individuals for one homologue (same as output of 'calc_IBD.list')

Usage

1
2
3
4
5
6
7
genotype(IBD, homologue, threshold = 0.8, ploidy = 2)

## S3 method for class 'matrix'
genotype(IBD, homologue, threshold = 0.8, ploidy = 2)

## S3 method for class 'list'
genotype(IBD, homologue, threshold = 0.8, ploidy = 2)

Arguments

IBD

numeric matrix or list of matrices.

homologue

homologue matrix for both parents. The first 'ploidy' columns from parent 1 and the second 'ploidy' columns from parent 2.

threshold

probability threshold to assign a homologue to an individual ( if IBD probability for hom 1 > threshold, it is considered that that individual has inherited hom 1).

ploidy

numeric

Details

Genotypes can be though of as a multiplication between a set of homologue probabilites and homologue genotypes. For example, in a diploid we have the following IBD probabilities: p(h1) = 0.9, p(h2) = 0.1, p(h3) = 1, p(h4) = 0; and genotypes g(h1) = 1, g(h2) = 0, g(h3) = 0, g(h4) = 1. The resulting genotype using a simple multiplication would be ∑{p(hi)*g(hi)}, 0.9 in this case.
We are more interested in imputing integer genotypes, so probabilities must be turned into integers. For that reason we use a threshold, default 0.8. All probabilities above 0.8 are turned to 1, and all probabilities below 0.8 are turned to 0. If not enough homologues are assigned this way, that is, an individual cannot be assigned at least 'ploidy' homologues, no genotype can be calculated and NA is returned.

Value

A vector or matrix of imputed genotypes. If not enough IBD probabilities are above the threshold for one individual, NA is returned.

Methods (by class)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data("smooth_descent")
data("homologue")
IBD <- sdescent$predIBD

#For all individuals at once
gen <- genotype(IBD, hom)
#Or one single individual
#Note this is a matrix where each column is one homologue
ind <- sapply(IBD,'[',,1)
gen <- genotype(ind, hom)

Alethere/SmoothDescent documentation built on Jan. 14, 2022, 9:40 p.m.