Skip to content

Examples

Chloë Cornelissen edited this page Nov 17, 2026 · 2 revisions

CAT

Run CAT on a contig set with default parameter settings deploying 16 cores for DIAMOND alignment. Name the contig classification output with official names, and create a summary:

Run cat with:

CAT_pack cat -c contigs.fasta -d db/ -n 16 --output_prefix first_CAT_run

Add the official names with:

CAT_pack add_names -i first_CAT_run.contig2classification.txt -o first_CAT_run.contig2classification.official_names.txt -d db/ --only_official

Create the summary with:

CAT_pack summarise -c contigs.fasta -i first_CAT_run.contig2classification.official_names.txt -o CAT_first_run.summary.txt

BAT

Run BAT on the set of MAGs that was binned from these contigs, reusing the protein predictions and DIAMOND alignment file generated previously during the contig classification:

CAT_pack bat -b bins/ -d db/ -p first_CAT_run.predicted_proteins.faa -a first_CAT_run.alignment.diamond -o first_BAT_run

Example run customization

CAT

Run the contig classification algorithm again with custom parameter settings.:

CAT_pack cat --range 5 --fraction 0.1 -c contigs.fasta -d db/ -p first_CAT_run.predicted_proteins.faa -a first_CAT_run.alignment.diamond -o second_CAT_run

and name the output with all names in the lineage, excluding the scores:

CAT_pack add_names -i second_CAT_run.contig2classification.txt -o second_CAT_run.contig2classification.names.txt -d db/ --exclude_scores

BAT

Run BAT on the set of MAGs with custom parameter settings, suppressing terminal verbosity.

CAT_pack bat -r 3 -f 0.1 -b bins/ -s .fa -d db/ -p first_CAT_run.predicted_proteins.faa -a first_CAT_run.alignment.diamond -o second_BAT_run --quiet

Next, add names to the ORF2LCA output file:

CAT_pack add_names -i second_BAT_run.ORF2LCA.txt -o second_BAT_run.ORF2LCA.names.txt -d db/

Identifying contamination/mis-binned contigs within a MAG

We often use the combination of CAT / BAT to explore possible contamination within a MAG.

CAT_pack cat -c ../bins/interesting_MAG.fasta -d db/ -o CAT.interesting_MAG
CAT_pack bat -b ../bins/interesting_MAG.fasta -d db/ -p CAT.interesting_MAG.predicted_proteins.faa -a CAT.interesting_MAG.alignment.diamond -o BAT.interesting_MAG

Contigs that have a different taxonomic signal than the MAG classification are probably contamination.

Alternatively, you can look at contamination from the MAG perspective, by setting the f parameter to a low value:

CAT_pack bat -f 0.01 -b ../bins/interesting_MAG.fasta -d db/ -o BAT.interesting_MAG.low_f

Then add the official names with:

CAT_pack add_names -i BAT.interesting_MAG.low_f.bin2classification.txt -o BAT.interesting_MAG.low_f.bin2classification.names.txt -d db/

BAT will output any taxonomic signal with at least 1% support. Low scoring diverging signals are clear signs of contamination!

Estimating the microbial composition with RAT

RAT estimates the taxonomic composition of metagenomes by integrating taxonomic signals from MAGs, contigs, and reads.

To run RAT's complete workflow, specify the mode, read files, contig files, bin folder, and database files:

$ CAT_pack rat --mode mcr -b bin_folder/ -c contigs.fasta -r forward_reads.fq.gz -r reverse_reads.fq.gz -d db/

Currently, RAT supports single read files as well as paired-end read files. Interlaced read files are currently not supported. RAT will run CAT and BAT on the contigs and MAGs, will map the reads back to the contigs, and then try to annotate any unmapped reads separately.

If you already have a sorted mapping file, you can supply it and RAT will skip the mapping step:

$ CAT_pack rat --mode mcr -b bin_folder/ -c contigs.fasta --bam_file mapping_file_sorted.bam -r forward_reads.fq.gz -r reverse_reads.fq.gz -d db/

If CAT and/or BAT have already been run on your data, you can supply the output files to RAT to skip the CAT and BAT runs:

$ CAT_pack rat --mode mcr -b bin_folder/ -c contigs.fasta -r forward_reads.fq.gz -r reverse_reads.fq.gz -d db/ --c2c CAT_contig2classification_file.txt --b2c BAT_bin2classification_file.txt

RAT requires one classification per sequence in tables supplied with --c2c, --b2c, or --u2c. If a lower fraction produces multiple assignments for the same sequence, RAT reports an error; regenerate those classifications with --fraction 0.5 to obtain a single assignment.

Similarly, if a previous RAT run crashed after the unmapped reads have already been aligned to the database with DIAMOND or MMseqs2, you can supply the intermediate files to continue the run:

$ CAT_pack rat --mode mcr -b bin_folder/ -c contigs.fasta -r forward_reads.fq.gz -r reverse_reads.fq.gz -d db/ --c2c CAT_contig2classification_file.txt --b2c BAT_bin2classification_file.txt --alignment_unmapped unmapped_alignment_file.diamond

After a RAT run is finished, you can run add_names on the abundance files (only for RAT runs with nr database):

$ CAT_pack add_names -i out.RAT.RAT.complete.abundance.txt -o out.RAT.RAT.complete.abundance.names.txt -d db/

Similar to CAT and BAT, the paths to all dependencies can be supplied via an argument:

$ CAT_pack rat --mode mcr -b bin_folder/ -c contigs.fasta --read_file forward_reads.fq.gz --read_file reverse_reads.fq.gz -d db/ --path_to_samtools /path/to/samtools

Clone this wiki locally