CovMat: Calculation of covariance or correlation matrix

Description Usage Arguments Value Note References Examples

View source: R/covmat.R

Description

The theoretical covariance between pairs of markers is calculated from either paternal haplotypes and maternal linkage disequilibrium (LD) or vise versa. A genetic map is required. The implementation relies on paternal half-sib families and biallelic markers such as single nucleotide polymorphisms (SNP). If parental haplotypes are incomplete (i.e., SNP alleles are missing), those parents will be discarded at the corresponding pairs of SNPs. If maternal half-sib families are used, the roles of sire/dam are swapped. Multiple families can be considered.

Usage

1
CovMat(linkMat, haploMat, nfam, pos_chr, map_fun = "haldane", corr = F)

Arguments

linkMat

(p x p) matrix of maternal LD between pairs of p markers; matrix is block diagonal in case of multiple chromosomes and must not contain missing values; use zeros if LD is uncertain

haploMat

(2N x p) matrix of sires haplotypes for all chromosomes (2 lines per sire); coding with 0's and 1's reflecting reference and alternate alleles, respectively; missing values can be coded as NA or any integer but not 0 and 1

nfam

vector (LEN N) containing number of progeny per family or scalar value in case of equal family size

pos_chr

list (LEN number of chromosomes) of vectors (LEN number of markers) of genetic positions in Morgan per chromosome

map_fun

character string of mapping function used; so far "haldane" (default) and "kosambi" are enabled

corr

logical; FALSE (default) if output is covariance matrix or TRUE if output is correlation matrix

Value

list (LEN 2) of matrix (DIM p1 x p1) and vector (LEN p1) with p1 ≤ p

K

covariance matrix OR

R

correlation matrix

valid.snps

vector of SNP indices considered for covariance/ correlation matrix

Note

Family size is used for weighting covariance terms in case of multiple half-sib families. It only matters if number of progeny differs.

If maternal haplotypes (H.mothers) are used instead of maternal LD (matLD), LD can be estimated from counting haplotype frequencies as:

matLD <- LDdam(inMat = H.mother, pos.chr)

If multiple chromosomes are considered, SNP positions are provided as, e.g.

pos.chr <- list(pos.snp.chr1, pos.snp.chr2, pos.snp.chr3)

References

Wittenburg, Bonk, Doschoris, Reyer (2020) Design of Experiments for Fine-Mapping Quantitative Trait Loci in Livestock Populations. BMC Genetics 21:66. doi: 10.1186/s12863-020-00871-1

Examples

1
2
3
4
5
6
7
  ### 1: INPUT DATA
  data(testdata)
  ### 2: COVARIANCE/CORRELATION MATRIX
  corrmat <- CovMat(matLD, H.sire, 100, pos.chr, corr = TRUE)
  ### 3: TAGSNPS FROM CORRELATION MATRIX
  bin <- tagSNP(corrmat$R)
  bin <- tagSNP(corrmat$R, 0.5)

Example output

239 SNPs have non-zero variance -> output matrix has reduced dimensions.
Warning messages:
1: In readChild(ch) : unable to terminate child process: Permission denied
2: In readChild(ch) : unable to terminate child process: Permission denied
3: In cleanup(mc.cleanup) : unable to terminate child: Permission denied
4: In cleanup(mc.cleanup) : unable to terminate child: Permission denied
239 SNPs have been grouped into 175 bins
239 SNPs have been grouped into 43 bins
Error while shutting down parallel: unable to terminate some child processes
sh: 1: rm: Permission denied
Warning messages:
1: In cleanup(kill = tools::SIGKILL, detach = TRUE, shutdown = TRUE) :
  unable to terminate child: Permission denied
2: In cleanup(kill = tools::SIGKILL, detach = TRUE, shutdown = TRUE) :
  unable to terminate child: Permission denied

hscovar documentation built on April 13, 2021, 9:06 a.m.

Related to CovMat in hscovar...