this is pretty interesting: Scientists find single ‘on-off’ gene that can change gender traits
The gene appears to have a “see-saw” relationship with another gene, SOX9, which is normally active only in males. When one is on, the other is automatically off. In the first few days of male development SOX9 is turned on, and this stops FOXL2 from becoming active for the rest of the man’s life. The reverse occurs in females, with FOXL2 being switched on first.