A person’s sex is science, but their gender is a social construct.
Even sex is not the black and white dichotomy most people make it out to be. The way we define and dictate someone’s sex isn’t reproducible for everyone. The intersex population is larger than what most people assume, and can vary in ways that defy the way we normally evaluate sex. It can range from someone having different chromosomal pairings, to having a varied arrangement of secondary sexual organs.
Anyone saying that someone’s sex is scientifically dependent on “x” is either ignorant, or academically dishonest.