# calc_IBD: Calculation of IBD In Alethere/SmoothDescent: Application of map-based genotype correction algorithm Smooth Descent

## Description

This function computes Identity-by-descent probabilities according to a naive model based on random assortment of markers. It requires homologue matrices ('p1hom' and 'p2hom') indicating which homologues of each parent carry a genoage of 1 or 0 for the tracked allele. Based on this, a probability matrix is returned: for each individual how likely it is, at each marker, that it has inherited each of the homologues. As a generic method, it can use a single genoage of one marker (and two vectors of homologue assignment); a vector of markers (and two homologue matrices) or a matrix of markers (and two homologue matrices).

## Usage

 ```1 2 3 4 5 6 7``` ```calc_IBD(geno, p1hom, p2hom, ploidy = 2) ## S3 method for class 'numeric' calc_IBD(geno, p1hom, p2hom, ploidy = 2) ## S3 method for class 'matrix' calc_IBD(geno, p1hom, p2hom, ploidy = 2) ```

## Arguments

 `geno` integer or matrix containing genotypes (genoages of allele A, from 0 to ploidy). If 'geno' is a matrix, each row must be labelled with a marker name, and each column is interpreted as an individual. Note that for many markers of one single individual, a 1 column matrix must be provided. `p1hom` numeric vector or matrix indicating which parental homologue, from parent 1, contains allele A. If 'geno' is an integer, 'p1hom' must be a vector of length ploidy. If 'geno' is a matrix, 'p1hom' must be a matrix of ncol = ploidy and nrow = nrow(geno) and the same rownames as 'geno'. `p2hom` numeric vector or matrix indicating which parental homologue, from parent 2, contains allele A. If 'geno' is an integer, 'p2hom' must be a vector of length ploidy. If 'geno' is a matrix,'p2hom' must be a matrix of ncol = ploidy and nrow = nrow(geno) and the same rownames as 'geno'. `ploidy` numeric, indicating the ploidy of an organism. Only even ploidies allowed and all individuals are expected to have the same ploidy.

## Value

The naive probability of having inherited each parental homologue. If the offspring genoage is impossible given the parental homologues, NA is returned. If 'geno'is a vector, returns a one-row matrix, each column containing the probability of having inherited that parental homologue (the first columns corresponding to parent 1, and the rest to parent 2). If 'geno' is a matrix, a list of matrices is returned. Each element is the probabilities for all individuals of having inherited one parental homologue. There should be ploidy*2 elements in the list.

## Methods (by class)

• `numeric`: Function for a single marker of a single individual.

• `matrix`: Function for handling matrix input to calc_IBD

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```data("genotype") geno <- geno[,-1:-2] #we take out parental genotypes data("homologue") #For a single genotype IBD <- calc_IBD(geno[1,1],hom[1,1:2],hom[1,3:4], ploidy = 2) #For a single individual #The genotype must be a matrix of one column! IBD <- calc_IBD(geno[,1,drop = FALSE],hom[,1:2],hom[,3:4], ploidy = 2) #For all individuals IBD <- calc_IBD(geno,hom[,1:2],hom[,3:4], ploidy = 2) ```

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