It has been known that if the gene W in drosophila plays a role, male drosophila will not courtship female drosophila and instead pursue homosexuality. 
If the male drosophila becomes an adult, as long as it is fed collectively for more than one day, the male drosophila begins to chase other female drosophila and show courtship behavior. However, if the drosophila is raised in isolation after emergence, this behavior will not occur.
 the homosexuality of drosophila is considered to be determined by genetic factors. Recently, researchers cultured male drosophila with the gene W, and then conducted experiments with this kind of drosophila. They found that the homosexual behavior of drosophila is not only affected by genetic factors, but also promoted by social factors.