File: findOverlaps-methods.Rd

package info (click to toggle)
r-bioc-genomicalignments 1.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,980 kB
  • ctags: 54
  • sloc: ansic: 1,493; makefile: 4; sh: 3
file content (182 lines) | stat: -rw-r--r-- 6,690 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
\name{findOverlaps-methods}
\alias{findOverlaps-methods}

\alias{findOverlaps}
\alias{findOverlaps,GAlignments,Vector-method}
\alias{findOverlaps,Vector,GAlignments-method}
\alias{findOverlaps,GAlignments,GAlignments-method}
\alias{findOverlaps,GAlignments,GRangesList-method}
\alias{findOverlaps,GRangesList,GAlignments-method}
\alias{findOverlaps,GAlignmentPairs,Vector-method}
\alias{findOverlaps,Vector,GAlignmentPairs-method}
\alias{findOverlaps,GAlignmentPairs,GAlignmentPairs-method}
\alias{findOverlaps,GAlignmentsList,Vector-method}
\alias{findOverlaps,Vector,GAlignmentsList-method}
\alias{findOverlaps,GAlignmentsList,GAlignmentsList-method}

\alias{countOverlaps}
\alias{countOverlaps,GAlignments,Vector-method}
\alias{countOverlaps,Vector,GAlignments-method}
\alias{countOverlaps,GAlignments,GAlignments-method}
\alias{countOverlaps,GAlignments,GenomicRanges-method}
\alias{countOverlaps,GenomicRanges,GAlignments-method}
\alias{countOverlaps,GAlignments,GRangesList-method}
\alias{countOverlaps,GRangesList,GAlignments-method}
\alias{countOverlaps,GAlignmentPairs,Vector-method}
\alias{countOverlaps,Vector,GAlignmentPairs-method}
\alias{countOverlaps,GAlignmentPairs,GAlignmentPairs-method}
\alias{countOverlaps,GAlignmentsList,Vector-method}
\alias{countOverlaps,Vector,GAlignmentsList-method}
\alias{countOverlaps,GAlignmentsList,GAlignmentsList-method}

\alias{overlapsAny}
\alias{overlapsAny,GAlignments,Vector-method}
\alias{overlapsAny,Vector,GAlignments-method}
\alias{overlapsAny,GAlignments,GAlignments-method}
\alias{overlapsAny,GAlignmentPairs,Vector-method}
\alias{overlapsAny,Vector,GAlignmentPairs-method}
\alias{overlapsAny,GAlignmentPairs,GAlignmentPairs-method}
\alias{overlapsAny,GAlignmentsList,Vector-method}
\alias{overlapsAny,Vector,GAlignmentsList-method}
\alias{overlapsAny,GAlignmentsList,GAlignmentsList-method}

\alias{subsetByOverlaps}
\alias{subsetByOverlaps,GAlignments,Vector-method}
\alias{subsetByOverlaps,Vector,GAlignments-method}
\alias{subsetByOverlaps,GAlignments,GAlignments-method}
\alias{subsetByOverlaps,GAlignmentPairs,Vector-method}
\alias{subsetByOverlaps,Vector,GAlignmentPairs-method}
\alias{subsetByOverlaps,GAlignmentPairs,GAlignmentPairs-method}
\alias{subsetByOverlaps,GAlignmentsList,Vector-method}
\alias{subsetByOverlaps,Vector,GAlignmentsList-method}
\alias{subsetByOverlaps,GAlignmentsList,GAlignmentsList-method}


\title{Finding overlapping genomic alignments}

\description{
  Finds range overlaps between a \link{GAlignments}, \link{GAlignmentPairs}, 
  or \link{GAlignmentsList} object, and another range-based object.

  NOTE: The \code{\link[IRanges]{findOverlaps}} generic function and methods
  for \link[IRanges]{Ranges} and \link[IRanges]{RangesList} objects
  are defined and documented in the \pkg{IRanges} package.
  The methods for \link[GenomicRanges]{GRanges} and
  \link[GenomicRanges]{GRangesList} objects are defined and
  documented in the \pkg{GenomicRanges} package.
}

\usage{
\S4method{findOverlaps}{GAlignments,GAlignments}(query, subject,
    maxgap = 0L, minoverlap = 1L,
    type = c("any", "start", "end", "within"),
    select = c("all", "first"),
    ignore.strand = FALSE)

\S4method{countOverlaps}{GAlignments,GAlignments}(query, subject,
    maxgap = 0L, minoverlap = 1L,
    type = c("any", "start", "end", "within"),
    ignore.strand = FALSE)

\S4method{overlapsAny}{GAlignments,GAlignments}(query, subject,
    maxgap = 0L, minoverlap = 1L,
    type = c("any", "start", "end", "within"),
    ignore.strand = FALSE)

\S4method{subsetByOverlaps}{GAlignments,GAlignments}(query, subject,
    maxgap = 0L, minoverlap = 1L,
    type = c("any", "start", "end", "within"),
    ignore.strand = FALSE)
}

\arguments{
  \item{query, subject}{
    A \link{GAlignments}, \link{GAlignmentPairs}, or \link{GAlignmentsList}
    object for either \code{query} or \code{subject}.
    A vector-like object containing ranges for the other one.
  }
  \item{maxgap, minoverlap, type, select}{
    See \code{\link[IRanges]{findOverlaps}} in the \pkg{IRanges} package
    for a description of these arguments.
  }
  \item{ignore.strand}{
    When set to \code{TRUE}, the strand information is ignored in the
    overlap calculations.
  }
}

\details{
  When the query or the subject (or both) is a \link{GAlignments}
  object, it is first turned into a \link{GRangesList} object (with
  \code{as( , "GRangesList")}) and then the rules described previously
  apply. \link{GAlignmentsList} objects are coerced to \link{GAlignments}
  then to a \link{GRangesList}. Feature indices are mapped back to the 
  original \link{GAlignmentsList} list elements.

  When the query is a \link{GAlignmentPairs} object, it is first
  turned into a \link{GRangesList} object (with \code{as( , "GRangesList")})
  and then the rules described previously apply.
}

\value{
  For \code{findOverlaps} either a \link[IRanges]{Hits} object when
  \code{select = "all"} or an integer vector otherwise. 

  For \code{countOverlaps} an integer vector containing the tabulated
  query overlap hits.

  For \code{overlapsAny} a logical vector of length equal to the number of
  ranges in \code{query} indicating those that overlap any of the ranges
  in \code{subject}.

  For \code{subsetByOverlaps} an object of the same class as \code{query}
  containing the subset that overlapped at least one entity in \code{subject}.
}

\seealso{
  \itemize{
    \item \code{\link[IRanges]{findOverlaps}}.
    \item \link[IRanges]{Hits-class}.
    \item \link{GRanges-class}.
    \item \link{GRangesList-class}.
    \item \link{GAlignments-class}.
    \item \link{GAlignmentPairs-class}.
    \item \link{GAlignmentsList-class}.
  }
}

\examples{
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)
}

\keyword{methods}
\keyword{utilities}