A large scale study of Scottish people's DNA is threatening to "rewrite the nation's history", according to author Alistair Moffat.

Scotland, he told the Edinburgh international book festival, despite a long-held belief that its ethnic make-up was largely Scots, Celtic, Viking and Irish, was in fact "one of the most diverse nations on earth".

"The explanation is simple. We are a people on the edge of beyond; on the end of a massive continent. Peoples were migrating northwest; and they couldn't get any further. We have collected them."

He and his colleagues have found West African, Arabian, south-east Asian and Siberian ancestry in Scotland. "The West African ancestry mostly originates in the 18th century, so it is almost certainly to do with the slave trade," he said.

David Lammy, MP for Tottenham, whose immediate ancestors are from the Caribbean, also revealed at the festival this week that DNA analysis had shown he has Orcadian ancestry – also likely to relate to British involvement in the Atlantic slave trade.

One per cent of all Scottish men, said Moffat, have Berber ancestry – why, he says, remains a mystery, though he believes that the penetration of people from the medieval caliphate of Cordoba "must have been immensely important". Moffat said his colleagues had also discovered DNA originating from Roman-period Illyria, the area occupied by modern Croatia, which may relate to Roman occupation of lowland Scotland.

Many of Moffat and Wilson's findings are laid out in their book The Scots: A Genetic Journey. But research continues apace, and most recent finding suggests that porridge has been a crucial factor in the nation's early history, Moffat said.

Until recently, he said, it had been believed that farming arrived incrementally in Scotland, around 3,000 years ago, by a process of slow and gradual adoption, by women, of new techniques. But their recent DNA research suggests something quite different, he said: that it arrived quickly via young male immigrants from what is now Germany.

These young men, he said, brought brand-new techniques with them, planting grass-derived crops that could be turned into porridge and fed to young children. This new improved food production reduced the period, argued Moffat, that the hunter-gatherer mothers had to devote to breast-feeding, and thus increased their fertility. This led to a population explosion, he said, laying the seeds of a recognisable society in northern Britain. "It is a revelation. Porridge, and I'm not joking about this, is absolutely crucial to our history."

Not every analysis of DNA has delivered welcome results. DNA analysis on Moffat himself – a proud Scottish Borders man – showed that his ancestry was English. "We don't offer counselling for that," he said.