Genes can make and break friendships in a way that may have influenced human evolution, say US scientists.
Research suggests that friendship choices are partly driven by our genes.
A particular shared genetic trait might help to draw two people together, or force them apart, say scientists.
The effect can result in "genetic clustering" in social networks, influencing the genetic make-up of populations.
This may have implications for studies looking at the effect of genes on human behaviour. It also adds an extra social twist to the story of human evolution, say researchers.
Scientists led by Dr James Fowler, from the University of California at San Diego, used data from two large health studies to search for genetic links to friendship.
The researchers identified genetic markers, or genotypes, in six specific genes and looked at how often they occurred among friends.
They found two clear examples where "birds of a feather flock together" and "opposites attract".
The first involved a variant of the gene DRD2 which has been associated with alcoholism.
People who carried the DRD2 genotype tended to befriend others with the same marker. Those without were also more likely to be friends.
"It is not hard to imagine that non-drinkers may actively avoid alcoholics, or that alcoholics may be drawn to environments that non-drinkers avoid," said the researchers writing in the journal Proceedings of the National Academy of Sciences.
A less obvious opposite association was seen between people with a version of the gene CYP2A6 linked to having an "open" personality. In this case, people with the genetic marker gravitated towards individuals who did not have it.
The findings took account of people's tendency to form "local" friendship within the same geographical area.