Very roughly, the SRY gene (a small segment of the Y chromosome) is the 'master switch' regarding sex. This study has identified a few other gene sequences that have something to do with determining what happens when that master switch is flipped from 'female' to 'male'. They also suggest that mutations in these might have something to do with intersex conditions where a woman has a Y chromosome.
Nfr