trimTails | R Documentation |
These generic functions remove leading or trailing nucleotides or
qualities. trimTails
and trimTailw
remove low-quality
reads from the right end using a sliding window (trimTailw
) or
a tally of (successive) nucleotides falling at or below a quality
threshold (trimTails
). trimEnds
takes an alphabet of
characters to remove from either left or right end.
## S4 methods for 'ShortReadQ', 'FastqQuality', or 'SFastqQuality'
trimTailw(object, k, a, halfwidth, ..., ranges=FALSE)
trimTails(object, k, a, successive=FALSE, ..., ranges=FALSE)
trimEnds(object, a, left=TRUE, right=TRUE, relation=c("<=", "=="),
..., ranges=FALSE)
## S4 method for signature 'BStringSet'
trimTailw(object, k, a, halfwidth, ..., alphabet, ranges=FALSE)
## S4 method for signature 'BStringSet'
trimTails(object, k, a, successive=FALSE, ...,
alphabet, ranges=FALSE)
## S4 method for signature 'character'
trimTailw(object, k, a, halfwidth, ..., destinations, ranges=FALSE)
## S4 method for signature 'character'
trimTails(object, k, a, successive=FALSE, ..., destinations, ranges=FALSE)
## S4 method for signature 'character'
trimEnds(object, a, left=TRUE, right=TRUE, relation=c("<=", "=="),
..., destinations, ranges=FALSE)
object |
An object (e.g., |
k |
|
a |
For For |
halfwidth |
The half width (cycles before or after the current; e.g., a half-width of 5 would span 5 + 1 + 5 cycles) in which qualities are assessed. |
successive |
|
left , right |
|
relation |
|
... |
Additional arguments, perhaps used by methods. |
destinations |
For |
alphabet |
|
ranges |
|
trimTailw
starts at the left-most nucleotide, tabulating the
number of cycles in a window of 2 * halfwidth + 1
surrounding
the current nucleotide with quality scores that fall at or below
a
. The read is trimmed at the first nucleotide for which this
number >= k
. The quality of the first or last nucleotide is
used to represent portions of the window that extend beyond the
sequence.
trimTails
starts at the left-most nucleotide and accumulates
cycles for which the quality score is at or below a
. The read
is trimmed at the first location where this number >= k
. With
successive=TRUE
, failing qualities must occur in strict
succession.
trimEnds
examines the left
, right
, or both ends
of object
, marking for removal letters that correspond to
a
and relation
. The trimEnds,ShortReadQ-method
trims based on quality.
ShortReadQ
methods operate on quality scores; use
sread()
and the ranges
argument to trim based on
nucleotide (see examples).
character
methods transform one or several fastq files to new
fastq files, applying trim operations based on quality scores; use
filterFastq
with your own filter
argument to filter on
nucleotides.
An instance of class(object)
trimmed to contain only those
nucleotides satisfying the trim criterion or, if ranges=TRUE
an
IRanges
instance defining the ranges that would trim
object
.
The trim*
functions use OpenMP threads (when available) during
creation of the return value. This may sometimes create problems when
a process is already running on multiple threads, e.g., with an error
message like
libgomp: Thread creation failed: Resource temporarily unavailable
A solution is to precede problematic code with the following code snippet, to disable threading
nthreads <- .Call(ShortRead:::.set_omp_threads, 1L) on.exit(.Call(ShortRead:::.set_omp_threads, nthreads))
Martin Morgan <mtmorgan@fhcrc.org>
showMethods(trimTails)
sp <- SolexaPath(system.file('extdata', package='ShortRead'))
rfq <- readFastq(analysisPath(sp), pattern="s_1_sequence.txt")
## remove leading / trailing quality scores <= 'I'
trimEnds(rfq, "I")
## remove leading / trailing 'N's
rng <- trimEnds(sread(rfq), "N", relation="==", ranges=TRUE)
narrow(rfq, start(rng), end(rng))
## remove leading / trailing 'G's or 'C's
trimEnds(rfq, c("G", "C"), relation="==")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.