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 matrixK
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 toTrue
.
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]]