Bacterial growth in multicellular aggregates leads to the emergence of complex life cycles