| findOverlaps-methods {GenomicAlignments} | 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 Ranges and RangesList objects
are defined and documented in the IRanges package.
The methods for GRanges and
GRangesList objects are defined and
documented in the GenomicRanges package.
## S4 method for signature 'GAlignments,GAlignments'
findOverlaps(query, subject,
maxgap=0L, minoverlap=1L,
type=c("any", "start", "end", "within"),
select=c("all", "first", "last", "arbitrary"),
algorithm=c("nclist", "intervaltree"),
ignore.strand=FALSE)
## S4 method for signature 'GAlignments,GAlignments'
countOverlaps(query, subject,
maxgap=0L, minoverlap=1L,
type=c("any", "start", "end", "within"),
algorithm=c("nclist", "intervaltree"),
ignore.strand=FALSE)
## S4 method for signature 'GAlignments,GAlignments'
overlapsAny(query, subject,
maxgap=0L, minoverlap=1L,
type=c("any", "start", "end", "within"),
algorithm=c("nclist", "intervaltree"),
ignore.strand=FALSE)
## S4 method for signature 'GAlignments,GAlignments'
subsetByOverlaps(query, subject,
maxgap=0L, minoverlap=1L,
type=c("any", "start", "end", "within"),
algorithm=c("nclist", "intervaltree"),
ignore.strand=FALSE)
query, subject |
A GAlignments, GAlignmentPairs, or GAlignmentsList
object for either |
maxgap, minoverlap, type, select, algorithm |
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.
For findOverlaps either a Hits object when
select = "all" or an integer vector otherwise.
For countOverlaps an integer vector containing the tabulated
query overlap hits.
For overlapsAny a logical vector of length equal to the number of
ranges in query indicating those that overlap any of the ranges
in subject.
For subsetByOverlaps an object of the same class as query
containing the subset that overlapped at least one entity in subject.
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)