segIBDandN | R Documentation |
Calculates the segment based probability of alleles to be IBD (identical by descent) and Native: For each pair of individuals the probability is computed that two SNPs taken at random position from randomly chosen haplotypes belong to a shared segment and are native.
segIBDandN(files, Native, map, minSNP=20, unitP="Mb", minL=1.0,
unitL="Mb", a=0.0, keep=NULL, skip=NA, cskip=NA, cores=1, quiet=FALSE)
files |
Vector with names of the phased marker files, one file for each chromosome. The required format is described under |
Native |
This parameter is either (1) Mx(2N) indicator matrix, with 1, if the segment containing the SNP is considered native, and 0 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 the output of function haplofreq. or (2) Vector with file names. The files contain for every SNP and for each haplotype from this breed 1 if the segment containing the SNP is considered native. 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 |
Data frame providing the marker map with columns including marker name |
minSNP |
Minimum number of marker SNPs included in a segment. |
unitP |
The unit for measuring the proportion of the genome included in shared segments.
Possible units are the number of marker SNPs included in shared segments ( |
minL |
Minimum length of a segment in |
unitL |
The unit for measuring the length of a segment. Possible units are the number of marker SNPs included in the segment ( |
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 |
keep |
Vector with IDs of individuals (from this breed) for which the probabilities are to be computed. By default, they will be computed for all individuals included in |
skip |
Take line |
cskip |
Take column |
cores |
Number of cores to be used for parallel processing of chromosomes. By default one core is used. For |
quiet |
Should console output be suppressed? |
For each pair of individuals the probability is computed that two SNPs taken at random position from randomly chosen haplotypes belong to a shared segment and are native. That is, they are not introgressed from other breeds.
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"
.
NxN
matrix with N
being the number of individuals from this breed included in all files (and in parameter keep
).
Robin Wellmann
data(map)
data(Cattle)
dir <- system.file("extdata", package = "optiSel")
GTfile <- file.path(dir, paste("Chr", unique(map$Chr), ".phased", sep=""))
Freq <- haplofreq(GTfile, Cattle, map, thisBreed="Angler", refBreeds="others", minSNP=20)$freq
fIBDN <- segIBDandN(GTfile, Freq<0.01, map=map, minSNP=20)
mean(fIBDN)
#[1] 0.01032261
fIBDN <- segIBDandN(GTfile, Freq<0.01, map=map, minSNP=20, cores=NA)
mean(fIBDN)
#[1] 0.01032261
## using files:
wdir <- file.path(tempdir(),"HaplotypeEval")
chr <- unique(map$Chr)
GTfile <- file.path( dir, paste("Chr", chr, ".phased", sep=""))
file <- haplofreq(GTfile, Cattle, map, thisBreed="Angler", minSNP=20, ubFreq=0.01, w.dir=wdir)
fIBDN <- segIBDandN(GTfile, file$match, map=map, minSNP=20)
mean(fIBDN)
#[1] 0.01032261
fIBDN <- segIBDandN(GTfile, file$match, map=map, minSNP=20, cores=NA)
mean(fIBDN)
#[1] 0.01032261
#unlink(wdir, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.