  A central part of population genomics consists of finding genomic regions
implicated in local adaptation. Population genomic analyses are based on
genotyping numerous molecular markers and looking for outlier loci in terms of
patterns of genetic differentiation. One of the most common approach for
selection scan is based on statistics that measure population differentiation
such as $F_{ST}$. However they are important caveats with approaches related to
$F_{ST}$ because they require grouping individuals into populations and they
additionally assume a particular model of population structure. Here we
implement a more flexible individual-based approach based on Bayesian factor
models. Factor models capture population structure with latent variables called
factors, which can describe clustering of individuals into populations or
isolation-by-distance patterns. Using hierarchical Bayesian modeling, we both
infer population structure and identify outlier loci that are candidates for
local adaptation. As outlier loci, the hierarchical factor model searches for
loci that are atypically related to population structure as measured by the
latent factors. In a model of population divergence, we show that the factor
model can achieve a 2-fold or more reduction of false discovery rate compared
to the software BayeScan or compared to a $F_{ST}$ approach. We analyze the
data of the Human Genome Diversity Panel to provide an example of how factor
models can be used to detect local adaptation with a large number of SNPs. The
Bayesian factor model is implemented in the open-source PCAdapt software.
