fastqFilter: Filter and trim a fastq file.

Description Usage Arguments Value See Also Examples

View source: R/filter.R

Description

fastqFilter takes an input fastq file (can be compressed), filters it based on several user-definable criteria, and outputs those reads which pass the filter to a new fastq file (also can be compressed). Several functions in the ShortRead package are leveraged to do this filtering.

Usage

1
2
3
4
fastqFilter(fn, fout, truncQ = 2, truncLen = 0, maxLen = Inf,
  minLen = 20, trimLeft = 0, maxN = 0, minQ = 0, maxEE = Inf,
  rm.phix = TRUE, primer.fwd = NULL, n = 1e+06, OMP = TRUE,
  compress = TRUE, verbose = FALSE, ...)

Arguments

fn

(Required). The path to the input fastq file.

fout

(Required). The path to the output file. Note that by default (compress=TRUE) the output fastq file is gzipped.

truncQ

(Optional). Default 2. Truncate reads at the first instance of a quality score less than or equal to truncQ.

truncLen

(Optional). Default 0 (no truncation). Truncate reads after truncLen bases. Reads shorter than this are discarded.

maxLen

(Optional). Default Inf (no maximum). Remove reads with length greater than maxLen. maxLen is enforced on the raw reads.

minLen

(Optional). Default 20. Remove reads with length less than minLen. minLen is enforced after all other trimming and truncation.

trimLeft

(Optional). Default 0. The number of nucleotides to remove from the start of each read. If both truncLen and trimLeft are provided, filtered reads will have length truncLen-trimLeft.

maxN

(Optional). Default 0. After truncation, sequences with more than maxN Ns will be discarded. Note that dada currently does not allow Ns.

minQ

(Optional). Default 0. After truncation, reads contain a quality score below minQ will be discarded.

maxEE

(Optional). Default Inf (no EE filtering). After truncation, reads with higher than maxEE "expected errors" will be discarded. Expected errors are calculated from the nominal definition of the quality score: EE = sum(10^(-Q/10))

rm.phix

(Optional). Default TRUE. If TRUE, discard reads that match against the phiX genome, as determined by isPhiX.

primer.fwd

(Optional). Default NULL. A character string defining the forward primer. Only allows unambiguous nucleotides. The primer will be compared to the first len(primer.fwd) nucleotides at the start of the read. If there is not an exact match, the read is filtered out.

n

(Optional). The number of records (reads) to read in and filter at any one time. This controls the peak memory requirement so that very large fastq files are supported. Default is 1e6, one-million reads. See FastqStreamer for details.

OMP

(Optional). Default TRUE. Whether or not to use OMP multithreading when calling FastqStreamer. Set this to FALSE if calling this function within a parallelized chunk of code (eg. within mclapply).

compress

(Optional). Default TRUE. Whether the output fastq file should be gzip compressed.

verbose

(Optional). Default FALSE. Whether to output status messages.

...

(Optional). Arguments passed on to isPhiX.

Value

integer(2). The number of reads read in, and the number of reads that passed the filter and were output.

See Also

fastqPairedFilter FastqStreamer trimTails

Examples

1
2
3
4
testFastq = system.file("extdata", "sam1F.fastq.gz", package="dada2")
filtFastq <- tempfile(fileext=".fastq.gz")
fastqFilter(testFastq, filtFastq, maxN=0, maxEE=2)
fastqFilter(testFastq, filtFastq, trimLeft=10, truncLen=200, maxEE=2, verbose=TRUE)

dada2 documentation built on Nov. 17, 2017, 10:21 a.m.