What it does
This Galaxy tool wraps the bwa-mem module of the BWA read mapping tool. For more details about the different modules of the BWA package see the BWA manual.
The Galaxy implementation takes fastq files as input and produces output in BAM format, which can be further processed using various BAM utilities existing in Galaxy (BAMTools, SAMTools, Picard).
From http://arxiv.org/abs/1303.3997:
BWA-MEM is an alignment algorithm for aligning sequence reads or long query sequences against a large reference genome such as human. It automatically chooses between local and end-to-end alignments, supports paired-end reads and performs chimeric alignment. The algorithm is robust to sequencing errors and applicable to a wide range of sequence lengths from 70bp to a few megabases.
Indices: Selecting reference genomes for BWA
The Galaxy wrapper for BWA allows you to select between precomputed and user-defined indices for reference genomes using the Will you select a reference genome from your history or use a built-in index? select box.
This select box has two options:
Use a built-in genome index
With this option (which is the default), Galaxy provides you with a dropdown select menu populated with genomes that have been pre-indexed with the bwa index utility and are ready to map sequenced reads against.
The collection of pre-indexed genomes is managed by the administrators of your Galaxy instance. If your genome of interest is missing and its impractical to use the second option below to work with it, consider contacting the support team for the Galaxy server you are working on to let them know that you would like to have an additional genome indexed.
Use a genome from history and build index
With this option, Galaxy provides you with a dropdown select menu populated with all FASTA formatted files listed in your current history. If you have uploaded your genome of interest into your history it will be shown there.
Selecting a genome from this dropdown will cause Galaxy to index it transparently first using the bwa index command, and then map against it with bwa aln.
Analysis modes
The tool supports different preconfigured analysis modes optimized for different types of input data. Alternatively, it allows you to take full control over all available options.
The preconfigured modes are:
Simple Illumina mode
This corresponds to the simplest possible and standard bwa mem application in which it aligns single or paired-end data to a reference using default parameters. It is equivalent to the following command: bwa mem <reference index> <fastq dataset1> [fastq dataset2]
PacBio mode
This mode is adjusted specifically for mapping of long PacBio subreads. It is running bwa mame with the -x pacbio option.
Nanopore 2D-reads mode
This mode is running bwa mem with the -x ont2d option.
Intra-sepcies contigs mode
This mode is running bwa mem with the -x intractg option.
Please note: minimap2 is recommended over and outperforms BWA-MEM for most types of input data except for Illumina short reads. For Illumina short-read mapping you may also consider using BWA-MEM2, which is about twice as fast as BWA-MEM.
Bam sorting mode
The generated bam files can be sorted according to three criteria: coordinates, names and input order.
In coordinate sorted mode the reads are sorted by coordinates. It means that the reads from the beginning of the first chromosome are first in the file.
When sorted by read name, the file is sorted by the reference ID (i.e., the QNAME field).
Finally, the No sorted (sorted as input) option yield a BAM file in which the records are sorted in an order corresponding to the order of the reads in the original input file. This option requires using a single thread to perform the conversion from SAM to BAM format, so the runtime is extended.
Read Groups are Important!
One of the recommended best practices in NGS analysis is adding read group information to BAM files. You can do this directly in BWA interface using the Specify read group information? widget. If you are not familiar with read groups you shold know that this is effectively a way to tag reads with an additional ID. This allows you to combine BAM files from, for example, multiple BWA runs into a single dataset. This significantly simplifies downstream processing as instead of dealing with multiple datasets you only have to handle only one. This is possible because the read group information allows you to identify data from different experiments even if they are combined in one file. Many downstream analysis tools such as variant callers (e.g., FreeBayes or Naive Variant Caller present in Galaxy) are aware of read groups and will automatically generate calls for each individual sample even if they are combined within a single file.
Description of read groups fields
(from GATK FAQ webpage):
| Tag | Importance | Definition | Meaning |
|---|---|---|---|
| ID | Required | Read group identifier. Each @RG line must have a unique ID. The value of ID is used in the RG tags of alignment records. Must be unique among all read groups in header section. Read group IDs may be modified when merging SAM files in order to handle collisions. | Ideally, this should be a globally unique identify across all sequencing data in the world, such as the Illumina flowcell + lane name and number. Will be referenced by each read with the RG:Z field, allowing tools to determine the read group information associated with each read, including the sample from which the read came. Also, a read group is effectively treated as a separate run of the NGS instrument in tools like base quality score recalibration (a GATK component) -- all reads within a read group are assumed to come from the same instrument run and to therefore share the same error model. |
| SM | Sample. Use pool name where a pool is being sequenced. | Required. As important as ID. | The name of the sample sequenced in this read group. GATK tools treat all read groups with the same SM value as containing sequencing data for the same sample. Therefore it's critical that the SM field be correctly specified, especially when using multi-sample tools like the Unified Genotyper (a GATK component). |
| PL | Platform/technology used to produce the read. Valid values: ILLUMINA, SOLID, LS454, HELICOS and PACBIO. | Important. Not currently used in the GATK, but was in the past, and may return. The only way to known the sequencing technology used to generate the sequencing data | It's a good idea to use this field. |
| LB | DNA preparation library identify | Essential for MarkDuplicates | MarkDuplicates uses the LB field to determine which read groups might contain molecular duplicates, in case the same DNA library was sequenced on multiple lanes. |
Example of Read Group usage
Suppose we have a trio of samples: MOM, DAD, and KID. Each has two DNA libraries prepared, one with 400 bp inserts and another with 200 bp inserts. Each of these libraries is run on two lanes of an illumina hiseq, requiring 3 x 2 x 2 = 12 lanes of data. When the data come off the sequencer, we would create 12 BAM files, with the following @RG fields in the header:
Dad's data: @RG ID:FLOWCELL1.LANE1 PL:illumina LB:LIB-DAD-1 SM:DAD PI:200 @RG ID:FLOWCELL1.LANE2 PL:illumina LB:LIB-DAD-1 SM:DAD PI:200 @RG ID:FLOWCELL1.LANE3 PL:illumina LB:LIB-DAD-2 SM:DAD PI:400 @RG ID:FLOWCELL1.LANE4 PL:illumina LB:LIB-DAD-2 SM:DAD PI:400 Mom's data: @RG ID:FLOWCELL1.LANE5 PL:illumina LB:LIB-MOM-1 SM:MOM PI:200 @RG ID:FLOWCELL1.LANE6 PL:illumina LB:LIB-MOM-1 SM:MOM PI:200 @RG ID:FLOWCELL1.LANE7 PL:illumina LB:LIB-MOM-2 SM:MOM PI:400 @RG ID:FLOWCELL1.LANE8 PL:illumina LB:LIB-MOM-2 SM:MOM PI:400 Kid's data: @RG ID:FLOWCELL2.LANE1 PL:illumina LB:LIB-KID-1 SM:KID PI:200 @RG ID:FLOWCELL2.LANE2 PL:illumina LB:LIB-KID-1 SM:KID PI:200 @RG ID:FLOWCELL2.LANE3 PL:illumina LB:LIB-KID-2 SM:KID PI:400 @RG ID:FLOWCELL2.LANE4 PL:illumina LB:LIB-KID-2 SM:KID PI:400
Note the hierarchical relationship between read groups (unique for each lane) to libraries (sequenced on two lanes) and samples (across four lanes, two lanes for each library).