When the sonographer told us we were having a girl, I panicked.

It was July 2022, and the prospect of giving birth to a girl in the United States was fraught. The Supreme Court had just overturned Roe v. Wade — a ruling that made me fear for my daughter’s future and her ability to determine her own destiny. But as I thought about the ways my daughter could be policed by outside forces, a deeper, more personal fear of the policing that many women inflict on themselves and that I’ve inflicted on myself set in.

Food usually brings people together. It’s how we celebrate and connect. And yet I’ve spent decades of my life avoiding and restricting it according to rigid rules of my own design. I find food terrifying and had long been afraid of passing that fear along to a future daughter. While plenty of men suffer from eating disorders, patients with anorexia nervosa and bulimia nervosa are overwhelmingly female.

As a child, I’d always been praised for my thinness. I was a tall, skinny kid, all knees and elbows. In sixth grade my body began to change, and I worried that by gaining weight, I would lose what I thought made me special.

In dance class I scrutinized my leotard-clad form in the mirror. Had my hips grown since the previous week? What about my stomach? I began doing situps in front of the TV at night, eating only bits and pieces of treats: I’d allow myself the chocolate chips from the cookie but not the whole cookie, cookie dough pieces from the ice cream but not the ice cream itself.

These behaviors developed into habits that made my life excruciating. By junior year of high school, I was skipping breakfast, eating only carrots and deli turkey for lunch. Sometimes I allowed myself the frosting — only the frosting — off a piece of cake from the school cafeteria. I was starving by the time I got home, but after I inevitably slipped up and ate a snack, I punished myself at dinner. The next day I’d wake up and follow the same routine. My life became a predictable pattern of self-denial and self-hatred, framed by my constant obsession with food.

College helped. So did meeting my now-husband, as well as a good therapist. I started to improve in my early 20s and had several years in semirecovery, but that fell apart during the pandemic.

I’m embarrassed by all of this. I’m a grown woman, an adult with children and a husband and a mortgage, and I can still be undone by an offer of cake and ice cream at a 4-year-old’s birthday party. I hate to be such a cliché: An upper-middle-class white girl from a high-achieving suburb develops an eating disorder. The after-school special practically writes itself. But my episode didn’t resolve in 30 minutes. It’s been nearly 30 years. Even in my better moments, I never really let go of my belief that skinniness is next to godliness.

All of this crowded my head while my husband squeezed my hand and the sonographer told us our daughter looked perfect — somewhat comforting but possibly the worst adjective she could throw at an anorexic obsessed with the concept.

When my initial panic finally subsided, I found my anxieties rested on my assumption that eating disorders are inherited, passed down genetically, and learned, through behavior and environment. I grew up in the low-fat-obsessed 1990s. So many of the women I knew and admired dieted constantly, casually discussing Weight Watchers points over half a grapefruit and cottage cheese. The body positivity movement has given me some hope, although I now worry that the abuse of popular weight loss drugs like Ozempic might resurrect the heroin chic aesthetic that dominated my childhood.

I started digging into the research on eating disorders and found that anorexia does run in families. One study found that women who have family members with anorexia are 11 times as likely to develop the disease as those without affected family. Anorexia, like most mental illnesses, is passed down via genetics and a person’s environment. My assumptions were partly correct. Many describe the connection through a particular metaphor: Genetics loads the gun, but environment pulls the trigger. So while there is a hereditary element, it doesn’t mean a person’s fate is sealed at birth.

For decades, researchers focused on environment as the cause of mental health problems. Families, particularly mothers, were blamed for their children’s schizophrenia, bipolar disorder or anorexia. That started to change in the 1960s, with the advent of modern twin studies, in which researchers compared identical and fraternal twins. Identical twins share 100 percent of their DNA, and fraternal twins share only around 50 percent, but identical and fraternal twins usually have the same environment. Studies found that identical twins were more likely to both have anorexia compared with fraternal twins, which bolstered the case for a genetic component to the disease.

Modern genomic research has allowed scientists to tease out the genetic and environmental factors even further. The earliest genetic studies homed in on single genes, but today scientists believe that mental illnesses are highly complex and may be associated with hundreds or possibly thousands of genes. In 2019 a consortium of researchers published the largest genomic study of anorexia to date. They compared the genomes of nearly 17,000 patients with anorexia to a control group of just over 55,000 men and women without it. They found eight regions on the genome significantly associated with anorexia, meaning that these regions of the genome are likely to contain genes that increase risk of developing anorexia. Researchers expect there are hundreds more of these regions, to be found in studies with even larger sample sizes.

They also discovered that anorexia shares genetic factors with a number of other mental illnesses, including obsessive-compulsive disorder, anxiety and depression.

It would seem my fears about my daughter developing an eating disorder were not irrational. But whether any one person will develop the disease is difficult to predict because of the complicated relationship between genes and environment. A person may have a loaded gun — a genetic predisposition to anorexia — that is never fired because there are no triggers in their environment. Triggers can also be hard to disentangle from genetics; if a parent is obsessed with dieting, does that count as a genetic factor or an environmental one?

“I don’t think we will ever be to the point where we can give you a number in terms of how likely it is that your child will develop an eating disorder if you have one,” said Cynthia Bulik, a professor at the University of North Carolina and the lead researcher on the 2019 study.

Professor Bulik described my daughter’s odds in terms of a deck of cards. There are four suits. Say the genetic risk factors, like the ones discovered in her study, are the clubs. Then there are probably as-yet-undiscovered protective genetic factors that reduce the influence of risk factors, diminish the possibility of their being expressed or offset their effect altogether. Those protective factors are the spades.

Then there are environmental risk factors, the diamonds. These might be a parent who’s constantly on a diet and a culture that applauds a celebrity’s extreme weight loss. And finally there are the hearts, the protective environmental factors: a parent who eats intuitively, a coach who values healthy, strong bodies.

The clubs and spades are inherited. The diamonds and hearts are accumulated over time. Those cards come together to create an individual’s risk hand.

For all of us, the clubs and spades are what they are. My daughter has my genes. Some of the diamonds and hearts are out of my control, too. I can’t change how our entire society talks about weight. But I can try to mitigate the risk of intergenerational transmission through my behavior. I can choose what she learns in our home, throughout my daughter’s life.

After years of talking around my eating disorder, I’m acknowledging it and accepting more help. My daughter inspires me — her resolute determination as she sucks down a bottle, the way she breaks into a smile, no matter what I look like, when I come into view. As her mom, I sometimes feel I’m swimming against a strong tide made up of my genetics, my upbringing and society’s beliefs about women. But as my mother will gladly remind me, a reason is not an excuse.

My eating disorder is not the only legacy my daughter has inherited. She is lucky to have plenty of protective environmental and genetic factors, too. When I think about the life I want for her, I remember another moment last summer. My mother, sister and I went to visit my grandmother for her 90th birthday. My sister baked a carrot cake, two layers of moist sponge with swirls of cream cheese frosting. After dinner she doled out huge pieces that we ate while we sat around the table, talking and laughing, three generations of women stubbornly enjoying cake and one another’s company.

My baby girl is so lucky to have these women in her life, and I look forward to when she’s old enough to pull up a chair and cut herself a slice.