Preserving genes: a model of the maintenance of genetic variation in a metapopulation under frequency-dependent selection