  Some bacteria and archaea possess an adaptive immune system that maintains a
memory of past viral infections as DNA elements called spacers, stored in the
CRISPR loci of their genomes. This memory is used to mount targeted responses
against threats. However, cross-reactivity of CRISPR targeting mechanisms
suggests that incorporation of foreign spacers can also lead to autoimmunity.
We show that balancing antiviral defense against autoimmunity predicts a
scaling law relating spacer length and CRISPR repertoire size. By analyzing a
database of microbial CRISPR-Cas systems, we find that the predicted scaling
law is realized empirically across prokaryotes, and arises through the
proportionate use of different CRISPR types by species differing in the size of
immune memory. In contrast, strains with nonfunctional CRISPR loci do not show
this scaling. We also demonstrate that simple population-level selection
mechanisms can generate the scaling, along with observed variations between
strains of a given species.
