However, the researchers also found that the same gene variant that can make a person sad in one context, can trigger happiness in another context.
"Our results suggest some people have a genetic makeup that makes them more susceptible to negative environments, but if put in a supportive environment these same people are likely to thrive," said lead investigator Chad Bousman from the University of Melbourne in Australia.
The research focussed on a particular gene, known as SERT, that transports the mood-regulating chemical, serotonin.
Every person has one of three types of SERT gene, either the long-long (l/l), the short-long (s/l), or the short-short (s/s).
The team DNA-tested 333 middle-aged people. They recorded their depressive symptoms each year over a five-year period.
They found that those with the s/s genotype who had experienced sexual or physical abuse as a child were more likely to experience ongoing severe depressive symptoms in middle age.
But, conversely, those with this same genotype but no history of abuse were happier than the rest of the population.
Bousman said this is good news for people experiencing depression and their treating health professionals.
"You cannot change your genotype or go back and change your childhood, but you can take steps to modify your current environment," he said.
The research was published in the British Journal of Psychiatry Open