Description Usage Arguments Value Examples
Helper function for demultiplexing sequencing reads, designed in a way to allow for parallelization accross barcodes (parallel extraction of reads by barcode). This function takes a specific barcode (numeric index) from lists of sample names/barcodes, a Biostrings::DNAStringSet of barcodes by sequence header, and a Biostrings::QualityScaledXStringSet of reads corresponding to the barcodes. Based on the barcode index given, it extracts all reads for the indexed barcode and writes all the reads from that barcode to a separate .fastq file.
1 2 | extractReads(barcodeIndex, barcodes, sampleNames, index, reads,
location = "./demultiplex_fastq", rcBarcodes = TRUE, hDist = 0)
|
barcodeIndex |
Which barcode (integer number or index) in the barcodes or sample name to use for read extraction |
barcodes |
A list of all barcodes in the sequencing dataset. Correlates and in same order as sampleNames |
sampleNames |
A list of sample names or identifiers associated with each barcode in the barcodes list |
index |
A Biostrings::DNAStringSet that contains the read headers and barcode sequence for each header in the sequence slot |
reads |
A Biostrings::QualityScaledXStringSet that has the same headers and order as the index file, but contains the read sequences and their quality scores |
location |
A directory location to store the demuliplexed read files. Defaults to generate a new subdirectory at './demultiplex_fastq' |
rcBarcodes |
Should the barcode indexes in the barcodes list be reverse complemented to match the sequences in the index DNAStringSet? Defaults to TRUE |
hDist |
Uses a Hamming Distance or number of base differences to allow for inexact matches for the barcodes/indexes. Defaults to 0. Warning: if the Hamming Distance is >=1 and this leads to inexact index matches to more than one barcode, that read will be written to more than one demultiplexed read files |
Writes a single .fastq file that contains all reads whose index matches the barcode specified. This file will be written to the location directory, and will be named based on the specified sampleName and barcode, e.g. './demultiplex_fastq/SampleName1_GGAATTATCGGT.fastq.gz'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Load example barcode, index, and read data into R session:
barcodePath <- system.file("extdata", "barcodes.txt", package = "animalcules.preprocess")
bcFile <- read.table(barcodePath, sep = "\t", header = T)
indexPath <- system.file("extdata", "virus_example_index.fastq", package = "animalcules.preprocess")
inds <- Biostrings::readDNAStringSet(indexPath, format = "fastq")
readPath <- system.file("extdata", "virus_example.fastq", package = "animalcules.preprocess")
reads <- Biostrings::readQualityScaledDNAStringSet(readPath)
## Extract reads from the first barcode
results <- extractReads(1, bcFile[, 2], bcFile[, 1], inds, reads, rcBarcodes = FALSE,
location = ".")
results
## Extract reads from multiple barcodes
more_results <- lapply(1:6, extractReads, bcFile[, 2], bcFile[, 1], inds,
reads, rcBarcodes = FALSE, location = ".")
## BiocParallel application
multicoreParam <- BiocParallel::MulticoreParam(workers = 3)
parallel_results <- BiocParallel::bplapply(1:6, extractReads, bcFile[,
2], bcFile[, 1], inds, reads, rcBarcodes = FALSE, location = ".", BPPARAM = multicoreParam)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.