Home Software Services About Contact usearch manual
fastx_demux command
Commands > Reads, FASTA/Q files

Performs demultiplexing by assigning reads to samples using index reads or barcodes.

Sample identifiers are added to the read labels. By default, the sample identifier is appended to the read label using sample=xxx; syntax. If the sample_delim option is set, then the new label is the sample identifier followed by the sample_delim string followed by 1, 2, 3...

Sample identifiers are taken from the barcode sequence labels.

The barcodes option is always required. Specifies a FASTA file containing barcode sequences which are (a) matched to the index reads (if -index option is specified) or (b) are found at start of the forward reads (otherwise). The label of a barcode sequence is used as the sample identifier.

Note that in case (b) the barcode is not stripped from the sequence. You can do this using in a following step using the fastx_truncate command.

The index option specifies a FASTA or FASTQ file with index reads. If the index option is not specified, the barcodes are assumed to be at the start of the forward reads. Index labels must match the read labels and appear in the same order in both files.

The maxdiffs option specifies the maximum number of differences allowed between an index read and a barcode. Default 0. Allowing differences may tend to increase cross-talk.

The reverse option gives a FASTQ filename for the reverse (R2) reads, if applicable. Sequence labels must match the forward (R1) reads and appear in the same order. The output2 option specifies a FASTQ filename for the demultiplexed reverse reads.

Example: Illumina unpaired with index reads

usearch -fastx_demux fwd.fq -index index.fq -barcodes bar.fa -fastqout reads_demux.fq

Example: Illumina paired with single index (i1 + r1 + r2)

usearch -fastx_demux R1.fq -reverse R2.fq -index I1.fq -barcodes bar.fa \
  -fastqout fwd_demux.fq -output2 rev_demux.fq

Example: Illumina paired with dual index (i1 + i2 + r1 + r2)
Here, you need to make a barcodes FASTA file (bar.fa) which matches the output from fastq_join, which is I1, NNN spacer, reverse-complemented I2.

usearch -fastq_join I1.fq -reverse I2.fq -fastqout indexes.fq

usearch -fastx_demux R1.fq -reverse R2.fq -index indexes.fq -barcodes bar.fa \
  -fastqout fwd_demux.fq -output2 rev_demux.fq

Example: 454 with barcodes in the main reads

usearch -fastx_demux reads.fq -barcodes bar.fa -fastqout reads_demux.fq