"Immigration to California well into the 1850s was almost exclusively male, and a high proportion of the few female immigrants were prostitutes. In such sex-segregated and relatively closed environments (mining camps, prisons, ships), particularly where male-female sexuality is conducted largely on a commercial basis, there tends to be a high incidence of "situational" homosexual activity among men...
...The atypical gender distribution of San Francisco's mid-nineteenth-century population contributed to the development of a large "vice" district, the fabled "Barbary Coast," which quickly earned San Francisco its reputation as a "wide-open town." The relative openness of a bawdy, semi-public sexual culture in San Francisco no doubt contributed to the development of rich homosexual and transgender subcultures before the twentieth century, as did the city's maritime economy and its burgeoning, bohemian literary and art scenes. Asbury notes that the brothels along Commercial Street in particular "were much frequented by degenerates," such as men who wore women's clothing, and that popular erotic sex cabarets included both male and female entertainers "who were encouraged to do whatever their erotic fantasies might dictate...
..."~
http://www.glbtq.com/social-sciences/san_francisco.html