Testing for Associations between Loci and Environmental Gradients Using Latent Factor Mixed Models