Session 4: Run mOTUs2, MetaPhlan3, and kraken2

In this part of the course, we will use the taxonomic profilers in the IMP3 pipeline and also MetaPhlan3.

In this session, you can use the IMP3 installation on crunchomics, as well as a metaphlan3 conda environment to profile example data.

External readers

You can easily install MetaPhlan3 as described here.


If you haven’t set up your conda enviroment yet, do the set up as described in the first session now.


In this session, you can use the small files prepared on crunchomics:

cd /zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/READS

Or you can use the preprocessed files from the last sessions. You have them in your output, or you can use them from here:

cd /zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/FILTERED_READS

Running taxonomic profiling within IMP3

You could re-run all steps including the taxonomy on the test run. However, since you already have the preprocessed data, all you need to do is to start IMP3 with an appropriate configuration file. In this config file, you set that you don’t want to do preprocessing, but that you want to do taxonomic profiling, and, of course, you set the input to already preprocessed files. Here’s an example: There is a config file which you can copy to your ~/personal folder.

cd ~/personal
cp /zfs/omics/projects/metatools/SANDBOX/Metagenomics101/04_taxonomy1/tax.config.yaml

This config will work as is, but you could change the input to your own data. You can also change the kraken database to one of the names in /zfs/omics/projects/metatools/DB with the word kraken in it (UHGP_kraken2 for human gut genomes, minikraken2 for an even smaller database).

First, you should always perform a dry run to detect potential problems in your configuration file.

cd ~/personal
/zfs/omics/projects/metatools/TOOLS/IMP3/runIMP3 -d

If the dry-run was successful, you’re set to submit the test run to the compute nodes. Remember, you can commit you job to the cluster like so:

sinfo -o "%n %e %m %a %c %C"
/zfs/omics/projects/metatools/TOOLS/IMP3/runIMP3 -c -r -n TESTTAX -b omics-cn002

As always, you can check the status in the output folder and by checking the slurm queue for your user name.

squeue -u YourUserID

Once the run is done, you will have a directory Analysis/taxonomy in your new output directory, which holds the outputs from mOTUs2 and kraken2.

Taxonomic profiling using MetaPhlan3

MetaPhlan3 is another profiler that works very well, especially on human samples. It’s other advantage is that it has a strain-level module, which we will use in a later session.

For MetaPhlan3, we have a conda environment that you can acitvate like so:

conda activate /zfs/omics/projects/metatools/TOOLS/miniconda3/envs/metaphlan-3.0

To get the help, do:

metaphlan -h

You could run metaphlan on the filtered test reads like this:

metaphlan /zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/FILTERED_READS/mg.r1.trimmed.phiX174_filtered.fq,/zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/FILTERED_READS/mg.r2.trimmed.phiX174_filtered.fq,/zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/FILTERED_READS/ --bowtie2out filtered_test.bowtie2.bz2 --input_type fastq -o profile.filtered_test.txt  --bowtie2db /zfs/omics/projects/metatools/DB/metaphlan --unknown_estimation

You can, of course, also use your own filtered reads instead. If you want to run metaphlan on a real data set, put the commands to activate (and deactivate) conda and the metaphlan command into a script that you submit to the cluster. You can then also choose to set the --nproc argument, e.g. --nproc 8 to parallelize the profiling.

For the purpose of this practical, you could also run the non-filtered reads:

metaphlan /zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/READS/,/zfs/omics/projects/metatools/SANDBOX/Metagenomics101/EXAMPLE_DATA/READS/ --bowtie2out unfiltered_test.bowtie2.bz2 --input_type fastq -o profile.unfiltered_test.txt  --bowtie2db /zfs/omics/projects/metatools/DB/metaphlan --unknown_estimation

To merge the profiles from several samples (or in this case, the same sample, but represented by filtered or unfiltered reads), you can use metaphlan’s merge script: profile*filtered_test.txt > merged_abundance.test.tsv

You can compare the results:

less merged_abundance.test.tsv
conda deactivate

End of today’s lesson. Have a nice day :-)