Abstract
A major theoretical problem in community ecology is to understand how genes, organisms, and environments combine to shape the structure and diversity of ecological communities. However, most classic ecological models work entirely with phenotypic parameters, neglecting the central role played by genes. This limitation is particularly acute in microbial ecology, where the widespread use of sequencing technologies allows researchers to directly measure the genomic and metagenomic properties of communities. Here, we bridge this gap by incorporating genotype-to-phenotype maps into classical ecological models, including the generalized Lotka-Volterra model (GLV) and consumer resource models (CRMs). We focus on the case where genotype-to-phenotype maps are linear, which provides a tractable yet powerful framework for analyzing complex traits. Even in this simple setting, the resulting ecological dynamics give rise to novel gene-level ecological dynamics that can be recast entirely in terms of genes, allowing us to develop an ecology of metagenomes. We find that ecological interactions between genes lead to pervasive "metagenomic hitchhiking" - low-fitness genes can survive in the ecosystem because they are integrated into genomes of high-fitness species. We also show that phylogenetic relationships between species mold the ability of closely related strains to stably coexist in complex communities. This highlights how lineage structure and competitive interactions jointly shape community composition. Our framework provides a principled foundation for interpreting metagenomic data through the lens of ecological theory. AUTHOR SUMMARY: Recent advances in sequencing technologies have transformed our ability to characterize microbial communities at the genomic level. However, most classic ecological models work entirely with phenotypic parameters, neglecting the central role played by genes. Here, we address this gap by extending classical ecological models to explicitly include genotype-to-phenotype maps. We focus on complex traits where the genotype-to-phenotype map is approximately linear. We show that the resulting ecological dynamics that can be recast entirely in terms of genes, allowing us to develop an ecology of metagenomes. Our framework provides a novel perspective for interpreting metagenomic data through the lens of ecological theory.