Ever feel tickled as a dog approached you -- tail wagging, friendly face -- only to realize he was after that half-sandwich you had stashed in your bag? It turns out that food may also have been the original lure as dogs first became domesticated.

A detailed analysis of the dog genome has linked widespread dog domestication with the emergence of agriculture. Dogs were likely attracted to humans -- and our food -- as opposed to humans bringing dogs to settlements.

The genetic clues, outlined in the latest issue of the journal Nature, reveal how dogs adapted to a starch-rich diet, possibly around 12,000 years ago.

"Our findings show that it was crucial to early dogs to be able to thrive on a diet rich in starch," lead author Erik Axelsson told Discovery News. "That indicates that dog domestication may be linked to the development of agriculture. It is possible that dogs may have been domesticated independently at locations where agriculture developed early, such as the Fertile Crescent and China."

Axelsson, who works in Uppsala University's Science for Life Laboratory, and his team made the determination after comparing DNA from 60 dogs representing 14 diverse breeds with DNA from 12 wolves of worldwide distribution.

While wolves have no genomic signature associated with starch consumption, dogs possess at least 10 genes that mutated to provide functional support for improved starch digestion. Wolves can digest starch, but the mutations allow dogs to do this much more efficiently.

"It is possible that waste dumps near early human settlements supplied early dogs with a substantial fraction of their nutritional needs," Axelsson explained. "If so, they would have been eating leftovers of the food we were eating. That food might have included roots, cereals and food made from cereals, such as bread and porridge, in addition to some meat and bone marrow from discarded bones."