## Abstract

Metagenomic datasets contain billions of protein sequences that could greatly enhance large-scale functional annotation and structure prediction. Utilizing this enormous resource would require reducing its redundancy by similarity clustering. However, clustering hundreds of million of sequences is impractical using current algorithms because their runtimes scale as the input set size *N* times the number of clusters *K*, which is typically of similar order as N, resulting in runtimes that increase almost quadratically with *N*. We developed Linclust, the first clustering algorithm whose runtime scales as *N*, independent of *K*. It can also cluster datasets several times larger than the available main memory. We cluster 1.6 billion metagenomic sequence fragments in 14 hours on a single server to 50% sequence identity, > 1000 times faster than has been possible before. Linclust will help to unlock the great wealth contained in metagenomic and genomic sequence databases. (Open-source software and metaclust database: `https://mmseqs.org/`).

In metagenomics DNA is sequenced directly from the environment, allowing us to study the vast majority of microbes that cannot be cultivated *in-vitro* [26]. During the last decade, costs and throughput of next-generation sequencing have dropped two-fold each year, twice faster than computational costs. This enormous progress has resulted in hundreds of thousands of metagenomes and tens of billions of putative gene and protein sequences [19, 32]. Therefore, computing and storage costs are now dominating metagenomics [6, 25, 27]. Clustering protein sequences predicted from sequencing reads or pre-assembled contigs can considerably reduce the redundancy of sequence sets and costs of downstream analysis and storage.

CD-HIT and UCLUST [7, 9] are by far the most widely used tools for clustering and redundancy filtering of protein sequence sets (see [18]). Their goal is to find a representative set of sequences such that each of the input set sequences is well enough represented by one of the *K* representatives, where “well enough” is quantified by some similarity criteria.

As most other fast sequence clustering tools, they use a fast prefilter to reduce the number of slow pairwise sequence alignments. An alignment is only computed if two sequences share a minimum number of identical *k*-mers. If we denote the average probability by *p*_{FP} that this happens by chance between two non-homologous input sequences, then the prefilter would speed up the sequence comparison by a factor of up to 1/*p*_{FP} at the expense of some loss in sensitivity. This is usually unproblematic: If sequence matches are missed (false negatives) we create too many clusters, but we do not loose information. In contrast, false positives are costly as they can cause the loss of unique sequences from the representative set.

CD-HIT and UCLUST employ the following *greedy in cremental clustering* approach: Each of the *N* input sequences is compared with the representative sequences of already established clusters. When the sequence is similar enough to the representative sequence of one of the clusters, that is, the similarity criteria such as sequence identity are satisfied, the sequence is added to that cluster. Otherwise, the sequence becomes the representative of a new cluster. Due to the comparison of all sequences with the cluster representatives, the runtimes of CD-HIT and UCLUST scale as O(NK), where *K* is the final number of clusters. In protein sequence clustering *K* is typically of similar size as *N* (see for example Fig. 2c) and therefore the total runtime scales almost quadratically with *N*. The fast sequence prefilters speed up each pairwise comparison by a large factor 1/*p*_{FP} but cannot improve the time complexity of *O*(*NK*). This almost quadratic scaling results in impractical runtimes for a billion or more sequences.

Here we present the sequence clustering algorithm Linclust, whose runtime scales as *O(N*), independent of the number of clusters found. We demonstrate that it produces clusterings of comparable quality as other tools that are orders of magnitude slower and that it can cluster over a billion sequences within hours on a single server.

## RESULTS

### Overview of Linclust

The Linclust algorithm is explained in Figure 1 (for details see Methods). A critical insight to achieve linear time complexity is that we need not align every sequence with every other sequence sharing a *k*-mer. We reach similar sensitivities by selecting only a very small subset of sequences as *centre sequences* and only aligning sequences to the centre sequences with which they share a *k*-mer. Linclust thus requires less than *mN* sequence comparisons with a small constant *m* (e.g. 20), instead of the ~*NK* comparisons needed by UCLUST, cD-HIT and other tools.

In most clustering tools, the main memory size severely limits the size of the datasets that can be clustered. UCLUST, for example, needs bytes *per residue* of the representative sequences. Linclust needs *m* × 16 bytes *per sequence*, but before running it automatically checks available main memory and if necessary splits the table of *mN* lines into chunks such that each chunk fits into memory (Supplemental Fig. S1 and Methods). It then processes the chunks sequentially. In this way, Linclust can cluster sequence sets that would occupy many times its main memory size at almost no loss in speed.

### Linclust and MMseqs2/Linclust workflows

We integrated Linclust into our MMseqs2 (Many-versus-Many sequence searching) software package [29], and we test two versions of Linclust in our benchmark comparison: the bare Linclust algorithm described in Figure 1 (simply named “Linclust”), and a combined four-step cascaded clustering workflow (“MMseqs2/Linclust”). In this workflow. a Linclust clustering step is followed by one (above 60% sequence identity) or three (≤ 60%) clustering steps, each of which clusters the representative sequences from the previous step by performing an increasingly sensitive all-against-all MMseqs2 sequence search followed by the greedy incremental clustering algorithm. For comparison, we also include in our benchmark the results of our original MMseqs clustering tool [13].

### Runtime and clustering sensitivity benchmark

We measure clustering runtimes on seven sets: the 61522 444 sequences of the UniProt database, randomly sampled subsets with relative sizes 1/16, 1/8, 1/4, 1/2, and UniProt plus all reversed sequences (123 million sequences). Each tool clustered these sets using a minimum pairwise sequence identity of 90%, 70% and 50%. Sequence identity was defined similarly for all three tools. The three tools use somewhat different strategies to try to ensure that only proteins with the same domain architecture are clustered together (see Methods: Clustering criteria).

At 50% identity, Linclust clusters the 123 million sequences 8.7 times faster than MMseqs2/Linclust and, by extrapolation, 2000 times faster than UCLUST, 610 times faster than MMseqs, 4000 times faster than CD-HIT, 1200 times faster than DIAMOND [4], 59 000 times faster than MASH [23], and 000 times faster than RAPsearch2 [34] (Fig. 2a,b). At 90% identity, Linclust still clusters these sequences 570 times faster than MMseqs, 100 times faster than UCLUST, 62 times faster than CD-HIT, and 4.5 times faster than MMseqs2/Linclust.

At 90 % sequence identity threshold, we determined how the runtimres scale with the input set size *N* by fitting a power law (*T* ~ *aN ^{b}*) to the measured runtimes. Runtimes scale very roughly quadratically for UCLUST (

*N*

^{1.62}) and CD-HIT (

*N*

^{2.75}) whereas they grow only linearly for MM-seqs2/Linclust (N

^{0}·

^{94}) and Linclust (

*N*

^{1.01}). The speed-ups due to Linclust’s Hamming distance stage and the ungapped alignment filter are analyzed in Supplemental Figure S2.

To assess the clustering sensitivity, we compare the average size of clusters: a deeper clustering with more sequences per cluster implies a higher sensitivity to detect similar sequences. All three tools produce similar numbers of clusters at 90% and 70% sequence identity (Fig. 2c). Importantly, despite Linclust’s linear scaling of the runtime with input set size, it manifests no loss of sensitivity for growing dataset sizes. At 50%, Linclust produces 13% more clusters than UCLUST. But we can increase Linclust’s sensitivity simply by selecting more *k*-mers per sequence. By increasing *m* from to Linclust takes only 1.5 to 2 times longer but attains nearly the same sensitivity as UCLUST (pink traces in Fig. 2a–c, Supplemental Fig. S4).

### Cluster consistency analysis

We measure the quality of the clusterings produced by the tools by analyzing the homogeneity of the functional annotation of the sequences in the clusters [22]. We assess Gene Ontology (GO) annotations [10] (Fig. 3a,b) and Pfam domain annotations [8] (Fig. 3c) provided by the UniProt database. For each of these annotations, we averaged two score variants over all clusters, “mean” and a “worst”. The “mean” (“worst”) score for a cluster is the mean (minimum) annotation similarity score between the representative sequence and all other cluster members, as described in [22].

Overall, the consistencies of cluster annotations are similar for all tools, which is not suprising since they all use exact Smith-Waterman alignments and similar acceptance criteria (**Supplemental Fig. S3**, Methods). However, MMseqs2/Linclust and Linclust clusterings have better consistencies than UCLUST and CD-HIT according to purely experimentally derived GO annotations (Fig. 3a) and according to Pfam domain annotations (Fig. 3c). This might be either due to a stricter minimum coverage criterion in Linclust or due to its slightly different definition of sequence similarity, which translates the sequence identity threshold into an approximately equivalent threshold of the similarity score of the local alignment divided by the maximum length of the two aligned segments (Methods: Clustering criteria). This sequence similarity measure is more appropriate than sequence identity to cluster sequences with conserved functions together, as it also accounts for gaps and for the degree of similarity between aligned residues. The cluster consistencies of all tools are similar when GO annotations based on computational predictions are included (Fig. 3b).

### Clustering 1.6 billion metagenomic sequences

As an illustration of Linclust’s power and flexibility, we applied it to cluster 1.59 billion protein sequence fragments predicted by Prodigal [15] in 2200 metagenomic and meta-transcriptomic datasets [16, 19, 30] downloaded mainly from the Joint Genome Institute. We clustered these sequences with a minimum sequence identity of ≥ 50% and minimum coverage of the shorter sequence of 90% (Methods: Clustering criteria), producing 504 million clusters in 14 hours on a 2 × 14-core server.

Our Metaclust database of 504 million representative sequenceds will improve the sensitivity of profile sequence searches by increasing the diversity of the underlying multiple sequence alignments. It will thereby raise the fraction of annotatable sequences in genomic and metagenomic datasets [25, 30]. It could also increase the number protein families for which reliable structures can be predicted de novo, as shown by Ovchinnikov et al. [24], who used an unpublished dataset of 2 billion metagenomic sequences. Metaclust should also allow us to predict more accurately the effects of mutations on proteins [14].

## DISCUSSION

Clustering a set of *N* items is challenging when both *N* and the number of clusters *K* are large, due to the time complexity of existing clustering algorithms. Hierarchical agglomerative clustering approaches have a time complexity of *O*(*N*^{2} log *N*) [5], others with a predefined number of clusters such as *K*-means or expectation maximization clustering have complexity *O*(*NK*). When both *N* and *K* are in the tens of millions, traditional approaches are impracticably slow. Driven by the need to cluster huge datasets it the era of big data, most work has focused on reducing the proportionality constant.

One example is the widely used canopy clustering algorithm [21]. The items are first preclustered into overlapping sets (*canopies*) based on a fast approximate similarity measure. Canopies could be biological sequences sharing the same *k*-mer or documents sharing a keyword. Some traditional clustering algorithm is run on all items, but with the restriction that slow, exact similarities are only computed between items belonging to the same canopy. Similar to the *k*-mer prefilter used in CD-HIT, UCLUST, kclust and MMseqs [7, 12, 13, 17], the preclustering reduces the number of comparisons by a large factor *F* using the slow, exact measure, but the time complexity of the exact distance calculation *O*(*N*^{2}/*F*) is still quadratic in *N*. Linear-time clustering algorithms, using for instance hashing techniques, have been proposed [20, 31]. But like the preclustering step in canopy clustering or Linclust’s prefilter to find *k*-mer matches, these algorithms are only approximate. If falsely clustered pairs are costly (e.g. for redundancy filtering) pairwise links need to be verified with the exact similarity measure, which still requires quadratic time complexity.

In contrast, Linclust’s linear time complexity of *O*(*mN*) includes verification of all edges between items using the exact distance measure. And it can be trivially generalized to cluster any items for which a set of *m* keys per item can be defined such that (1) items belonging to a cluster are likely to share at least one of their keys and (2) items not belonging to a cluster are unlikely to share a key. For clustering documents the keys could be all subsets of the *n* keywords of size *k*, for example [20]. To achieve a high sensitivity, the centre of the group of items sharing a key could be selected to be that member whose sum of sizes of groups it belongs to is largest. In this way, the centre items are able to pull together into single clusters many items from different groups.

We perform the clustering in step 5 of Figure 1 with the greedy incremental clustering, because it always chooses the longest sequence as the cluster representative. This ensures that the representative sequences, being the longest sequence in each cluster, are likely to contain all protein domains of all cluster members. Our rule in step 2 to choose the longest protein sequence per *k*-mer group as its centre is well-suited to achieve large clusters, because the longest sequences tend to be selected as centres of most of the *k*-mer groups they belong to, and these long sequences therefore have edges to most sequences they share *k*-mers with.

As far as we know, Linclust is the only algorithm that could run on datasets of billions of items resulting in billions of clusters, overcoming the time and memory bot tlenecks of existing clustering algorithms. Linclust could therefore be useful for many other applications. We are currently working on extending Linclust to nucleotide sequences [3, 11] and to clustering D-dimensional vectors. The latter method could be used, for instance, for metagenomic binning to cluster contigs by their coverage profiles across *D* metagenomic samples [1].

In summary, we hope the Linclust algorithm will prove helpful for exploiting the tremendous value in publicly available metagenomic and metatranscriptomic datasets. Linclust should lead to considerable savings in computing resources in current applications. Most importantly, it will enable previously infeasible large-scale analyses.

## METHODS

The Linclust algorithm consists of the following steps (Figure 1):

**1. Generating the table of**. We transform the sequence set into a reduced alphabet of 13 letters to increase the number of*k*-mers*k*-mer matches and hence the*k*-mer sensitivity at a moderate reduction in selectivity (see subsection Reduced amino acid alphabet). We set by default*k*=10 for clustering thresholds below 90% sequence identity and*k*= 14 otherwise. For each sequence, we extract*m k*-mers, as described in “Selection of*k*-mers”. Increasing*m*from its default value of 20 (option) increases the sensitivity at the cost of a moderately decreasing speed (Supplemental Fig. S4). We store each extracted`-kmer-per-seq`*k*-mer index (8 bytes), the sequence identifier (4 bytes), its length (2 bytes), and its position*j*in the sequence (2 bytes) in a table with*mN*lines. Therefore, Linclust has a memory footprint of*mN*× 16 bytes.**2. Finding exact**. We sort this table by the*k*-mer matches*k*-mer index using the in-place sort from the OpenMP template library (http://freecode.com/projects/omptl). The sorting has a quasi-linear time complexity of*O*(*mN*log(*mN*)) and typically takes less than 10% of the total runtime. The sorting groups sequences together into blocks of lines that contain the same*k*-mer. For each such*k*-mer group we select the longest sequence as its centre sequence. We overwrite the position*j*with the diagonal*i*–*j*of the*k*-mer match with the centre sequence, where*i*is the position of the group’s*k*-mer in the centre sequence. We further overwrite the*k*-mer index by the centre sequence identifier and resort the*mN*lines of the table by the centre sequence identifier. The*k*-mer match stage results file has one entry for each centre sequence identifier containing the list of identifiers of sequences that share a*k*-mer with the centre sequence. If a sequence shares multiple*k*-mer matches with a centre sequence, we keep only the entry with the lowest diagonal*i*–*j*.**3a. Hamming distance pre-clustering**. For each*k*-mer group we compute the Hamming distance (the number of mismatches) in the full amino acid alphabet between the centre sequence and each sequence in the group along the stored diagonals*i*–*j*. This operation is fast as it needs no random memory or cache access and uses AVX2/SSE4.1 vector instructions. Members that already satisfy the specified sequence identity and coverage thresholds on the entire diagonal are removed from the results passed to step 3b and are added to the cluster of their centre sequence after step 5.**3b. Ungapped alignment filtering**. For each*k*-mer group we compute the optimal ungapped, local alignment between the centre sequence and each sequence in the group along the stored diagonals*i*–*j*, using one-dimensional dynamic programming with the Blosum62 matrix. We filter out matches between centre and member sequences if the ungapped alignment score divided by the length of the diagonal is very low. We set a conservative threshold, such that the false negative rate is 1 %, i.e., only 1 % of the alignments below this threshold would satisfy the two criteria, sequence identity and coverage. For each combination on a grid {50, 55, 60,…, 100} ⊗ {0,10, 20,…, 100}, we determined these thresholds empirically on 4 million local alignments sampled from an all-against-all comparison of the UniProt database [2].**4. Local gapped sequence alignment**. Sequences that pass the ungapped alignment filter are aligned to their centre sequence using the AVX2/SSE4.1-vectorized alignment module with amino acid compositional bias correction from MMseqs2 [29], which builds on code from the SSW library [33]. Sequences satisfying the specified sequence identity and coverage thresholds are linked by an edge. These edges (neighbor relationships) are written in the format used by MMseqs2 for clustering results.**5. Greedy incremental clustering**. This algorithm was already implemented for MMseqs [13]. Briefly, the file with the validated directed edges from centre sequences to member sequences is read in and all reverse edges are added. The list of input sequences is sorted by decreasing length. While the list is not empty yet, the top sequence is removed from the list, together with all sequences still in the list that share an edge with it. These sequences form a new cluster with the top sequence as its representative.

### Reduced amino acid alphabet

We iteratively constructed reduced alphabets starting from the full amino acid alphabet. At each step, we merged the two letters {*a, b*} → *a*′ = (*a* or *b*) that conserve the maximum mutual information, . Here *A* is the new alphabet size, *p*(*x*) is the probability of observing letter *x* at any given position, and *p*(*x,y*) is the probabilities of observing *x* and *y* aligned to each other. These probabilities are extracted from the Blosum62 matrix. When *a* and *b* are merged into *a*′, for example, *p*(*a*′) = *p*(*a*) + *p*(*b*) and *p*(*a*′,*y*) = *p*(*a,y*) + *p*(*b,y*). The default alphabet with *A* = 13 merges (L,M), (I,V), (k,R), (E, Q), (A,S,T), (N, D) and (F,Y).

### Selection of *k*-mers

To be able to cluster two sequences together we need to find a *k*-mer in the reduced alphabet that occurs in both. Because we extract only a small fraction of *k*-mers from each sequence, we need to avoid picking different *k*-mers in each sequence. Our first criterion for *k*-mer selection is therefore to extract *k*-mers such that the same *k*-mers tend to be extracted from homologous sequences. Second, we need to avoid positional clustering of selected *k*-mers in order to be sensitive to detect local homologies in every region of a sequence. Third, we would like to extract *k*-mers that tend to be conserved between homologous sequences. Note that we cannot simply stored a subset of *A ^{k} m/L k*-mers to be selected due to its sheer size.

We can satisfy the first two criteria by computing hash values for all *k*-mers in a sequence and selecting the *m k*-mers that obtain the lowest hash values. Since appropriate hash functions can produce values that are not correlated in any simple way with their argument, this method should randomly select *k*-mers from the sequences such that the same *k*-mers always tend to get selected in all sequences. We developed a simple 16-bit rolling hash function with good mixing properties, which we can compute very efficiently using the hash value of the previous *k*-mer (Supplemental Fig. S5).

In view of the third criterion, we experimented with combining the hash value with a *k*-mer conservation score . This score ranks *k*-mers *x*_{1:k} by the conservation of their amino acids, according to the diagonal elements of the Blosum62 substitution matrix *S*(·, ·). We scaled the hash function with a rectified version of the conservation score: hash-value(*x*_{1:k})/max {1, *S*_{cons}(*x*_{1:k}) – *S*_{offset}}. Despite its intuitive appeal, we did not succeed in obtaining significant improvements and reverted to the simple hash function.

### Clustering datasets that don’t fit into main memory

Linclust needs *m* × 16 bytes of memory per sequence. If the computer’s main memory is too small, Linclust automatically splits the *k*-mer array into *C* equal-sized chunks small enough to fit each into main memory (Supplemental Fig. S1). For each chunk index *c* ∈ {0,…,*C* – 1} we run Linclust steps 1 and 2 (Figure 1) normally but extract only *k*-mers whose numerical index modulo *C* yields a rest *c*. This way each of the *C* runs builds up a *k*-mer table with only about *mN/C* lines instead of *mN*, and hence each run needs *C* times less memory. Each run writes out a file with all found *k*-mer groups, and afterwards all *C* files are merged into a single file such that *k*-mer groups are sorted by ascending centre IDs. Finally, Linclust steps 3 to 5 are performed as usual.

### Parallelization and supported platforms

We used OpenMP to parallelize all stages except the fast step 5 and SIMD instructions to parallelize step 3 and step 4. Linclust supports Linux and Windows, Mac OS X and CPUs with AVX2 or SSE4.1 instructions.

### Clustering criteria

MMseqs2/Linclust and Linclust has three main criteria to link two sequences by an edge: (1) a maximum E-value threshold (option ** -e** [0,∞) computed according to the gap-corrected Karlin-Altschul statistics using the ALP library [28]; (2) a minimum coverage (option

**[0,1], which is defined by the number of aligned residue pairs divided by either the minimum of the length of query/centre and target/non-centre sequences (default mode,**

`-c`**), or by the length of the target/non-centre sequence (**

`--cov-mode 0`**), or by the length of the query/centre (**

`--cov-mode 1`**); (3) a minimum sequence identity (**

`--cov-mode 2`**) with option**

`--min-seq-id [0,1]`**defined as the number of identical aligned residues divided by the number of aligned columns including internal gap columns, or, by default, defined by a highly correlated measure, the equivalent similarity score of the local alignment (including gap penalties) divided by the maximum of the lengths of the two locally aligned sequence segments. The score per residue**

`--alignment-mode 3`*equivalent*to a certain sequence identity is obtained by a linear regression using thousands of local alignments as training set (Fig. S2 in [12]).

The sequence identity in UCLUST is defined as number of identical residues in the pairwise global alignment divided by the number of aligned columns including internal gaps. Due to the global alignment, no explicit coverage threshold is needed. CD-HIT defines sequence identity as the number of identical residues in the local alignment divided by the length of the shorter sequence. Therefore, sequence coverage of the shorter sequence must be at least as large as the sequence identity threshold.

### Tools and options for benchmark comparison

Linclust and MMseqs2/Linclust (commit 5e21868) used the commands ** mmseqs linclust --cov-mode 1 -c 0.9 --min-seq-id 0.9 and mmseqs cluster --cov-mode 1 -c 0.9 --min-seq-id 0.9** for 90%, respectively, and

**or**

`--min-seq-id 0.7`**for 70% and 50%. The minimum coverage of % of the shorter sequence was chosen to enforce global similarity, similar to UCLUST and CD-HIT. CD-HIT 4.6 was run with the parameters**

`--min-seq-id 0.5`**0 and**

`-T 16 -M`**, and**

`-n 5 -c 0.9, -n 4 -c 0.7`**for 90%, 70% and 50% respectively. UCLUST (7.0.1090) was run with**

`-n 3 -c 0.5`**, for RAPsearch2 (2.23) we used**

`--id 0.9, 0.7, 0.5`**, for DIAMOND (v0.8.36.98) option**

`-z 16`**, and for MASH (v2.0)**

`--id 0.5`**. Runtimes were measured with the Linux time command.**

`-s 20 -a -i -p 16`### Functional consistency benchmark

We evaluated the functional cluster consistency based on Gene Ontology (GO) annotations of the UniProt knowledge base. We carried out three tests: one based on (1) experimentally validated GO annotations, (2) general functional GO annotations (mostly inferred from homologous proteins) and Pfam annotations. The UniProt 2016_03 release was clustered by each tool at 90%, 70% and 50% sequence identity level and then evaluated. For CD-HIT we computed only the clustering at 90% sequence identity because of run time constraints. For each cluster, we computed the ‘worst’ and ‘mean’ cluster consistency scores, as described earlier [22]. These cluster consistency scores are defined respectively as the minimum and the mean of all pairwise annotation similarity scores between the cluster’s representative sequence and the other sequences in the cluster.

GO annotations are often annotating the whole sequence. We used the Pfam annotations of the UniProt to check local consistence of clusters (Fig. 3c). We compare the Pfam domain annotation of the representative sequence against all cluster members. If the member has the exact same domain annotation as the representative sequence we count it as correct (value=1) and otherwise as false (value=0).

### Clustering

We downloaded ~1800 metagenomic and ~400 metatranscriptomic datasets with assembled contigs from the Joint Genome institute’s IMG/M archive [19] and NCBI’s Sequence Read Archive [16] (`ftp://ftp.ncbi.nlm.nih.gov/sra/wgs_aux`) using the script metadownload.sh from `https://bitbucket.org/martin_steinegger/linclust-analysis`. We predicted genes and protein sequences using Prodigal [15] resulting in 1,595,926,152 proteins.

We clustered the 1.59 million sequence fragments with Linclust using the following acceptance criteria: (1) the min imum sequence identity is 50%, using the score-per-column similarity measure described in Clustering criteria, (2) the shorter of the two sequences has at least 90% of its residues aligned, and (3) the maximum E-value is 10^{−3} (default) (Linclust options: ** --min-seq-id 0.5 --cov-mode 1 -c 0.9 --cluster-mode 2**). The clustering step found 504 million cluster within 14 hours on a server with two 14-core Intel Xeon E5-2680 v4 CPUs (2.4 GHz) and 762 GB RAM.

Since many of the predicted metagenomic protein sequences are fragments, we first eliminated redundancy and fragments by running Linclust with the following acceptance criteria: (1) The shorter of the two sequences has at least 90% of its residues aligned and (2) the fraction of identical residues among the aligned ones is at least 50% (Linclust options ** --cov-mode 1 -c 0.9 --min-seq-id 0.5 --cluster-mode 2**). The clustering step reduced the number of sequences from 1.59 billion to 504 million within 14 hours on a server with two 14-core Intel Xeon E5-2680 v4 CPUs (2.4 GHz) and 762 GB RAM.

### Metaclust protein sequence sets

The Meta-clust database is available as FASTA formatted file at `https://metaclust.mmseqs.org/`.

### Code availability

Linclust has been integrated into our free GPLv3-licensed MMseqs2 software suite [29]. The source code and binaries for Linclust can be download at `https://github.com/soedinglab/mmseqs2`.

Data availability. All scripts and benchmark data including command-line parameters necessary to reproduce the benchmark and analysis results presented here are available at `https://bitbucket.org/martin_steinegger/linclust-analysis">`.

## AUTHOR CONTRIBUTIONS

MS performed the research and programming, MS and JS jointly designed the research and wrote the manuscript.

## COMPETING INTERESTS

The authors declare no competing financial interests.

## ACKNOWLEDGEMENTS

We are grateful to Cedric Notredame and Chaok Seok for hosting MS in their groups at the CRG in Barcelona and at Seoul National University for 12 and 24 months, respectively. Thanks to Milot Mirdita and Clovis Galiez for feedback to the manuscript. We thank all who contributed metagenomic datasets used to build Metaclust, in particular the US Department of Energy Joint Genome Institute `http://www.jgi.doe.gov/` and their user community. This work was supported by the EU’s Horizon 2020 Framework Programme (Virus-X, grant 685778).