Competition between recombination and epistasis can cause a transition from allele to genotype selection