Each year, billions of people get infected with viruses–with common ones like influenza and cold viruses, and rarer ones like polio and Ebola. The viruses don’t stay all that long inside of us. In most cases, our immune systems wipe them out, except for a few refugees that manage to escape to a new host and keep their species alive. In some cases, the viruses kill their unfortunate hosts, and end their own existence as well. But in some exquisitely rare cases, viruses meld with the genome of their hosts and become part of the genetic legacy their hosts pass down to future generations.

Scientists know this melding has happened because viruses have distinctive genes. When scientists scan the human genome, they sometimes come across a stretch of DNA that bears the hallmarks of viruses. The easiest type of virus to recognize are retroviruses, a group that includes HIV. Retroviruses make copies of themselves by infecting cells and then using an enzyme to insert their genes into their host cell’s DNA. The cell then reads the inserted DNA and makes new molecules that assemble into new viruses.

Most of the time, retroviruses behave like other viruses, jumping from host to host. But sometimes a retrovirus will end up in the genome of an egg or sperm. If it then ends up in a new embryo, the embryo will carry a copy of the virus in every single cell–including its own egg or sperm. And on and on, from parents to children to grandchildren.

If the virus DNA remains intact, it still has the capacity to multiply. It may produce new viruses that break out of a cell, and even leap into a new host. But over the generations, the virus DNA may mutate and degrade. It may no longer be able to escape its own cell. But the virus may still have a bit of life left to it: it can make new viruses that insert their genes back into the genome at a new location. Here’s a simplified diagram of how it works…

View Images Dewannieux and Heidmann 2013 dx.doi.org/10.1016/j.coviro.2013.08.005

This process has generated a huge amount of viral DNA in the human genome. We carry about 100,000 pieces of DNA that came from retroviruses–known as endogenous retroviruses. All told, they come to an estimated 5 to 8 percent of the entire human genome. That’s several times more DNA that makes up all 20,000 of our protein-coding genes.

When biologists started sequencing the genomes of other species, they discovered that it’s taken millions of years to pile up all this viral DNA. They found some of the same endogenous retroviruses in the genome of chimpanzees, for example. Since our ancestors split from theirs about seven million years ago, this shared viral DNA must come from our common ancestor.

Gkikas Magiorkinis, a University of Oxford virologist, and his colleagues have now carried out large-scale survey of endogenous retroviruses in humans, apes, and Old World monkeys–a group of species that all descend from a common primate ancestor that lived some 40 million years ago. They catalogued the viruses in each species and compared them to the versions in the other primates. They were able to reconstruct the history of our viral DNA in unprecedented detail, even coming up with estimates for the rate at which the viruses inserted new copies into our genome.

The scientists can trace our viral DNA to 30 to 35 separate invasions. Once each virus established itself in our ancestors’ DNA, it produced copies of itself scattered through the genome. The rate at which new copies were inserted rose and fell over time, and at different rates in different branches of the primate tree. Here’s an overall look at the history of the viruses. (“Loci” here refers to new copies of viruses inserted into the genome in a given interval of time.)

View Images Magiorkinis et al, Retrovirology 2015

Our monkey-like ancestors 40 million years ago acquired new virus copies at a fast clip–much faster than in our own lineage in the past couple million years. One virus in particular, known as HERV-H, was responsible for most of the new copies. It may have evolved adaptations that made it into a superspreader inside the genome.

In the Old World monkeys–represented in the new study by baboons and macaques–the rate of new virus copies pretty much stayed the same over the past 30 million years. But the apes tell a different story. The rate dropped in every ape branch. The same shift occurred in parallel in the ancestors of humans, chimpanzees, gorillas, orangutans, and gibbons.

It’s possible that some of this decline had something to do with the fact that we have been fighting back against our inner viruses for millions of years. A newly inserted virus may disrupt an essential gene, and the result may be that its cell may become cancerous. Scientists have documented this threat by studying mice, which are often the victims of retrovirus-driven cancer. And they’ve also found that mammal cells can minimize this risk in many ways. One way is to coil up virus DNA so that it can’t get copied. Another way is to make special proteins that damage newly made virus genes.

One thing that apes have in common is that they’re big. If you’re a big animal, that means you have more cells, and more cells should mean you have a bigger risk of developing cancer. Yet we don’t. The risk of cancer in a human is no greater than a mouse. It’s possible that an increase in body size drives the evolution of new defenses against cancer. And those defenses may include doing a better job of keeping viruses in check.

But Magiorkinis and his colleagues suspect that getting big can only explain some of the decline. In the human lineage in particular, viruses have slowed down drastically. Here’s a graph from their new study that tracks the frequency of new virus copies in the human genome over time:

View Images Magiorkinis et al, Retrovirology 2015

In the past million years, only a single virus has continued to multiply–known as HERV-K. Today, you can find some HERV-K copies in some people and not in others. The pattern of these copies suggests that as recently as 250,000 years ago, HERV-K was still making new copies.

It’s possible that HERV-K is completely dead now. There’s no evidence that HERV-K or any other endogenous retrovirus is actively spreading or causing cancer. It’s hard to say at this point why humans have put the brakes on endogenous retroviruses. But Magiorkinis has one suggestion: our ancestors may have reduced their odds of picking up new viruses.

Retroviruses like HIV can be spread by blood. Other primates use their teeth as weapon, either to kill prey or to fight other primates. If their victim has an infection, they can get infected, too. Ancient humans evolved to gather food with tools rather than teeth. Males stopped chomping other males, a shift that is reflected in the shrinking canine teeth of our ancestors. By making ourselves less vulnerable to blood-borne viruses, we put a stop to the influx of retroviruses overrunning our genomes.

There’s no way of telling if we are done with new endogenous retroviruses for good now, or if HIV or some other new retrovirus will manage to work its way into our genes. But the history of our inner viruses is still important to our health. Scientists have found HERV-K proteins made in tumors, suggesting that cancer cells may harness some of the biochemical power in these ancient parasites. Knowing their past can let us understand how they’ll affect us in the future.

(For more information, see my book A Planet of Viruses.)