Image copyright Jessica Thompson Image caption Burials at Mount Hora in Malawi yielded DNA used in the study

DNA from ancient remains has been used to reconstruct thousands of years of population history in Africa.

Researchers sequenced the genomes of 16 individuals who lived between 8,000 and 1,000 years ago.

The data shows how the invention and spread of farming had a major impact on the genes of people in Africa - just as it did in Europe and Asia.

The findings are published in the journal Cell.

The results suggest that populations related to the indigenous people of southern Africa had a wider distribution in the past.

This southern African-like genetic background is found in hunter-gatherers from Malawi and Tanzania in the east of the continent. These hunters lived between 8,100 and 1,400 years ago.

But the later spread of farmers from western Africa had a major impact on the genetic make-up of people in surrounding regions.

Further DNA analysis revealed the hunter-gatherers in eastern Africa had mixed extensively with the incoming farmers.

The researchers estimate that the mixing occurred between 8,000 and 4,000 years ago.

The study also found possible evidence of migration into Africa from the Middle East. About 38% of the ancestry of a 3,100-year-old livestock herder from Tanzania was related to ancient farmers from the Levant region.

"These results document a prehistoric population landscape that we didn't know about," said co-author Pontus Skoglund, from Harvard Medical School, US.

"They document how farmer and herder migrations swept through eastern and southern Africa."

The researchers also found tentative evidence of adaptive evolution - changes driven by environmental pressure - for genes involved in taste in the ancient individuals. These taste receptors are known to be important for detecting and learning to avoid poisonous plants.