BWA barcode trimming and labeling
1
0
Entering edit mode
8.4 years ago
igor 13k

There is a -B flag in bwa aln:

Length of barcode starting from the 5’-end. When INT is positive, the barcode of each read will be trimmed before mapping and will be written at the BC SAM tag. For paired-end reads, the barcode from both ends are concatenated. [0]

However, it does not seem to be present in bwa mem. Is there a way to replicate this behavior in bwa mem? It doesn't actually affect the actual alignment (as far as I can tell), so technically it should be possible for both alignment options.

Also, are there other aligners that support this behavior?

bwa • 3.8k views
ADD COMMENT
1
Entering edit mode
8.3 years ago
piet ★ 1.9k

The tasks of read trimming or clipping should be separated from assembling or mapping in a properly designed work flow. There are dozens of tools for read clipping, thus this functionality must not be re-implemented within aligners. In simple cases use 'seqtk'.

In my experience barcode trimming is usually done by the sequencing service provider. You only need to care about it if something went wrong there. And in these pathologic cases you will usually need a procedure highly adapted to that case.

However, you can exploit the fact, that 'bwa mem' is able to read an interleaved fastq stream from stdin (note the trailing '-').

my_favorite_read_trimmer <in1.fq> <in2.fq> | bwa mem -p refseq.fasta -
ADD COMMENT
0
Entering edit mode

The reason why I mentioned the -B flag was because it allowed you to keep the barcode associated with the corresponding read. If you trim prior to alignment, then you lose the barcode which would defeat the entire purpose.

I am familiar with demultiplexing and read trimming. My question was about a specific task that is related, but completely different.

ADD REPLY
0
Entering edit mode

"bwa mem" is a local aligner. Thus technically, it can align your reads even with barcodes present. Do you have reads with different barcodes in a single FASTQ file?

ADD REPLY
0
Entering edit mode

Yes. Otherwise, there is no point in having the barcode in the aligned file.

ADD REPLY
0
Entering edit mode

If you would store the stripped reads in different files, you could use read groups to keep track of the barcodes. See this (great) comment from John C: Read Group In Sam/Bam Files: What Do They Exactly Describe?

ADD REPLY

Login before adding your answer.

Traffic: 2551 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6