Ancient communities transformed the Amazon thousands of years ago, farming in a way which has had a lasting impact on the rainforest, a major new study shows.