Abstract
Bacteria exhibit varying niche breadths, with generalists thriving in diverse environments and specialists confined to specific habitats. Although genes for cooperative traits have been suggested to influence niche breadth evolution, their precise role remains unclear. We used a combination of phylogeny-based comparative methods to test causal hypotheses about the directionality of the relationship between genes for cooperation and bacterial niche breadth evolution across 25,785 species. Our results revealed 1) a positive correlation between the proportion of genes for cooperation and niche breadth; 2) genes for cooperation influenced niche breadth evolution, with a decreased proportion of such genes promoting niche contraction as the predominant evolutionary direction; and 3) genes for cooperation experience more frequent gain and loss within species rather than across species. These findings suggest a role of bacterial cooperation in influencing niche breadth evolution and maintaining the ecological versatility of bacteria. While our results are consistent with a simple relationship under the hypotheses tested, more complex causal scenarios are possible, including the role of factors that influence both cooperation and niche breadth.