Two types of gene test statistics have been implemented in MAGMA: the mean of the χ 2 statistic for the SNPs in a gene, and the top χ 2 statistic among the SNPs in a gene. For the mean χ 2 statistic, a gene p-value is then obtained by using a known approximation of the sampling distribution [20,21]. For the top χ 2 statistic such an approximation is not available, and therefore an adaptive permutation procedure is used to obtain an empirical gene p-value. A random phenotype is first generated for the reference data, drawing from the standard normal distribution. This is then permuted, and for each permutation the top χ 2 statistic is computed for every gene. The empirical p-value for a gene is then computed as the proportion of permuted top χ 2 statistics for that gene that are higher than its observed top χ 2 statistic. The required number of permutations is determined adaptively for each gene during the analysis, to increase computational efficiency. Further details can be found in ‘Supplemental Methods—SNP-wise gene analysis’.