Shotgun metagenomics

mbtools has support for aligning shotgun metagenomic reads. Before proceeding we recommend you preprocess the reads first as described in an earlier vignette.

library(mbtools)

Aligning reads

We use minimap2 for everything since it performs as good as other aligners but does not require explicit building of the reference. This way your reference database can just be a (compressed) fasta file.

As example data we will use 3 samples generated with the polyester read sampler from a list of 10 reference genomes in equal abundances.

Preparing the example data

Let's create our file list for the example data and reference database:

fi <- system.file("extdata/shotgun", package = "mbtools") %>%
      find_read_files()
ref <- system.file("extdata/genomes/zymo_mock.fna.gz",
                   package = "mbtools")

Which are 3 paired-end files.

fi

Aligning

As always we will need A config object.

config <- config_align(
    reference = ref,
    threads = 3,
    use_existing = FALSE
)

config

This will be sufficient to align reads. As always the first argument can also be an artifact from quality_control or preprocess.

alns <- align_short_reads(fi, config)

You will get an output artifact that logs the created alignments...

alns$alignments

...the size of all the alignments on disk...

print(alns$disk_size, unit = "auto")

...and the logs in case something goes wrong.

cat(alns$logs[[1]])


Gibbons-Lab/mbtools documentation built on Jan. 28, 2024, 11:08 a.m.