Interplay between Ecology and Evolution of Microbial Communities Engaged in a Public Goods Game