Learn R Programming

optiSel (version 2.0.7)

segBreedComp: Calculates the Segment-Based Breed Composition of Individuals

Description

Calculates the segment based Breed Composition: For every individual the breed composition is estimated, including the genetic contribution from native ancestors.

Usage

segBreedComp(Native, map, unitP="Mb")

Value

Data frame with the number of rows being the number of individuals. The columns are

Indiv

IDs of the individuals,

native

Genetic contributions from native ancestors,

...

Contributions from other breeds.

Arguments

Native

This parameter is either

(1) Mx(2N) logical matrix, with TRUE, if the segment containing the SNP is considered native, and FALSE otherwise. The row names are the marker names, and the non-unique column names are the IDs of the individuals. The matrix is typically computed from component freq of the output from function haplofreq.

or

(2) Mx(2N) character matrix, with components being the first characters of the names of the breeds in which the respective segment has maximum frequency. Segments considered native are coded as '1'. The row names are the marker names, and the non-unique column names are the IDs of the individuals. The matrix is typically component match from the output of function haplofreq.

or

(3) Vector with file names. The files contain for every SNP and for each haplotype 1 if the segment containing the SNP is considered native. Otherwise it is the first letter of the name of the breed in which the segment has maximum frequency. These files are typically created by function haplofreq. There is one file per chromosome and file names must contain the chromosome name as specified in the map in the form "ChrNAME.", e.g. "Breed2.Chr1.nat".

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 markers must be in the same order as in in Native.

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.

Author

Robin Wellmann

Details

For every individual the breed composition is computed, including the genetic contribution from native ancestors (native contribution). The native contribution is the proportion of the genome belonging to segments whose frequency is smaller than a predefined value in all other breeds.

Additionally, for each introgressed breed, the proportion of the genome of each individual is computed that is non-native and has maximum frequency in the respective breed (not if option (1) is used).

Examples

Run this code
data(map)
data(Cattle)
dir     <- system.file("extdata", package = "optiSel")
GTfiles <- file.path(dir, paste("Chr", unique(map$Chr), ".phased", sep=""))
Haplo   <- haplofreq(GTfiles, Cattle, map, thisBreed="Angler", minSNP=20, minL=1.0)
Comp    <- segBreedComp(Haplo$freq<0.01, map)
mean(Comp$native)
#[1] 0.3853432

Comp <- segBreedComp(Haplo$match, map)
apply(Comp[, -1], 2, mean)

## Reading native segments from files:
if (FALSE) {
wdir <- file.path(tempdir(), "HaplotypeEval")
file <- haplofreq(GTfiles, Cattle, map, thisBreed="Angler", minSNP=20, 
           minL=1.0, ubFreq=0.01, what="match", w.dir=wdir)
Comp <- segBreedComp(file$match, map)
head(Comp)

apply(Comp[, -1], 2, mean)
#    native          F          H          R 
#0.38534317 0.05503451 0.25986508 0.29975724 

#unlink(wdir, recursive = TRUE)
}

Run the code above in your browser using DataLab