WELLINGTON, July 11 (Xinhua) -- An international collaboration led by New Zealand scientists have revealed for the first time the secrets of 500 species of fish that change sex, which remained a mystery for decades.

"We may take it for granted that the sex of an animal is established at birth and doesn't change. However, about 500 species of fish change sex in adulthood, often in response to environmental cues," said geneticist Jenny Graves, one of the co-lead author of the research published in Science Advances on Thursday.

"How sex can reverse so spectacularly has been a mystery for decades. The genes haven't changed, so it must be the signals that turn them off and on," said Graves who has followed the bluehead wrasse for years.

Bluehead wrasses live in groups, on coral reefs of the Caribbean. A dominant male, with a blue head, protects a harem of yellow females. If the male is removed, the biggest female becomes male, in just 10 days. She changes her behavior in minutes, her color in hours. Her ovary becomes a testis and by 10 days it is making sperm, according to the findings.

Using the latest genetic approaches, high-throughput RNA-sequencing and epigenetic analyses, the researchers discovered when and how specific genes are turned off and on in the brain and gonad so that sex change can occur.

The study is important for understanding how genes get turned off and on during development in all animals, including humans, and how the environment can influence this process, researchers said.

"We found that sex change involves a complete genetic rewiring of the gonad," said Erica Todd from the University of Otago, the co-lead author.