findOverlaps-methods | R Documentation |
Finds range overlaps between a GAlignments, GAlignmentPairs, or GAlignmentsList object, and another range-based object.
NOTE: The findOverlaps
generic function and methods
for IntegerRanges and IntegerRangesList
objects are defined and documented in the IRanges package.
The methods for GRanges and
GRangesList objects are defined and
documented in the GenomicRanges package.
GAlignments, GAlignmentPairs, and GAlignmentsList
objects also support countOverlaps
, overlapsAny
, and
subsetByOverlaps
thanks to the default methods defined in the
IRanges package and to the findOverlaps
method defined in
this package and documented below.
## S4 method for signature 'GAlignments,GAlignments'
findOverlaps(query, subject,
maxgap=-1L, minoverlap=0L,
type=c("any", "start", "end", "within"),
select=c("all", "first", "last", "arbitrary"),
ignore.strand=FALSE)
query , subject |
A GAlignments, GAlignmentPairs, or GAlignmentsList
object for either |
maxgap , minoverlap , type , select |
See |
ignore.strand |
When set to |
When the query or the subject (or both) is a GAlignments
object, it is first turned into a GRangesList object (with
as( , "GRangesList")
) and then the rules described previously
apply. GAlignmentsList objects are coerced to GAlignments
then to a GRangesList. Feature indices are mapped back to the
original GAlignmentsList list elements.
When the query is a GAlignmentPairs object, it is first
turned into a GRangesList object (with as( , "GRangesList")
)
and then the rules described previously apply.
A Hits object when select="all"
or an integer
vector otherwise.
findOverlaps
.
Hits-class.
GRanges-class.
GRangesList-class.
GAlignments-class.
GAlignmentPairs-class.
GAlignmentsList-class.
ex1_file <- system.file("extdata", "ex1.bam", package="Rsamtools")
galn <- readGAlignments(ex1_file)
subject <- granges(galn)[1]
## Note the absence of query no. 9 (i.e. 'galn[9]') in this result:
as.matrix(findOverlaps(galn, subject))
## This is because, by default, findOverlaps()/countOverlaps() are
## strand specific:
galn[8:10]
countOverlaps(galn[8:10], subject)
countOverlaps(galn[8:10], subject, ignore.strand=TRUE)
## Count alignments in 'galn' that DO overlap with 'subject' vs those
## that do NOT:
table(overlapsAny(galn, subject))
## Extract those that DO:
subsetByOverlaps(galn, subject)
## GAlignmentsList
galist <- GAlignmentsList(galn[8:10], galn[3000:3002])
gr <- GRanges(c("seq1", "seq1", "seq2"),
IRanges(c(15, 18, 1233), width=1),
strand=c("-", "+", "+"))
countOverlaps(galist, gr)
countOverlaps(galist, gr, ignore.strand=TRUE)
findOverlaps(galist, gr)
findOverlaps(galist, gr, ignore.strand=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.