- Methodology Article
- Open access
- Published:

# An Eigenvalue test for spatial principal component analysis

*BMC Bioinformatics*
**volumeÂ 18**, ArticleÂ number:Â 562 (2017)

## Abstract

### Background

The spatial Principal Component Analysis (sPCA, Jombart (Heredity 101:92-103, 2008) is designed to investigate non-random spatial distributions of genetic variation. Unfortunately, the associated tests used for assessing the existence of spatial patterns (*global and local test*; (Heredity 101:92-103, 2008) lack statistical power and may fail to reveal existing spatial patterns. Here, we present a non-parametric test for the significance of specific patterns recovered by sPCA.

### Results

We compared the performance of this new test to the original *global* and *local* tests using datasets simulated under classical population genetic models. Results show that our test outperforms the original *global* and *local* tests, exhibiting improved statistical power while retaining similar, and reliable type I errors. Moreover, by allowing to test various sets of axes, it can be used to guide the selection of retained sPCA components.

### Conclusions

As such, our test represents a valuable complement to the original analysis, and should prove useful for the investigation of spatial genetic patterns.

## Background

The principal component analysis (PCA; [1, 2]) is one of the most common multivariate approaches in population genetics [3]. Although PCA is not explicitly accounting for spatial information, it has often been used for investigating spatial genetic patterns [4]. As a complement to PCA, the spatial principal component analysis [5] has been introduced to explicitly include spatial information in the analysis of genetic variation, and gain more power for investigating spatial genetic structures.

sPCA finds synthetic variables, the principal components (PCs), which maximise both the genetic variance and the spatial autocorrelation as measured by Moranâ€™s *I* [6]. As such, PCs can reveal two types of patterns: â€˜*global*â€™ structures, which correspond to positive autocorrelation typically observed in the presence of patches or clines, and â€˜*local*â€™ structures, which correspond to negative autocorrelation, whereby neighboring individuals are more genetically distinct than expected at random (for a more detailed explanation on the meaning of *global* and *local* structures see [5]). The *global* and *local* tests have been developed for detecting the presence of global and local patterns, respectively [5]. Unfortunately, while these tests have robust type I error, they also typically lack power, and can therefore fail to identify existing spatial genetic patterns [5]. Moreover, they can only be used to diagnose the presence or absence of spatial patterns, and are unable to test the significance of specific structures revealed by sPCA axes.

In this paper, we introduce an alternative statistical test which addresses these issues. This approach relies on computing the cumulative sum of a defined set of sPCA eigenvalues as a test statistic, and uses a Monte-Carlo procedure to generate null distributions of the test statistics and approximate *p*-values. After describing our approach, we compare its performances to the global and local tests using simulated datasets, investigating several standard spatial population genetics models. Our approach is implemented as the function *spca_randtest* in the package *adegenet* [7, 8] for the R software [9].

## Methods

### Test statistic

As in most multivariate analyses of genetic markers, our approach analyses a table of centred allele frequencies (i.e. set to a mean frequency of zero), in which rows represent individuals or populations, and columns correspond to alleles of various loci [3, 5, 10]. We note *X* the resulting matrix, and *n* the number of individuals analysed. In addition, the sPCA introduces spatial data in the form of a *n* by *n* matrix of spatial weights *L*, in which the *i*
^{th} row contains weights reflecting the spatial proximity of all individuals to individual *i*. The PCs of sPCA are then found by the eigen-analysis of the symmetric matrix (Jombart et al. [5]):

We note *Î»* the corresponding non-zero eigenvalues. We differentiate the *r* positive eigenvalues *Î»*
^{+}, corresponding to global structures, and the â€˜*s*â€™ negative eigenvalues *Î»*
^{âˆ’}, corresponding to local structures, so that *Î»â€‰=*Â {
*Î»*
^{+}
,
*Î»*
^{âˆ’}}. Without loss of generality, we assume both sets of eigenvalues are ordered by decreasing absolute value, so that *Î»*
_{1}
^{+}Â *>â€‰Î»*
_{2}
^{+}Â *>â€‰â€¦â€‰>â€‰Î»*
_{
r
}
^{+} and |*Î»*
_{1}
^{âˆ’}
*|â€‰>â€‰|Î»*
_{2}
^{âˆ’}
*|â€‰>â€‰â€¦â€‰>â€‰|Î»*
_{
s
}
^{âˆ’}|. Simply put, each eigenvalue quantifies the magnitude of the spatial genetic patterns in the corresponding PC: larger absolute values indicate stronger global (respectively local) structures. We note *V*
^{+}Â =â€‰{*v*
_{1}
^{+}, â€¦, *v*
_{
r
}
^{+}} and *V*
^{âˆ’}Â =â€‰{*v*
_{1}
^{âˆ’}, â€¦, v_{s}
^{âˆ’}} the sets of corresponding PCs.The most natural choice of test statistic to assess whether a given PC contains significant structure would seem to be the corresponding eigenvalue. This would, however, not account for the dependence on previous PCs: *v*
_{
j
}
^{+} (respectively *v*
_{
j
}
^{âˆ’}) can only be significant if all previous PCs {*v*
_{1}
^{+}, â€¦, *v*
_{
j-1}
^{+}} are also significant. To account for this, we define the test statistic for *v*
_{
j
}
^{+} as:

and as:

for *v*
_{
j
}
^{âˆ’}.

*f*
_{
i
}
^{+} and *f*
_{
i
}
^{âˆ’} become larger in the presence of strong global or local structures in the first *i*
^{th} global/local PCs. Therefore, they can be used as test statistics against the null hypotheses of absence of global or local structures in these PCs. The expected distribution of *f*
_{
i
}
^{+} and *f*
_{
i
}
^{âˆ’} in the absence of spatial structure is not known analytically. Fortunately, it can be approximated using a Monte-Carlo procedure, in which at each permutation individual genotypes are shuffled to be assigned to a different pair of coordinates than in the observed original dataset and *f*
_{
i
}
^{+} and *f*
_{
i
}
^{âˆ’} are computed. Note that the original values of the test statistic are also included in these distributions, as the initial spatial configuration is by definition a possible random outcome. The *p*-values are then computed as the relative frequencies of permuted statistics equal to or greater than the initial value of *f*
_{
i
}
^{+} or *f*
_{
i
}
^{âˆ’}.

To guide the selection of global and local PCs to retain, the simulated values of each eigenvalue (from most positive to most negative), which make up the *f*
_{
i
}
^{+} and *f*
_{
i
}
^{âˆ’} statistics, are also recorded during the permutation procedure. In this way, if global or local structures are detected to be significant, an observed *p*-value for each observed eigenvalue can be estimated by comparison with its simulated eigenvalue distribution. Note that the number of eigenvalues produced by an sPCA does not change between the observed and permuted datasets, so each observed eigenvalue can be compared with the distribution of the corresponding simulated one. This testing procedure can be used with increasing numbers of retained axes, testing the significance of a new axis as long as previous axes showed significant structure. As one test is performed per axis, we use Bonferroni correction to avoid the inflation of type I error, so that the significance level for the *i*
^{th} PC will be Î±/i, where Î± is the target type I error. Hence, the correction implies that if the most positive (or negative) eigenvalue is significant in regards with the chosen *p-*value threshold, the second eigenvalue is tested for a *p-*value threshold that is the half of the previous and so on. The entire testing procedure is implemented in the function *spca_randtest* in the package *adegenet* [7, 8] for R [9]. A flow chart of the test procedure is shown in Fig.Â 1.

### Simulation study

To assess the performance of our test, we simulated genetic data under three migration models: island (IS) and stepping stone (SS), using the software GenomePop 2.7 [11], and isolation by distance (IBD), using *IBDSimV2.0* [12]. We simulated the IS and SS models with 4 populations, each with 25 individuals, and a single population under IBD with 100 individuals. 200 unlinked biallelic diploid loci (or single nucleotide polymorphisms; SNPs) were simulated. Populations evolved under constant effective population size Î¸â€‰=â€‰20, and interchanged migrants at three different symmetric and homogeneous rates (0.005, 0.01, and 0.1). We performed 100 independent runs for each of the three migration rates, for a total of 300 simulated dataset per migration model. An example of input file for GenomePop 2.7 and *IBDSimV2.0* are included as AdditionalÂ filesÂ 1 and 2.

To quantify type I error rates for the *spca_randtest, global* and *local tests*, we extracted 100 random coordinates from 10 square 2D grids, using the function *spsample* from the *spdep* package [13]. In order to evaluate the rate of false negatives for global patterns, we manually generated 10 sets of 100 pairs of coordinates simulating gradients and/or patches from 2D grids. An example of simulated global patterns is presented in Fig.Â 2. To test for the rate of false negatives for local patterns, we perform a principal component analysis on 10 random datasets simulated under the SS model with 0.005 migration rate. We used the coordinates of the individuals on the first principal component and set the second coordinate to zero for all individuals (1D). With the coordinates so produced, we used the function *chooseCN* in adegenet to obtain 10 neighbouring graphs where the most genetically distinct individuals (falling in the upper quartile of the pairwise genetic distances) are considered as neighbors, while the others are non-neighbors.

We tested 100 simulations each for all the 30 sets of geographic coordinates (random, positive and negative), for each of the three migration rates (0.005, 0.01 and 0.1), for each of the three migration models (IS, SS, IBD; total of 9000 tests per migration model). We repeated all tests using a subset of 40 SNPs per individual, for a total of 18,000 tests in the absence of spatial structures, and and 36,000 tests in the presence of global or local structures.

## Results

### Statistical power of the spca_randtest

We compared the performances of the *spca_randtest* with the *global* and *local* tests in three settings: in the absence of spatial structure, and in the presence of global, and local structures. The results obtained in the absence of spatial structure show that all tests have reliable type I errors (Table 1 and 2). The *spca_randtest* exhibited consistently better performances for detecting existing structures in the data than both *global* and *local tests* (Table 1 and 2). Although our simulated local spatial patterns turned out more difficult to detect than global patterns, the *spca_randtest* is twice to five times more effective than the *local test* (Table 1 and 2). Generally, the underlying migration model, the migration rate and the number of loci affect the ability of all tests to detect non-random spatial patterns. Both *spca_randtest* and *global* and *local tests* have in fact a lower sensitivity in presence of island migratory schemes, while results for stepping stone and isolation by distance models are more satisfying (Table 1 and 2). Increasing migration rates lead to a higher rates of false negatives for all tests, which can be overcome using more loci (Table 1 and 2).

Significant eigenvalues are assessed using a hierarchical Bonferroni correction which accounts for non-independence of eigenvalues and multiple testing (Fig. 2). Strong patterns (e.g. IBD) tend to produce a higher number of significant components than weak patterns (e.g. island models with high migration rates), which are otherwise captured by fewer to no components.

### Application to real data

We have run the sPCA to compare the new *spca_randtest* and previous tests to a real dataset of human mitochondrial DNA (mtDNA). We used a dataset of 85 populations from Central-Western Africa that spans a big portion of the African continent (from Gabon to Senegal; [14]). Previous analysis on these data detected a clear genetic structure from West to Central Africa with ongoing stepping stone migration movements. We therefore expected that this spatial distribution of genetic variation would be detected as significant. In the sPCA, populations were treated as units of the analysis, for which allele frequencies of mtDNA polymorphisms are calculated per population. The same approach was used in [14] to run a discriminant analysis of principal components (DAPC; [10]) and detect population genetic structure. The sPCA analysis is found non significant by *global* and *local* tests after 10,000 permutations (*p*-value >0.5), while the *spca_randtest* detects a significant global pattern already with 500 permutations, and with 10,000 permutations the *p*-value for global patterns is 0.005. The second step of the test on single eigenvalues finds the three most positive components to be significant after Bonferroni correction (Table 3). Significant axes can thus be plotted against the spatial network to give a biological interpretation to the results (Fig.Â 3).

## Discussion

We introduced a new statistical test associated to the sPCA to evaluate the statistical significance of global and local spatial patterns. Using simulated data, we show that this new approach outperforms previously implemented tests, having greater statistical power (lower type II errors) whilst retaining consistent type I errors. Our simulations also suggest that demographic settings and migratory models can substantially impact the ability to detect spatial patterns. Indeed, high migration rates, non-hierarchical migration models, such as island model, and low amount of loci can hamper or worsen the performance of the test, preventing the detection of actual spatial patterns. In lack of previous information on the demographic history and/or the movement ecology of the population under study, it is certainly useful to exploit all the available genetic information. In this regards, our simulations show how an increased number of loci does improve the ability of the test to provide meaningful results.

The impact of specific factors such as the effective population size or the number of individuals sampled per population remain to be investigated. A more extensive simulation study, possibly comparing different non-model based methods such as sPCA, would clarify the extent of the spatial information that can be obtained with such methods without comparing explicit evolutionary hypotheses. In fact, the sPCA and the associated *spca_randtest* cannot distinguish between explicit migration models. However, the possibility to detect which eigenvalues contain the spatial information provides the user with further information to interpret the biological meaning of the spatial structure, by focusing on few meaningful dimensions.

Our data application seems to confirm that the *spca_randtest* is more effective than *global* or *local* tests. We chose indeed a previously published dataset of human populations which span a subcontinental area of Africa and had been originally detected to be a highly structured dataset with a geographic cline of population differentiation (Montano et al. [14]). On the basis of the original results, we would have expected a spatial global structure to be present in the data and thus detected with an sPCA. While the *global* test failed to provide statistical significance, the *spca_randtest* did obtain significant results and pointed to the three first most positive components to be also significant after Bonferroni correction. In agreement with the original interpretation of the genetic structure within the samples, spatial component 1 (SP1) shows a clear differentiation of populations in the Gabon-Congo region, while SP2 detects differentiation of Central Nigerian and North Cameroonian populations, on one hand, and extreme Western populations of Senegal, on the other hand (Fig. 3). The colored combination of the first and second most positive component (Fig. 3) also correctly detects a more fragmented differentiation across Central forested areas (Cameroon, Gabon and Congo) compared to more homogeneous Central-Western populations, which was the main result of the original publication based on very different approaches [14]. We limited the analysis to these two component as the third did not add much information to the previous.

## Conclusions

Our simulation approach coupled with a real data application well illustrates the informativeness of our new test to retrieve significant spatial patterns, being these global or local structures and highlights the usefulness of selecting a specific number of significant components to interpret the biological meaning of the results.

## References

Pearson K. On lines and planes of closest fit to systems of points in space. Philosophical Magazine Series. 1901;6:559â€“572.

Hotelling H. Analysis of a complex of statistical variables into principal components. J Ed Psychol. 1933;24:417.

Jombart T, Pontier D, Dufour AB. Genetic markers in the playground of multivariate analysis. Heredity. 2009;102:330â€“41.

Novembre J, Stephens M. Interpreting principal component analyses of spatial population genetic variation. Nat Genet. 2008;40:646â€“9.

Jombart T, Devillard S, Dufour AB, Pontier D. Revealing cryptic spatial patterns in genetic variability by a new multivariate method. Heredity. 2008;101:92â€“103.

Moran PAP. Notes on continuous stochastic phenomena. Biometrika. 1950;37:17â€“23.

Jombart T. Adegenet: a R package for the multivariate analysis of genetic markers. Bioinformatics. 2008;24:1403â€“5.

Jombart T, Ahmed I. Adegenet 1.3-1: new tools for the analysis of genome-wide SNP data. Bioinformatics. 2011;27:3070â€“1.

R Core Team. R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. 2017. URL https://www.R-project.org/.

Jombart T, Devillard S, Balloux F. Discriminant analysis of principal components: a new method for the analysis of genetically structured populations. BMC Genet. 2010;11:94.

Carvajal-RodrÃguez A. GENOMEPOP: a program to simulate genomes in populations. BMC Bioinformatics. 2008;9:223.

Leblois R, Estoup A, Rousset F. IBDSim: a computer program to simulate genotypic data under isolation by distance. Mol Ecol Resour. 2009;9:107â€“9.

Bivand RS, Pebesma E, GÃ³mez-Rubio V. Applied spatial data analysis with R. New York: Springer; 2013. p. 378pp.

Montano V, Marcari V, Pavanello M, Anyaele O, Comas D, Destro-Bisol G, Batini C. The influence of habitats on female mobility in Central and Western Africa inferred from human mitochondrial variation. BMC Evol Biol. 2013;13,1:24.

South A. Rworldmap: a new R package for mapping global data. R J. 2011;3:35â€“43.

## Acknowledgements

We thank two anonymous reviewers for insightful comments and feedback which greatly improved the original version of the manuscript.

### Funding

No funds were used for this study.

### Availability of data and materials

https://github.com/thibautjombart/adegenet/blob/master/R/spca_randtest.R

### Author contributions

Test development: VM and TJ. Data analysis: VM. Wrote the manuscript: VM and TJ.

## Author information

### Authors and Affiliations

### Corresponding author

## Ethics declarations

### Ethics approval and consent to participate

Not applicable

### Consent for publication

Not applicable

### Competing interests

The authors declare no conflict of interest.

## Additional files

### Additional file 1:

Example of GenomePop Input with a parameter setting to simulate an island model of migration. (TXT 363 kb)

### Additional file 2:

Example of IbdSettings for IBD_Sim with parameter setting to simulate an isolation by distance evolutionary model. (TXT 635 kb)

### Additional file 3: Figure S1.

Distributions of significant eigenvalues detected in the presence of global (blue bars) and local (green bars) spatial patterns after hierarchical Bonferroni correction, for 100 significantly positive and 100 significantly negative patterns. Black bars correspond to eigenvalues which are significant without Bonferroni correction. Barsâ€™ height indicates the frequency of observing a significant eigenvalue in a certain position (from most positive to most negative) over the 100 tested patterns. (PDF 1150 kb)

## Rights and permissions

**Open Access** This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The Creative Commons Public Domain Dedication waiver (http://creativecommons.org/publicdomain/zero/1.0/) applies to the data made available in this article, unless otherwise stated.

## About this article

### Cite this article

Montano, V., Jombart, T. An Eigenvalue test for spatial principal component analysis.
*BMC Bioinformatics* **18**, 562 (2017). https://doi.org/10.1186/s12859-017-1988-y

Received:

Accepted:

Published:

DOI: https://doi.org/10.1186/s12859-017-1988-y