# limix.stats.linear_kinship¶

limix.stats.linear_kinship(G, out=None, verbose=True)[source]

Estimate Kinship matrix via linear kernel.

Let 𝑑 be the number of columns of G. The resulting matrix is given by:

$𝙺 = 𝚇𝚇ᵀ/𝑑$

where

$𝚇ᵢⱼ = (𝙶ᵢⱼ - 𝑚ⱼ) / 𝑠ⱼ$

is the matrix G column-wise normalized by means 𝑚ⱼ and standard deviations 𝑠ⱼ. NaNs are ignored so as to produce matrix K having only real numbers.

This functions is specially designed to also handle large matrices G that would otherwise require a large amount of memory if it were to be loaded in memory first. For those cases, libraries like Dask come in handy.

Parameters
• G (array_like) – Samples-by-variants matrix.

• out (ndarray) – A location into which the result is stored.

• verbose (bool, optional) – True for showing progress; False otherwise. Defauts to True.

Examples

>>> from numpy.random import RandomState
>>> from limix.stats import linear_kinship
>>>
>>> random = RandomState(1)
>>> X = random.randn(4, 100)
>>> K = linear_kinship(X, verbose=False)
>>> print(K)
[[ 0.91314823 -0.19283362 -0.34133897 -0.37897564]
[-0.19283362  0.89885153 -0.2356003  -0.47041761]
[-0.34133897 -0.2356003   0.95777313 -0.38083386]
[-0.37897564 -0.47041761 -0.38083386  1.23022711]]