# Math behind the Genetic Relationship Matrix

The genetic relationship matrix (GRM) can estimate the genetic relationship between two individuals ($j$ and $k$) over $m$ SNPs and $i$ representing a specific SNP. What I don't understand from their equation is why we divide our summation by $m$ (the number of SNPs). $x_{ij}$ is the number of copies of the minor allele for the $j$-th individual in SNP $i$. $p_i$ is the frequency of the minor allele for SNP $i$.

• I do not know anything about this GRM but it seems to me it is divided by m to represent the average relationship over all (m) SNPs. Jun 18 '15 at 14:26
• I am not familiar with it either, sources would be very useful. But, this may answer your question, if it does let me know and I will post it as an answer... Summing over $m$ SNPs would give a result for a pair of individuals. But if you want a result which is comparable to other GRM's then you need an average which accounts for the number of SNPs measured, hence $1/m$ times the summation. Otherwise you two GRMs could have different scores purely because of the number of SNPs included. Jun 18 '15 at 14:37
• ncbi.nlm.nih.gov/pmc/articles/PMC3014363 This is a link to the paper I am studying hope it helps fill in any missing information you need. Jun 18 '15 at 14:42
• 1) did my comment answer your question (does it make sense?) 2) could you also edit the question to include the article link and explain what each term is e.g. $m$ denotes the number of loci, $i$ is ... $j$ is ... $k$ is.. $x$ is... and $p$ is... The question would be most valuable if it is able to stand alone (not require going to external sites/papers for definitions) Jun 18 '15 at 14:54

This expression is a mean

$$\frac{1}{m}\sum_{i=1}^m ...$$

($$m$$ is the number of SNPs) of the ratio

$$\frac{numerator}{denominator}$$

where the numerator is a covariance

$$(a_i-C)(b_i-C)$$

and the denominator is the expected heterozygosity (it is also the variance of binomial distribution with n=2)

$$2p_i(1-p_i)$$

Therefore, it represents how much do two individuals covary $$(x_{ij})(x_{ik}-p_i)$$ respectively to what is expected on average $$2p_i(1-p_i)$$ averaged over all SNPs $$\frac{1}{m}\sum_{i=1}^m...$$, where $$m$$ is the number of SNPs.

It is a relative measure (relative to the expected heterozygosity) of covariance between each individual (averaged over all SNPs).

Does it help?

• Evaluating it this way gives us the average correlation per SNP between two individuals which considering the amount of SNPs it will be a very small value and considering the the correlation will be between -1 and 1 i dont see the intuition behind dividing by the number of SNPs (m). Also does anyone know other methods of estimating the genetic relationship between two individuals? Jun 18 '15 at 15:32
• I am not sure what confuses you with this division by $m$. When you calculated your average grade at school, you added all the grades and divide the whole think by the number of grades. This is what this division is. You add all the relative covariances for each SNPs (relative the expected heterozygosity) and you divide the whole thing by the number of SNPs. Jun 18 '15 at 15:42
• Does it make sense? You might just want to read about the arithmetic mean. Jun 19 '15 at 12:30
• A little complex but I will try to get it. Thanks for sharing a detailed analysis.
– user17381
Aug 19 '15 at 9:35

$2p_i$ is the expectation of $SNP_i$:

$$E(SNP_i) = 0 \times (1-p_i)^2 + 1 \times 2p_i(1 - p_i) + 2 \times p_i^2 = 2 p_i$$

$(x_{ij} - 2p_i)(x_{ik} - 2p_i)$ measures how the two SNPs covary. I have no idea why they divide it by $2p_i(1 - p_i)$, but if you leave that one out, you have the plain definition of covariance.

https://en.wikipedia.org/wiki/Expected_value

https://en.wikipedia.org/wiki/Covariance

Though the question was posted a long ago, I feel that a clarification could be beneficial.

Heterozygosity / gene diversity
The factor in the denominator is twice the variance of the number of major alleles at site $$i$$, also known as heterozygosity or gene diversity: $$H_i = 2p_i(1-p_i).$$ What might appear confusing here is the factor $$1-p_i$$ that is explicitly written instead of traditional $$q_i=1-p_i$$: $$H=2pq$$ (since the probabilities of minor and major alleles sum to $$1$$).

Covariance
In statistical terms this factor can be interpreted as twice the variance of the average number of major/minor alleles on the site, which is the motivation for including it in the denominator of the covariance function, as, e.g., when converting covariance to a correlation coefficient. It is necessary however to note that this inclusion can be done in different ways, depending on what statistical aspects one wants to emphasize.

• In particular, the equation given in the question, taken from this paper (referenced in the comments), is the covariance of a standartized genotype matrix, defined as $$W_{ij} = \frac{x_{ij}-2p_i}{\sqrt{2p_i(1-p_i)}}.$$ In other words the standartization is done prior to calculating the covariance $$cov_{jk} = \frac{1}{m}\sum_i W_{ij}W_{ik}.$$

This is however different from a more traditional definition of Genetic relationship matrix, as in VanRaden's work, where such division is done after calculating the covariance: $$G_{jk} = \frac{\frac{1}{m}\sum_i(x_{ij}-2p_i)(x_{ik}-2p_i)}{\frac{1}{m}\sum_i 2p_i(1-p_i)} = \frac{\sum_i(x_{ij}-2p_i)(x_{ik}-2p_i)}{\sum_i 2p_i(1-p_i)}.$$

Finally, as a word of caution, let me mention that $$x_{ij}, x_{ik}$$ in these expressions can take only values $$0$$ or $$1$$.

The matrix gives you an estimate of the average linear relationship between any two individuals genomes, it's essentially taking the average of the betas (like linear regression betas) across each locus. One of the formulas for 'beta' is covariance divided by the sample variance, which is exactly what is happening. Each locus beta predicts the state of a person's genome at that locus from another person's genome at the same locus. Taking the average of these betas across the entire genome gives you a coefficient that can be thought of as a measure of how well we can predict one person's genome from another.