This page is a rough guide. The commands are not meant to be copied/pasted and will require some editing and missing parameters.

Importing the contigs

Anvi’o is picky when it comes to contig names. Most assembly tools will generate contig names that are not compatible with Anvi’o. Therefore, we will use the anvi-script-reformat-fasta script to rename the contigs.

# reformat the fasta file keeping a tabular file with the old and new names
anvi-script-reformat-fasta contigs.fasta -o contigs-renamed.fa -r report.txt --simplify-names -T 4

We can then run anvi-gen-contigs-database to create the contigs database.

# Creating a contigs database
anvi-gen-contigs-database -f votus.fna -o CONTIGS.db -T 4

The contigs database is a binary file that contains all the information about the contigs. It is the main file that Anvi’o uses to store information about the contigs. We can now run some anvi’o programs (like anvi-run-hmms) to add annotations to our contigs:

# These commands require the download of databases
anvi-run-hmms -c CONTIGS.db -T 4
anvi-run-scg-taxonomy -c CONTIGS.db -T 4
anvi-run-ncbi-cogs -c CONTIGS.db -T 4
anvi-scan-trnas -c CONTIGS.db

:bulb: Check the anvio output and warnings.

Importing the BAM files

:warning: If you created the BAM files before renaming the contigs

In the second step, you will create the anvio profiles from the read mapping files. We have provided subsampled files to limit download and computational time.

Only if you created the BAM files before renaming the contigs, you will need to re-create them or to use anvi-script-reformat-bam to rename the contigs in the BAM files.

Note that it will use the report.txt file from the previous step.

export PATH=$PATH:/shared/team/bin/

for BAM in *.bam;
do
    echo "Processing $BAM"
    anvi-script-reformat-bam -l report.txt -o "fix_$i" "$i";
    echo "Done ($BAM)"
done

Importing the BAM files as “coverage profiles”

After reformatting the BAM files, you can create their coverage profiles specifying the contigs database (-c) and the number of threads (-T).

:question: Can you make a loop here too?

:bulb: The (new) bam files must be indexed first!

# CHANGE FILENAMES, PATHS AND THREADS AS APPROPRIATE FOR YOUR OWN COMPUTER
anvi-profile -i sub_sample_01.bam -c CONTIGS.db -T 4 -o profile_1
anvi-profile -i sub_sample_02.bam -c CONTIGS.db -T 4 -o profile_2
anvi-profile -i sub_sample_03.bam -c CONTIGS.db -T 4 -o profile_3

Finally, merge profiles to generate the profile database.

anvi-merge profile_*/PROFILE.db -o SAMPLES-MERGED -c CONTIGS.db   

Run the interactive interface

:checkered_flag: You can now visualize the results with anvi-interactive!

anvi-interactive -p SAMPLES-MERGED/PROFILE.db -c CONTIGS.db

Previous submodule: