Researchers in the United States say they have uncovered tentative evidence of a genetic component to friendship.
Using data from two independent studies, they found carriers of one gene associated with alcoholism tended to stick together.
However, people with another gene linked with metabolism and openness, stayed apart.
Details are published in the journal Proceedings of the National Academy of Sciences.
The researchers looked at six genetic markers in two long-running US studies, the National Longitudinal Study of Adolescent Health and the Framingham Heart Study, which contain both genetic data and information on friends.
With one gene, called DRD2, which has been associated with alcoholism, they found clusters of friends with the very same marker.
Another gene called CYP2A6, which has a suspected role in the metabolism of foreign bodies including nicotine, appeared more divisive. People with this gene seemed to steer clear of those who also carry the gene.
Why, the researchers don't know, but they speculate it could form part of a defensive ploy.
They say similar patterns have been observed among couples, with individuals avoiding prospective partners who are susceptible to the same diseases.
The gene CYP2A6 has also been associated with an openness to new ideas and situations, they say.
Of course there are many caveats. Those who like a drink might have made most of their friends at a bar or pub, and that may explain any genetic link there.
Nor could the researchers find any strong relationship between genes and friends with four of the six genetic markers which were examined in the study.
But Professor James Fowler of the University of California, who led the study, says genes may go some way to explaining why we often instinctively like - or dislike - the people we meet.
"That feeling that you get that you're just going to like somebody or not going to like them - a lot of times we'll have those instincts about people and we're not sure where they come from," he told BBC News.
"We think that understanding the genotypes that underlie friendship may help us to understand more of that process."
The means by which we identify similar genotypes will also require more research, he says, but it is likely to be based on physical manifestations of certain genes which we are able to identify in people.
"It's not like I'm going to be carrying around a little spit kit and testing all my friends," he says. "It's those genes' underlying characteristics which we must be able to detect in some way either consciously or unconsciously."