Comparing allele frequencies among populations that differ in environment has long been a tool for detecting loci involved in local adaptation. However, such analyses are complicated by an imperfect knowledge of population allele frequencies and neutral correlations of allele frequencies among populations due to shared population history and gene flow. Here we develop a set of methods to robustly test for unusual allele frequency patterns and correlations between environmental variables and allele frequencies while accounting for these complications based on a Bayesian model previously implemented in the software Bayenv. Using this model, we calculate a set of "standardized allele frequencies" that allows investigators to apply tests of their choice to multiple populations while accounting for sampling and covariance due to population history. We illustrate this first by showing that these standardized frequencies can be used to detect nonparametric correlations with environmental variables; these correlations are also less prone to spurious results due to outlier populations. We then demonstrate how these standardized allele frequencies can be used to construct a test to detect SNPs that deviate strongly from neutral population structure. This test is conceptually related to F ST and is shown to be more powerful, as we account for population history. We also extend the model to next-generation sequencing of population poolsa cost-efficient way to estimate population allele frequencies, but one that introduces an additional level of sampling noise. The utility of these methods is demonstrated in simulations and by reanalyzing human SNP data from the Human Genome Diversity Panel populations and pooled next-generation sequencing data from Atlantic herring. An implementation of our method is available from http://gcbias.org.T HE phenotypes of individuals within a species often vary clinally along environmental gradients (Huxley 1939). Such phenotypic clines have long been central to adaptive arguments in evolutionary biology (Mayr 1942), with diverse examples including latitudinal clines in skin pigmentation in humans (Jablonski 2004), body size and temperature tolerance in Drosophila (Hoffmann and Weeks 2007), and flowering time in plants ( Stinchcombe et al. 2004). Unsurprisingly, comparisons of allele frequencies between populations that differ in environment were among the earliest population genetic tests for selection (Cavalli-Sforza 1966;Lewontin and Krakauer 1973;Endler 1986) and have continued to be central to population genetics to this day (e.g., Coop et al. 2009;Akey et al. 2010).The falling cost of sequencing and genotyping means that such comparisons can now be made on a genome-wide scale, allowing us to start to understand the genetic basis of local adaptation across a broad range of organisms. However, such studies need to acknowledge the sampling issues inherent in population genetic studies of natural populations. In assessing correlations between allele frequencies and environmental vari...