Skip to main content

# Streamed and parallel demultiplexing of fastq files

## Quickstart

` pydemult --fastq input.fastq.gz --barcodes barcodes.txt --threads 4 --writer-threads 16 `

## Requirements and usage

pydemult allows you to demultiplex fastq files in a streamed and parallel way. It expects that a sample barcode can be matched by a regular expression from the first line of each fastq entry and that sample barcodes are known in advance.

Suppose we have a file containing sample barcodes like this:

` Sample Barcode sample1 CTTCAA sample2 CAACAA sample3 GTACGG `

and a typical entry in the fastq file looks like this:

` @HWI-ST808:140:H0L10ADXX:1:1101:8463:2:NNNNNN:CTTCCA TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTATGATGCTGTGAGTTCC + @CCDDDDFHHHHHJIJFDDDDDDDDDBDDDDDBB0@B##################### `

Since the sample barcode is six bases long, we have to set the corresponding –barcode-regex option to (.*):(?P<CB>[ATGCN]{6} in the call

` pydemult --fastq input.fastq.gz --barcodes barcodes.txt --barcode-regex "(.*):(?P<CB>[ATGCN]{6}" `

### Barcode and UMI regular expressions

By default, pydemult parses the read name for the cell barcode with regular expressions. Cell barcodes are indicated by a capturing group called CB, while (optional) UMIs are indicated by a capturing group called UMI. Some examples include:

  • (.*):(?P<CB>[ATGCN]{11}), for a cell barcode of length 11 that is present after the last colon of the read name.

  • (.*):CELL_(?P<CB>[ATGCN]{10}):UMI_(?P<UMI>[ATGCN]{8}), for a cell barcode of length 10, followed by a UMI sequence of length 8. For DropSeq data preprocessed by the [umis](https://github.com/vals/umis) tool, a regex like this is advisable.

### Output

pydemult will create a compressed fastq file for each sample barcode, with the filename taken from the corresponding Sample column entry of barcodes.txt.

### A note on multithreading

pydemult divides its work into a demultiplexing and output part. The main thread streams the input and lazily distributes data blobs (of size –buffer-size) across n different demultiplexing threads (set with –threads), where the actual work happens. Demultiplexed input is then sent over to m threads for writing into individual output files (set with –writer-threads). Reading and demultiplexing are fast and CPU-bound operations, while output speed is determined by how fast data can be written to the underlying file system. In our experience, output is much slower than demultiplexing itself and requires proportionally more cores to speed up the runtime. We obtained best results when distributing output to three threads for each demultiplexing thread (1:3 ratio of –threads to –writer-threads).

## License

The project is licensed under the MIT license. See the LICENSE file for details.

Metadata

Release files for pydemult 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydemult 0.6
File Size Uploaded
pydemult-0.6.tar.gz 7.1 kB Details

Release files / pydemult-0.6.tar.gz

Download URL pydemult-0.6.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
59df3d38af23ee2cb6a2a383497ba868f788a2f1758600d859ae9767ad6376ae
BLAKE2b-256 checksum
How to use checksums
25c4130f6be7b897947b42c0ab957b14b9eb42ea65372758a150a6ff60df710f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.6 This release

1 release file

0.5

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2

2 release files

0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page