segIBDatN: Segment-Based Kinship at Native Alleles.

segIBDatNR Documentation

Segment-Based Kinship at Native Alleles.

Description

Calculates the kinship at native alleles, which is the segment based probability of native alleles to be IBD.

Usage

segIBDatN(files, phen, map, thisBreed, refBreeds="others", ubFreq=0.01, minSNP=20,
  unitP="Mb", minL=1.0, unitL="Mb", a=0.0, keep=NULL, lowMem=TRUE, 
  skip=NA, cskip=NA, cores=1, quiet=FALSE)

Arguments

files

This can be a character vector with names of the phased marker files, one file for each chromosome. Alternatively files can be a list with the following components:

a) hap.thisBreed: A character vector with names of the phased marker files for the individuals from thisBreed, one file for each chromosome.

b) hap.refBreeds: A character vector with names of the phased marker files for the individuals from the reference breeds (refBreeds), one file for each chromosome. If this component is missing, then it is assumed that the haplotypes of these animals are also included in hap.thisBreed.

c) match: If present, a character vector with file names containing the origin of the marker alleles. The files are typically created with function haplofreq. If this vector is missing, then the default method is used to estimate the origins.

File names must contain the chromosome name as specified in the map in the form "ChrNAME.", e.g. "Breed2.Chr1.phased". The required format of the marker files is described under Details.

phen

Data frame containing the ID (column "Indiv"), breed name (column "Breed"), and sex (column Sex) of each individual.

map

Data frame providing the marker map with columns including marker name 'Name', chromosome number 'Chr', and possibly the position on the chromosome in Mega base pairs 'Mb', and the position in centimorgan 'cM'. (The position in base pairs could result in an integer overflow). The order of the markers must bethe same as in the files.

thisBreed

Breed name: Results will be computed for individuals from thisBreed.

refBreeds

Vector containing names of genotyped breeds. A segment is considered native if its frequency is smaller than ubFreq in all refBreeds. The default "others" means that all genotyped breeds except thisBreed are considered.

ubFreq

A segment is considered native if its frequency is smaller than ubFreq in all reference breeds.

minSNP

Minimum number of marker SNPs included in a segment.

unitP

The unit for measuring the proportion of the genome included in native segments. Possible units are the number of marker SNPs included in shared segments ('SNP'), the number of Mega base pairs ('Mb'), and the total length of the shared segments in centimorgan ('cM'). In the last two cases the map must include columns with the respective names.

minL

Minimum length of a segment in unitL (e.g. in cM).

unitL

The unit for measuring the length of a segment. Possible units are the number of marker SNPs included in the segment ('SNP'), the number of Mega base pairs ('Mb'), and the genetic distances between the first and the last marker in centimorgan ('cM'). In the last two cases the map must include columns with the respective names.

a

The function providing the weighting factor for each segment is w(x)=x*x/(a+x*x). The parameter of the function is the length of the segment in unitL. The default value a=0.0 implies no weighting, whereas a>0.0 implies that old inbreeding has less influence on the result than new inbreeding.

keep

Subset of the IDs of the individuals from data frame phen (including individuals from other breeds) or a logical vector indicating the animals in data frame phen that should be used. By default all individuals included in phen will be used.

lowMem

If lowMem=TRUE then temporary files will be created and deleted.

skip

Take line skip+1 of the genotype files as the row with column names. By default, the number is determined automatically.

cskip

Take column cskip+1 of the genotype files as the first column with genotypes. By default, the number is determined automatically.

cores

Number of cores to be used for parallel processing of chromosomes. By default one core is used. For cores=NA the number of cores will be chosen automatically. Using more than one core increases execution time if the function is already fast.

quiet

Should console output be suppressed?

Details

Calculates a list containing matrices needed to compute segment based kinships at native alleles, defined as the conditional probability that two randomly chosen alleles are IBD, given that both originate from native ancestors. An allele is considered to originate from a native ancesor if the segment containing the allele has low frequency in all reference breeds.

The kinship at native alleles between individuals i and j is Q1[i,j]/Q2[i,j].

The mean kinship at native alleles in the offspring is (x'Q1x+d1)/(x'Q2x+d2), where x is the vector with genetic contributions of the selection candidates.

Genotype file format: Each file containing phased genotypes has a header and no row names. Cells are separated by blank spaces. The number of rows is equal to the number of markers from the respective chromosome and the markers are in the same order as in the map. The first cskip columns are ignored. The remaining columns contain genotypes of individuals written as two alleles separated by a character, e.g. A/B, 0/1, A|B, A B, or 0 1. The same two symbols must be used for all markers. Column names are the IDs of the individuals. If the blank space is used as separator then the ID of each individual should repeated in the header to get a regular delimited file. The columns to be skipped and the individual IDs must have no white spaces. The name of each file must contain the chromosome name as specified in the map in the form "ChrNAME.", e.g. "Breed2.Chr1.phased".

Value

A list of class ratioFun including components:

Q1

matrix with Q1[i,j] = Probability that two alleles chosen from individuals i and j are IBD and are native.

Q2

matrix with Q2[i,j] = Probability that two alleles chosen from individuals i and j are both native.

d1

The value by which the probability that two alleles chosen from the offspring are IBD and native increases due to genetic drift.

d2

The value by which the probability that two alleles chosen from the offspring are native increases due to genetic drift.

id

IDs of the individuals for which the probabilites have been computed.

mean

Mean kinship at native alleles of the specified individuals. Note that 1-mean is the genetic diversity at native segments of the specified individuals from thisBreed

Author(s)

Robin Wellmann

Examples

data(map)
data(Cattle)
dir     <- system.file("extdata", package = "optiSel")
files   <- paste(dir, "/Chr", 1:2, ".phased", sep="")
sKinatN <- segIBDatN(files, Cattle, map, thisBreed="Angler", 
                   ubFreq=0.01, minL=1.0, lowMem=FALSE)
               
## Mean kinship at native segments:
sKinatN$mean
#[1] 0.06695171

## Note that this can not be computed as mean(sKinatN$of).


## Results for individuals:
sKinatN$of <- sKinatN$Q1/sKinatN$Q2
sKinatN$of["Angler1","Angler5"]
#[1] 0.4394066

## Use temporary files to reduce working memory:

sKinatN <- segIBDatN(files, Cattle, map, thisBreed="Angler", ubFreq=0.01,  minL=1.0)
               
## Mean kinship at native segments:
sKinatN$mean
#[1] 0.06695171



optiSel documentation built on Sept. 11, 2024, 7:19 p.m.