It is commonplace in virome analyses to cluster similar sequences together at the approximate level of species. These clustered sequences are referred to as viral operational taxonomic units (vOTUs).
The MIUViG recommended parameters define two sequences as the same vOTU when they share at least 95% ANI (average nucleotide identity) over at least 85% of the shorter sequence (alignment fraction). From each cluster we keep one representative: the longest sequence.
We will do this with votuderep, a small tool that runs the whole procedure (BLAST, ANI calculation and clustering) with a single command. If you want to see each step separately, the manual procedure is described at the end of this page.
We will use the checkv environment we created in the previous section, which contains checkv and votuderep. votuderep is available from BioConda in case you wish to install it.
conda activate checkv
votuderep --version
More about the tool (downloading the training data, the databases, and filtering by CheckV quality) in the votuderep page.
We could dereplicate the geNomad output (genomad_votus.fna), but we have just run CheckV, and its output is a better starting point.
CheckV splits the viral sequences in two files:
| File | Content |
|---|---|
~/checkv-out/viruses.fna |
sequences that are not proviruses, unchanged |
~/checkv-out/proviruses.fna |
proviruses, with the host regions trimmed away |
How many sequences are in each file? And do the sequence names look the same?
There are 1,740 sequences in viruses.fna and 38 in proviruses.fna: together they are the 1,778 sequences predicted by geNomad.
The trimmed proviruses have a suffix and the coordinates of the retained region, for example
>c_000000000003_1 2211-4683/4683 (the viral region is the bases 2,211 to 4,683 of a 4,683 bp contig).
In the original contig, almost half of the sequence was host DNA (CheckV reported 47% contamination).
Dereplicating the trimmed proviruses means that the host DNA does not end up in our vOTU set (or, worse, make unrelated sequences look similar because they share a bit of host genome). We just need to put the two files together:
cat ~/checkv-out/proviruses.fna ~/checkv-out/viruses.fna \
> ~/checkv-out/combined_viruses.fna
The sequence names are all different, so there is nothing else to fix. Let’s see what we have:
seqfu stats -nbt ~/checkv-out/combined_viruses.fna
mkdir -p ~/derep
votuderep derep -i ~/checkv-out/combined_viruses.fna \
-o ~/derep/derep_votus.fasta -t 8
The parameters are:
-i FASTA: the input sequences,-o FASTA: the output file with the dereplicated vOTUs,-t INT: the number of threads used by BLAST.--keep to keep intermediate files (useful for tutorial)It takes only a few seconds with our data. If you see Success! and the number of sequences written, it worked.
You can check all the options with votuderep derep --help. The defaults are the MIUViG parameters that we described above (--min-ani 95 and --min-tcov 85).
How many sequences did we have, and how many vOTUs do we have now? Compare the two files with seqfu stats.
seqfu stats -nbt ~/checkv-out/combined_viruses.fna ~/derep/derep_votus.fasta
| File | #Seq | Total bp | Avg | N50 | N75 | N90 | Min | Max |
|---|---|---|---|---|---|---|---|---|
| combined_viruses | 1,778 | 18,225,658 | 10,250.65 | 29,750 | 7,635 | 3,503 | 940 | 313,021 |
| derep_votus | 1,765 | 18,192,769 | 10,307.52 | 29,750 | 7,755 | 3,517 | 940 | 313,021 |
We started with 1,778 sequences and ended with 1,765 vOTUs: only 13 sequences were redundant. The longest sequence is still there (313,021 bp), and the average length went up slightly, because when two sequences are merged the shorter one is the one removed.
Only 1% of the sequences were removed. Is that surprising? Not really: our sequences come from a single co-assembly of the three samples, where the assembler has already merged most of the similar sequences. You would expect to remove much more when merging the predictions from many separate assemblies.
The output is a FASTA file with the representative sequences only. If you also want to know which sequences were
merged into each vOTU you need the cluster table: use the manual procedure below, or run votuderep with --keep
to keep its temporary files (the BLAST table and the ANI table are in the directory printed on screen).
The two thresholds can be changed with --min-ani and --min-tcov:
votuderep derep -i ~/checkv-out/combined_viruses.fna -o ~/derep/ani90.fasta -t 8 --min-ani 90
Try different values and look at the number of sequences in the output. What happens when you ask for a very high identity,
like 99%? And when you require less alignment coverage?
| Parameters | vOTUs |
|---|---|
--min-ani 90 |
1,713 |
--min-ani 95 (default) |
1,765 |
--min-ani 99 |
1,778 |
--min-tcov 50 |
1,757 |
--min-tcov 95 |
1,766 |
The stricter the thresholds, the more vOTUs we keep (fewer sequences are considered "the same"). At 99% identity nothing is merged any more: all the 1,778 sequences are kept. If we relax the criteria (90% identity, or 50% coverage), more sequences are merged.
Do not use these relaxed or stricter values for the rest of the tutorial: we continue with the default
MIUViG parameters, so ~/derep/derep_votus.fasta is our final set of vOTUs.
Yes. votuderep follows the same logic as the CheckV scripts described in the next section
(all-vs-all megablast, ANI calculated from the local alignments, and greedy clustering starting from the longest sequence).
We checked it: running both on combined_viruses.fna produces exactly the same 1,765 representatives.
In this section we use a combination of BLAST and python scripts that are available alongside CheckV, which is what votuderep runs for you.
It is useful to understand what is going on under the hood, and it gives you the cluster table (which sequence went into which vOTU).
The examples below use genomad_votus.fna as the input, but you can use combined_viruses.fna as well.
To download these scripts you can run the following:
wget -O ~/bin/aniclust.py \
https://bitbucket.org/berkeleylab/checkv/raw/51a5293f75da04c5d9a938c9af9e2b879fa47bd8/scripts/aniclust.py
wget -O ~/bin/anicalc.py \
https://bitbucket.org/berkeleylab/checkv/raw/51a5293f75da04c5d9a938c9af9e2b879fa47bd8/scripts/anicalc.py
# Set them executable with "chmod +x aniclust.py", "chmod +x anicalc.py". And put the scripts in your path.
chmod +x ~/bin/*.py
This might look daunting, but let’s work through it one command at a time:
First, create a blast+ database to be able to align sequences against it:
# DO NOT COPY THIS COMMAND
makeblastdb -in ${my_seqs_fna} -dbtype nucl -out ${output}
# example : makeblastdb -in genomad-out/genomad_votus.fna -dbtype nucl -out genomad_votus.db
Next, use megablast from blast+ package to perform all-vs-all blastn of sequences (as the query and the target are both your vOTUs):
# DO NOT COPY THIS COMMAND
blastn -query ${my_seqs_fna} -db ${output} \
-outfmt '6 std qlen slen' -max_target_seqs 10000 \
-out ${out_tsv_file} -num_threads 8
# example : blastn -query genomad-out/genomad_votus.fna -db genomad_votus.db -outfmt '6 std qlen slen' -max_target_seqs 10000 -out genomad_blast.tsv -num_threads 8
Next, calculate pairwise ANI by combining local alignments between sequence pairs:
# DO NOT COPY THIS COMMAND
anicalc.py -i ${out_tsv_file} -o ${ani_tsv}
# example python scripts/anicalc.py -i genomad_blast.tsv -o genomad_ani.tsv
Finally, perform UCLUST-like clustering using the MIUVIG recommended-parameters (95% ANI + 85% AF):
# DO NOT COPY THIS COMMAND
aniclust.py --fna ${my_seqs_fna} --ani ${ani_tsv} \
--out ${clusters_tsv} \
--min_ani 95 --min_tcov 85 --min_qcov 0
# example : python scripts/aniclust.py --fna genomad-out/genomad_votus.fna --ani genomad_ani.tsv --out vOTU_genomad_c95.tsv --min_ani 95 --min_tcov 85 --min_qcov 0
Take a look at the my_clusters.tsv file, this contains two tab-delimitied columns (i.e. separated by tabs). The first is a representative sequence for each cluster, this is what we’re interested in. To get them, we’ll use an awk command to get the first column and write it to a new file called my_vOTUs.txt:
# DO NOT COPY THIS COMMAND
awk '{print $1}' ${clusters_tsv} > VOTUS_FINAL.tsv
example : awk '{print $1}' vOTU_genomad_c95.tsv > vOTU_genomad_representatives.tsv
We can then use a handy utility in seqfu called seqfu list, which is already installed! This will take a list of sequence IDs and extract the matching seqs from a fasta file:
# DO NOT COPY THIS COMMAND
seqfu list my_vOTUs.txt <genomad_viruses.fna> > <my_vOTUs.fa>
# seqfu list vOTU_genomad_representatives.tsv genomad-out/genomad_viruses.fna > vOTUs_representatives.fa