data [50,51], the initial assembly of the secretin rings (SctC) at the outer membrane favors assembly of the inner membrane rings by interacting with SctD. The secretion apparatus then assembles independently of the basal body. Together, these two structures recruit SctJ at the inner membrane. In the inside-out model, inferred primarily from Salmonella data [52], assembly starts with the secretion apparatus, which provides a platform stabilizing the inner ring association between SctJ and SctD. The interaction of SctD and the secretin stabilizes the outer membrane rings. The SctQ C-ring and SctN ATPase are then recruited to the complex in both models. The general secretory pathway translocates the non-cytoplasmic components of this initial complex but once the ATPase is in place, the remaining components, including the inner rod (SctI), the needle filament (SctF) and the tip (LcrV), are secreted by the assembling NF-T3SS itself [53]. Upon contact with a host-cell membrane, the NF-T3SS initially secretes the translocators and then the effectors. The processes of NF-T3SS assembly and secretion of translocators and effectors involve a series of switches to control the timing, order and number of secreted proteins [54]. The flagellum assembly pathway shares many of these organizing principles, including switches of secretion substrates as the appendage forms [55,56], and inside- out assembly [57]. Interestingly, it is not yet clear if NF-T3SS effectors are delivered through the central channel of the needle/ pilus structures, as suggested by the designation ‘‘injectisome’’. It is possible that the needle is only a sensor and regulator used to establish tight cell contacts and trigger the extracellular secretion of effectors [58,59] for subsequent translocation to the eukaryotic cell [60]. Experimentally studied NF-T3SSs include between 15 and 25 proteins, of which nine are ubiquitous core proteins (SctCJNQRSTUV) and four other (SctDFLP) are present in most systems (Figure 1A, Table S1) [3,6,8,61]. Phylogenetic analyses of the ubiquitous proteins led to the identification of seven different NF-T3SS types [62], each including one or a few different model systems: SPI1 includes an NF-T3SS from the S. enterica Pathoge- nicity Island 1 and from Shigella [27,63], SPI2 is from a second locus in S. enterica [64,65], Ysc from Yersinia [66], Chlamy from Chlamydia trachomatis [67], Rhizo from Rhizobium sp. strain NGR234 [18], Hrp1 from Pseudomonas syringae [68] and Hrp2 from Ralstonia solanacearum [69]. Interestingly, this categorization distinguished systems involved in bacterial interactions with animals and protozoa (SPI1, SPI2, Ysc, Chlamy systems) from systems involved in interactions with plants and fungi (Hrp1, Hrp2, Rhizo systems). A number of these NF-T3SS proteins are homologous to the flagellum [70], clearly showing common ancestry of the two structures: of 13 (nearly) ubiquitous proteins in the NF-T3SS, nine have clear homologs in the flagellum (SctJNQRSTUV/L), and two, SctP and SctF, have functional and structural counterparts [71]. SctP proteins play a central role, thought to be analogous to that of the flagellar protein FliK [26], and they are interchangeable between Shigella and Salmonella SPI1 systems [47]. Unfortunately, they display very weak sequence similarity between closely related bacteria [47], which precludes an evolutionary analysis by sequence similarity or phylogenetic methods. Similar problems arise when analyzing the chaperones of NF-T3SS, which are essential for needle complex formation and secretion, but are too diverse between NF-T3SSs of different families to allow comprehensive evolutionary studies. It is noteworthy that the flagellum outer membrane ring (L-ring) is formed with a lipoprotein unrelated to the secretin (FlgH) [72]. The trees of concatenated sequences of the flagellar components are approximately congruent with a tree of concatenated universal protein sequences [73], suggesting relatively few cases of horizon- Origins and Diversification of T3SS tal transfer [74]. On the other hand, the NF-T3SS has been extensively transferred among Proteobacteria [65,75–77], albeit not among Chlamydiales [78]. When their genes were horizontally transferred, the imports seem to have included the entire set of genes in a single event for both flagellum and NF-T3SS [3,79,80]. A decade ago, several studies indicated one single phylogenetic split between the flagellum and the NF-T3SS [75,79,81,82]. This is compatible with three different evolutionary scenarios. The two elements might have independent origins from an ancestral system, or one system might have adapted pre-existing structures from the other system for a new function [61], a process referred to as ‘‘exaptation’’ [83]. Understanding the details of the exaptation process requires an understanding of the direction of the evolutionary events. Current sequence databanks cover a much larger fraction of the prokaryotic world than ten years ago. Phylogenetic methods for dealing with multi-protein complexes have also been improved [84,85], but these newer approaches have not yet been applied to infer the evolutionary history of T3SSs. The ongoing explosion of partially assembled genomes and metagenomes would also benefit from new tools for the detection and analysis of T3SSs from partial data. We have therefore produced such tools and applied them to genome data in order to determine the evolutionary origins and patterns of diversification of T3SSs. Results Detection of T3SS components and discrimination from flagellar components We retrieved sequences corresponding to a diverse set of known flagella and NF-T3SSs from genome databanks. We focused initially on 12 gene families (Table S1), eight with homologs among flagella and NF-T3SSs (the T3SS core genes: sctJNQRSTUV), one family specific to NF-T3SSs (the secretin sctC) and three specific to flagella (genes encoding rod components: flgB, flgC and fliE). We searched for homologs of these genes, made multiple alignments, manually corrected them and built protein profiles (Materials and Methods). We queried the proteins encoded in 1385 genomes containing 2575 replicons (1483 chromosomes and 1092 plasmids) with these profiles using Hmmer 3 [86]. Replicons either had hits to the majority of the protein profiles (Figure 1B), or to only few of them. In the latter case, the profiles retrieved homologs of the secretin and of the ATPase in other cell machineries. We filtered these hits, retaining hits that were statistically significant. We then selected hits from replicons containing a minimal number of the 12 gene families (different criteria to infer NF-T3SSs or flagella, Materials and Methods), and those hits had to co-localize in units of two different core genes or more (Materials and Methods). Subsequent expert analysis, informed by the available literature, resulted in a dataset of 921 putative T3SSs: 222 NF-T3SSs and 699 flagella distributed among 155 and 642 genomes, respectively. In the following sections, we summarize 216 NF-T3SSs, after excluding six on the basis of phylogenetic analyses (Table S2). We also analyzed a subset of 357 flagellar T3SSs that were representative of the diversity in the entire dataset and which had been manually curated (Materials and Methods, Table S3, Dataset S2). The vast majority (92%) of NF-T3SSs were encoded in chromosomes. NF-T3SSs were only identified in bacteria with outer and cytoplasmic membrane (diderms): Chlamydiae, Proteobacteria, and Verrucomicrobia. Flagella were found in many more taxa, within diderms (Acidobacteria, Aquificae, Bacteroidetes, Chloroflexi, Deferribac- teres, Gemmatimonadetes, Nitrospirae, Planctomycetes, Proteo- bacteria, Spirochetes, Thermotogae and Verrucomicrobia), and PLOS Genetics | www.plosgenetics.org 3 September 2012 | Volume 8 | Issue 9 | e1002983