## Kinship matrix from haplotypes

### Description

This function computes a HapAllele-based kinship matrix from a GHap.haplo object.

### Usage

 1 2 ghap.kinship(haplo, weights, batchsize = 500, only.active.samples = TRUE, only.active.alleles = TRUE, verbose = TRUE) 

### Arguments

 haplo A GHap.haplo object. weights A numeric vector providing HapAllele-specific weights. batchsize A numeric value controlling the number of haplotype alleles to be processed at a time (default = 500). only.active.samples A logical value specifying whether only active samples should be included in the output (default = TRUE). only.active.alleles A logical value specifying whether only active haplotype alleles should be included in the output (default = TRUE). verbose A logical value specfying whether log messages should be printed (default = TRUE).

### Details

Briefly, let \mathbf{H} be the centered n x m matrix of HapGenotypes, where n is the number of individuals and m is the number of HapAlleles. The HapAllele covariance among individuals is computed as:

\mathbf{K} = q\mathbf{HDH}'

where \mathbf{D} = diag(d_i), d_i is the weight of HapAllele i (default d_i = 1), and q is the inverse weighted sum of variances in the columns of \mathbf{H}. Notice that this is a generalization of the SNP-based genomic relationship matrix (VanRaden, 2008).

### Value

The function returns a n x n matrix of HapAllele-based kinships, where n is the number of individuals.

### Author(s)

Yuri Tani Utsunomiya <ytutsunomiya@gmail.com>

Marco Milanesi <marco.milanesi.mm@gmail.com>

### References

P. M. VanRaden. Efficient methods to compute genomic predictions. J. Dairy. Sci. 2008. 91:4414-4423.

### Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 # #### DO NOT RUN IF NOT NECESSARY ### # # # Copy the example data in the current working directory # ghap.makefile() # # # Load data # phase <- ghap.loadphase("human.samples", "human.markers", "human.phase") # # # Subset data - randomly select 3000 markers with maf > 0.02 # maf <- ghap.maf(phase, ncores = 2) # set.seed(1988) # markers <- sample(phase$marker[maf > 0.02], 3000, replace = FALSE) # phase <- ghap.subsetphase(phase, unique(phase$id), markers) # rm(maf,markers) # # # Generate block coordinates based on windows of 10 markers, sliding 5 marker at a time # blocks <- ghap.blockgen(phase, 10, 5, "marker") # # # Generate matrix of haplotype genotypes # ghap.haplotyping(phase, blocks, batchsize = 100, ncores = 2, freq = 0.05, outfile = "example") # # # Load haplotype genotypes # haplo <- ghap.loadhaplo("example.hapsamples", "example.hapalleles", "example.hapgenotypes") # # # ### RUN ### # # # Compute Kinship matrix # K <- ghap.kinship(haplo, batchsize = 100) 

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.