# The Q Matrix

The Q matrix is a matrix, where is the number of genotypes and is the number of populations. This matrix can be calculated by a number of programs including *STRUCTURE*. To calculate this matrix, the number of expected populations in the data must be provided. The resulting matrix gives the relatedness of each genotype to each population. To make sure the correct number of populations has been chosen, several population sizes should be tested several times. The most stable population size (tested usng an ANOVA) is assumed to be the correct number of populations. This approach is time-consuming and problem-prone. Thus, it is recommended to use the P matrix.