Maintenance of restriction-modification system diversity creates pan-immunity
Bacterial antiviral defense systems are highly diverse and unevenly distributed across populations, such that different strains carry distinct immune repertoires that together form a pan-immune system. Restriction-modification (RM) systems are the most abundant bacterial defense systems and exemplify this architecture, exhibiting remarkable diversity in structure, function, specificity, and efficacy. How and why such diversity is maintained, why weaker systems are not outcompeted, and whether diversity provides benefits beyond protection of individual cells remain unclear. Here, we experimentally tracked bacteria and phages across populations differing in RM diversity. We find no consistent evidence of a trade-off between defense strength and host fitness. Instead, we identify a trade-off between defense strength and horizontal transferability: stronger RM systems are less able to spread between strains, likely because factors that increase defense strength also increase toxicity risk upon transfer to unmethylated hosts. These weaker yet more mobile systems may therefore act as more accessible pan-immune components that bacterial populations can acquire in response to shifting parasite pressures. Furthermore, we show RM systems experience negative frequency-dependent selection, such that common specificities are more readily overcome by phages while rare ones remain protective, causing the benefits of potent systems to erode as they spread. Together, these dynamics maintain RM diversity and explain why weaker systems persist alongside stronger ones. Finally, we show that population-level RM diversity generates collective protection by constraining the emergence of RM-escaping phages and limiting the invasion of bacterial surface mutants that avoid phage adsorption, providing experimental support for the pan-immune model.