The study got its start after Dr. Amit V. Khera, one of Dr. Kathiresan’s postdoctoral fellows, noticed that researchers had looked at genetic risks of heart disease and had, in different studies, looked at the effect of environment and lifestyle risks. So, he wondered, why not look at lifestyles and genetics in the same populations and see how much each contributes?

The researchers began about a year and a half ago, analyzing data from four large studies that not only had genetic data on participants but also had information on lifestyles and on which participants developed heart disease.

The investigators developed a genetic score based on 50 genes associated with heart disease. They developed a lifestyle score based on whether people smoked, whether they exercised at least once a week, whether they followed a healthy diet — one with fruits, vegetables, fish, whole grains and nuts — and whether they were obese.

An optimum lifestyle score was defined as having three or all four of these elements, which is important, Dr. Kathiresan said, because many people who are obese have enormous difficulty losing weight and maintaining their weight loss. “You can get into this group even if you are obese by not smoking, exercising and eating a healthy diet, “ he said.

Even better, said Dr. Lawrence J. Appel, the director of the Welch Center for Prevention, Epidemiology and Clinical Research at Johns Hopkins Medicine, you do not have to have an exemplary lifestyle to reap a big benefit. It looks as if the biggest protective effect by far came from going from a terrible lifestyle to one that was at least moderately good.

Dr. John Michael Gaziano, a preventive cardiologist at the VA Boston Healthcare System and at Brigham and Women’s Hospital, said the work showed the power of large data sets. Until recently, researchers mostly used much smaller data sets, which tend to have a lot of random variation, making results hard to interpret. The Million Veteran Program, a study that he is leading, and the National Institutes of Health’s precision medicine initiative that is recruiting a million participants should provide the sort of data that can make results like Dr. Kathiresan’s more feasible and more powerful.

For Dr. Gaziano, the biggest surprise was that a test based on combining 50 genes, each of which had a tiny role in heart disease, was such a powerful predictor of risk. The larger studies underway now should allow researchers to understand more about how much each of those genes contributes, he added.