Ancient food waste holds the history of the Sahara desert’s climate in its bones. Nearly 5,000 years worth of fossilized leftovers in the Takarkori rock shelter in southwestern Libya show ancient humans’ transition from a mostly-fish diet to one that featured more land animals like sheep and cattle, according to new research published on February 29 in the journal PLOS One.

About 11,000 years ago, the Sahara, which is now a hyperarid desert, was in a green phase. Sediment and pollen data show that the iconic desert was once covered in lakes, rivers and wetlands, but between 4,500 and 8,000 years ago, the humid savannah transitioned into the dry, windy desert that’s recognizable today. Residing in rock shelters like the one researchers studied at Takarkori, ancient human hunter-gatherers lived through it all.

Researchers from Belgium and Italy analyzed over 17,000 animal remains from the rock shelter. The bones were marked with cuts and burns, signs that they were cooked and eaten by humans. The researchers found that catfish and tilapia bones made up 90 percent of the finds from the first few thousand years that humans inhabited the shelter, starting about 10,000 years ago. But of the more recent 4,650- to 5,900-year-old remains, only about 40 percent were fish bones, and the majority belonged to mammals.

“All the other finds are surface finds, [from] just one layer, one period, one event. Whereas what we have here is a 5,000-year sequence with a lot of bones – so that makes it special,” bioarchaeologist Wim van Neer, a co-author of the study, tells the Guardian’s Nicola Davis.

Analyzing the bones further, the researchers found the number of tilapia decreased with time, possibly because catfish are better adapted to live in warm, shallow water, according to a PLOS statement.

Previous research has shown that about 6,400 years ago, the Takarkori shelter’s original residents called the Late Acacus hunter-gatherers were replaced by people who used early agricultural practices. Research has found evidence that the pastoral residents cultivated weed-like cereal grasses, and that pastoral groups around the rock shelter kept herds of domesticated Barbary sheep.

That has led some experts to suggest that the introduction of domesticated livestock may have exacerbated the region’s shift from the “Green Sahara” to the desert seen today, as Lorraine Boissoneault reported for Smithsonian magazine in 2017. Though critics suggest the shift back to a desert was inevitable.

The new research in PLOS One provides evidence that regardless of whether humans influenced the creation of the desert, their behavior reflected the constraints of a rapidly changing climate.

“There are not a whole lot of sites like Takarkori that show the transition in the ways people were eating in this period of dramatic landscape change,” University of Oslo archaeologist David Wright says to Jason Arunn Murugesu at New Scientist. “It is just one piece of the puzzle, but an important one as we wrestle with understanding how people can adapt to extreme forms of climate change.”