In the last two decades, dozens of scientific papers have been published on the biological origins of homosexuality - another announcement was made last week. It's becoming scientific orthodoxy. But how does it fit with Darwin's theory of evolution?
Macklemore and Ryan Lewis's hit song Same Love, which has become an unofficial anthem of the pro-gay marriage campaign in the US, reflects how many gay people feel about their sexuality.
But scientific opinion is with Macklemore. Since the early 1990s, researchers have shown that homosexuality is more common in brothers and relatives on the same maternal line, and a genetic factor is taken to be the cause. Also relevant - although in no way proof - is research identifying physical differences in the brains of adult straight and gay people, and a dizzying array of homosexual behaviour in animals.
But since gay and lesbian people have fewer children than straight people, a problem arises.
"This is a paradox from an evolutionary perspective," says Paul Vasey from the University of Lethbridge in Canada. "How can a trait like male homosexuality, which has a genetic component, persist over evolutionary time if the individuals that carry the genes associated with that trait are not reproducing?"
Scientists don't know the answer to this Darwinian puzzle, but there are several theories. It's possible that different mechanisms may be at work in different people. Most of the theories relate to research on male homosexuality. The evolution of lesbianism is relatively understudied - it may work in a similar way or be completely different.
The genes that code for homosexuality do other things too
The allele - or group of genes - that sometimes codes for homosexual orientation may at other times have a strong reproductive benefit. This would compensate for gay people's lack of reproduction and ensure the continuation of the trait, as non-gay carriers of the gene pass it down.
There are two or more ways this might happen. One possibility is that the allele confers a psychological trait that makes straight men more attractive to women, or straight women more attractive to men. "We know that women tend to like more feminine behavioural features and facial features in their men, and that might be associated with things like good parenting skills or greater empathy," says Qazi Rahman, co-author of Born Gay; The Psychobiology of Sex Orientation. Therefore, the theory goes, a low "dose" of these alleles enhances the carrier's chances of reproductive success. Every now and then a family member receives a larger dose that affects his or her sexual orientation, but the allele still has an overall reproductive advantage.
Another way a "gay allele" might be able to compensate for a reproductive deficit is by having the converse effect in the opposite sex. For example, an allele which makes the bearer attracted to men has an obvious reproductive advantage to women. If it appears in a man's genetic code it will code for same-sex attraction, but so long as this happens rarely the allele still has a net evolutionary benefit.
There is some evidence for this second theory. Andrea Camperio-Ciani, at the University of Padova in Italy, found that maternal female relatives of gay men have more children than maternal female relatives of straight men. The implication is that there is an unknown mechanism in the X chromosome of men's genetic code which helps women in the family have more babies, but can lead to homosexuality in men. These results haven't been replicated in some ethnic groups - but that doesn't mean they are wrong with regards to the Italian population in Camperio-Ciani's study.
Gay people were 'helpers in the nest'
Some researchers believe that to understand the evolution of gay people, we need to look at how they fit into the wider culture.
Paul Vasey's research in Samoa has focused on a theory called kin selection or the "helper in the nest" hypothesis. The idea is that gay people compensate for their lack of children by promoting the reproductive fitness of brothers or sisters, contributing money or performing other uncle-like activities such as babysitting or tutoring. Some of the gay person's genetic code is shared with nieces and nephews and so, the theory goes, the genes which code for sexual orientation still get passed down.
Sceptics have pointed out that since on average people share just 25% of their genetic code with these relatives, they would need to compensate for every child they don't have themselves with two nieces or nephews that wouldn't otherwise have existed. Vasey hasn't yet measured just how much having a homosexual orientation boosts siblings' reproduction rate, but he has established that in Samoa "gay" men spend more time on uncle-like activities than "straight" men.
"No-one was more surprised than me," says Vasey about his findings. His lab had previously shown that gay men in Japan were no more attentive or generous towards their nieces and nephews than straight, childless men and women. The same result has been found in the UK, US and Canada.
Vasey believes that his Samoan result was different because the men he studied there were different. He studied the fa'afafine, who identify as a third gender, dressing as women and having sex with men who regard themselves as "straight". They are a transgender group who do not like to be called "gay" or "homosexual".
Vasey speculates that part of the reason the fa'afafine are more attentive to their nephews and nieces is their acceptance in Samoan culture compared to gay men in the West and Japan ("You can't help your kin if they've rejected you"). But he also believes that there is something about the fa'afafine way of life that means they are more likely to be nurturing towards nieces and nephews, and speculates that he would find similar results in other "third gender" groups around the world.
If this is true, then the helper in the nest theory may partly explain how a genetic trait for same-sex attraction hasn't been selected away. That hypothesis has led Vasey to speculate that the gay men who identify as men and have masculine traits - that is to say, most gay men in the West - are descended from men who had a cross-gendered sexuality.
Gay people do have children
In the US, around 37% of lesbian, gay, bisexual and transsexual people have a child, about 60% of which are biological. According to the Williams Institute, gay couples that have children have an average of two.
These figures may not be high enough to sustain genetic traits specific to this group, but the evolutionary biologist Jeremy Yoder points out in a blog post that for much of modern history gay people haven't been living openly gay lives. Compelled by society to enter marriages and have children, their reproduction rates may have been higher than they are now.
How many gay people have children also depends on how you define being "gay". Many of the "straight" men who have sex with fa'afafine in Samoa go on to get married and have children.
"The category of same-sex sexuality becomes very diffuse when you take a multicultural perspective," says Joan Roughgarden, an evolutionary biologist at the University of Hawaii. "If you go to India, you'll find that if someone says they are 'gay' or 'homosexual' then that immediately identifies them as Western. But that doesn't mean there's no homosexuality there."
Similarly in the West, there is evidence that many people go through a phase of homosexual activity. In the 1940s, US sex researcher Alfred Kinsey found that while just 4% of white men were exclusively gay after adolescence, 10% had a three-year period of gay activity and 37% had gay sex at some point in their lives.
A national survey of sexual attitudes in the UK last year came up with lower figures. Some 16% of women said they had had a sexual experience with another woman (8% had genital contact), and 7% of men said they had had a sexual experience with a man (with 5% having genital contact).
But most scientists researching gay evolution are interested in an ongoing, internal pattern of desire rather than whether people identify as gay or straight or how often people have gay sex. "Sexual identity and sexual behaviours are not good measures of sexual orientation," says Paul Vasey. "Sexual feelings are."
It's not all in the DNA
Qazi Rahman says that alleles coding for same sex attraction only explain some of the variety in human sexuality. Other, naturally varying biological factors come into play, with about one in seven gay men, he says, owing their sexuality to the "big brother effect".
This has nothing to do with George Orwell, but describes the observation that boys with older brothers are significantly more likely to become gay - with every older brother the chance of homosexuality increases by about a third. No-one knows why this is, but one theory is that with each male pregnancy, a woman's body forms an immune reaction to proteins that have a role in the development of the male brain. Since this only comes into play after several siblings have been born - most of whom are heterosexual and go on to have children - this pre-natal quirk hasn't been selected away by evolution.
Exposure to unusual levels of hormone before birth can also affect sexuality. For example, female foetuses exposed to higher levels of testosterone before birth show higher rates of lesbianism later on. Studies show that "butch" lesbian women and men have a smaller difference in length between their index and ring fingers - a marker of pre-natal exposure to testosterone. In "femme" lesbians the difference has been found to be less marked.
Brothers of a different kind - identical twins - also pose a tricky question. Research has found that if an identical twin is gay, there is about a 20% chance that the sibling will have the same sexual orientation. While that's a greater likelihood than random, it's lower than you might expect for two people with the same genetic code.
William Rice, from the University of California Santa Barbara, says that it may be possible to explain this by looking not at our genetic code but at the way it is processed. Rice and his colleagues refer to the emerging field of epigenetics, which studies the "epimarks" that decide which parts of our DNA get switched on or off. Epimarks get passed on to children, but only sometimes. Rice believes that female foetuses employ an epimark that makes them less sensitive to testosterone. Usually it's not inherited, but occasionally it is, leading to same-sex preference in boys.
Dr William Byne, editor-in-chief of the journal LGBT Health, believes sexuality may well be inborn, but thinks it could be more complicated than some scientists believe. He notes that the heritability of homosexuality is similar to that for divorce, but "social science researchers have not… searched for 'divorce genes'. Instead they have focused on heritable personality and temperamental traits that might influence the likelihood of divorce."
For Qazi Rahman, it's the media that oversimplifies genetic theories of sexuality, with their reports of the discovery of "the gay gene". He believes that sexuality involves tens or perhaps hundreds of alleles that will probably take decades to uncover. And even if heterosexual sex is more advantageous in evolutionary terms than gay sex, it's not only gay people whose sexuality is determined by their genes, he says, but straight people too.