This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Demultiplex pair-end fastq reads with barcode 2 in the identifier line

I have multiplexed pair-end fastq reads with dual barcodes. The issue is that one barcode is present in the header and one is present at the beginning of the read. I need a method to demultiplex this data, but in order to assign a read to an individual, both barcodes are required, as there is overlap between the barcodes. It seems there are packages available to demultiplex using header ID or in-line barcodes to demultiplex, but not both.

example reads:

@700819F:525:HT235BCXX:2:1101:1139:2144 1:N:0:ATCACGAT
CGAATTGCAGATTTTTTCTGAATAAAGCAGTGCAATAAAATTCCCCGCAAAAACACTTNANNNGNNNNNNNNNNNNNNNNNNNNANNNNNNGNTAATAAA
+
GGGGGIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII#<###.####################.######<#.<<GGGI
@700819F:525:HT235BCXX:2:1101:1212:2172 1:N:0:ATCACGAT
AAGGATGCAGGGCATCTCCCTCAGGCTGCGCTCTATCGAAGTCATCCCAGAATTAGATTCCGACCACAGACCAGTCTTAGTCAAACTAGGACCCGAGTGT
+
GGGGGIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGIIIIIIIIIIIIIIIIIIIIGIIIIIIGGIIIGIIIIIIIIIIIIIGGIGIGIIIGIGI
@700819F:525:HT235BCXX:2:1101:1110:2173 1:N:0:ATCACGAT
GGTTGTGCAGAAAGAGTTGCTGATAAACTTAGCCATGCAGAACAGAATTATGAGTTAGAAGTATGTATATATATACCAATCACTATATCAACCCATTACC
+
<G.G<GGIIIG.GA.GAGAAGG<AA<A<.<<<GA<.<<.G<.G<<A<GGAA....<G.G..<<.GA..<A.<GG<<<.<..<<.GG.A..G..<<<.<<G

Thanks in advance.

sequence demultiplex fastq

First, use a program that demultiplex by header. After that, use a program that demultiplex by inline barcode.

I've tried that approach, but was unsuccessful. In order to assign reads to an individual, both barcodes are required. The barcodes alone are not unique to individuals, but in combination, they are and can be used to assign reads to a sample.

I fail to see how this approach don't work. Suppose you have two barcodes in the header and two barcodes inline, identifyng four individuals. First you demultiplex by header, second you demultiplex separately each of two resulting fastqs by inline barcode:

                  [1]                 [2]
original.fastq ___----> header1.fastq ----> header1_inline1.fastq
                  |                   |
                  |                   |_--> header1_inline2.fastq
                  |
                  |_--> header2.fastq ----> header2_inline1.fastq
                                      |
                                      |_--> header2_inline2.fastq

You end up with your four individuals identified.

1 answer

How about pasting your first barcode to the reads, and demultiplexing with virtual barcodes that represent all the combinations of barcode 1 and 2 ? Here is one way to paste.

paste -d '' <(grep '^@' test.fq | sed s/.*:// | perl -ne 'chomp;print"\n$_\n\n","I"x(length($_)),"\n"') test.fq 
@700819F:525:HT235BCXX:2:1101:1139:2144 1:N:0:ATCACGAT
ATCACGATCGAATTGCAGATTTTTTCTGAATAAAGCAGTGCAATAAAATTCCCCGCAAAAACACTTNANNNGNNNNNNNNNNNNNNNNNNNNANNNNNNGNTAATAAA
+
IIIIIIIIGGGGGIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII#<###.####################.######<#.<<GGGI
etc...

The command is a bit cryptic, but basically it reads as follows: to the original file, paste without delimiter a virtual file made by extracting the barcode sequence from the read names, and for each barcode outputting and empty line, followed by a line containing the barcode, followed by an empty line, followed by a quality line with one "I" per base in teh barcode.

Thanks, this is what I was looking for. I am feeding multiplexed RADSEq reads into ipyrad to look for SNPs, so this is ideal because it works with the program nicely.

Go ahead and accept this answer (green check mark) to provide closure to this thread.

Log in to answer this question.