~ubuntu-branches/ubuntu/wily/r-bioc-genomicranges/wily-proposed

« back to all changes in this revision

Viewing changes to man/setops-methods.Rd

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2013-10-18 10:40:04 UTC
  • Revision ID: package-import@ubuntu.com-20131018104004-ktm4ub0pcoybnir6
Tags: upstream-1.12.4
ImportĀ upstreamĀ versionĀ 1.12.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\name{setops-methods}
 
2
\alias{setops-methods}
 
3
 
 
4
\alias{union,GRanges,GRanges-method}
 
5
\alias{intersect,GRanges,GRanges-method}
 
6
\alias{setdiff,GRanges,GRanges-method}
 
7
 
 
8
\alias{punion,GRanges,GRanges-method}
 
9
\alias{punion,GRanges,GRangesList-method}
 
10
\alias{punion,GRangesList,GRanges-method}
 
11
 
 
12
\alias{pintersect,GRanges,GRanges-method}
 
13
\alias{pintersect,GRanges,GRangesList-method}
 
14
\alias{pintersect,GRangesList,GRanges-method}
 
15
\alias{pintersect,GRangesList,GRangesList-method}
 
16
\alias{pintersect,GappedAlignments,GRanges-method}
 
17
\alias{pintersect,GRanges,GappedAlignments-method}
 
18
 
 
19
\alias{psetdiff,GRanges,GRanges-method}
 
20
\alias{psetdiff,GRanges,GRangesList-method}
 
21
\alias{psetdiff,GRangesList,GRangesList-method}
 
22
 
 
23
\alias{pgap,GRanges,GRanges-method}
 
24
 
 
25
\title{Set operations on GRanges/GRangesList/GappedAlignments objects}
 
26
 
 
27
\description{
 
28
  Performs set operations on GRanges/GRangesList/GappedAlignments objects.
 
29
}
 
30
 
 
31
\usage{
 
32
## Set operations
 
33
\S4method{union}{GRanges,GRanges}(x, y, ignore.strand=FALSE, ...)
 
34
\S4method{intersect}{GRanges,GRanges}(x, y, ignore.strand=FALSE, ...)
 
35
\S4method{setdiff}{GRanges,GRanges}(x, y, ignore.strand=FALSE, ...)
 
36
 
 
37
## Parallel set operations
 
38
\S4method{punion}{GRanges,GRanges}(x, y, fill.gap=FALSE, ignore.strand=FALSE, ...)
 
39
\S4method{pintersect}{GRanges,GRanges}(x, y, resolve.empty=c("none", "max.start", "start.x"), ignore.strand=FALSE, ...)
 
40
\S4method{pintersect}{GappedAlignments,GRanges}(x, y, ...)
 
41
\S4method{psetdiff}{GRanges,GRanges}(x, y, ignore.strand=FALSE, ...)
 
42
}
 
43
 
 
44
\arguments{
 
45
  \item{x, y}{
 
46
    For \code{union}, \code{intersect}, \code{setdiff}, \code{pgap}:
 
47
    \code{x} and \code{y} must both be \link{GRanges} objects.
 
48
 
 
49
    For \code{punion}: one of \code{x} or \code{y} must be a \link{GRanges}
 
50
    object, the other one can be a \link{GRanges} or \link{GRangesList} object.
 
51
 
 
52
    For \code{pintersect}: one of \code{x} or \code{y} must be a \link{GRanges}
 
53
    object, the other one can be a \link{GRanges}, \link{GRangesList} or
 
54
    \link{GappedAlignments} object.
 
55
 
 
56
    For \code{psetdiff}: \code{x} and \code{y} can be any combination of
 
57
    \link{GRanges} and/or \link{GRangesList} objects, with the exception
 
58
    that if \code{x} is a \link{GRangesList} object then \code{y} must be
 
59
    a \link{GRangesList} too.
 
60
 
 
61
    In addition, for the "parallel" operations, \code{x} and \code{y} must
 
62
    be of equal length (i.e. \code{length(x) == length(y)}).
 
63
  }
 
64
  \item{fill.gap}{
 
65
    Logical indicating whether or not to force a union by using the rule
 
66
    \code{start = min(start(x), start(y)), end = max(end(x), end(y))}.
 
67
  }
 
68
  \item{resolve.empty}{
 
69
    One of \code{"none"}, \code{"max.start"}, or \code{"start.x"} denoting
 
70
    how to handle ambiguous empty ranges formed by intersections.
 
71
    \code{"none"} - throw an error if an ambiguous empty range is formed,
 
72
    \code{"max.start"} - associate the maximum start value with any
 
73
    ambiguous empty range, and \code{"start.x"} - associate the start value
 
74
    of \code{x} with any ambiguous empty range. (See
 
75
    \code{\link[IRanges]{pintersect}} for the definition of an ambiguous
 
76
    range.)
 
77
  }
 
78
  \item{ignore.strand}{
 
79
    For set operations: If set to TRUE, then the strand of \code{x} and
 
80
    \code{y} is set to \code{"*"} prior to any computation.
 
81
 
 
82
    For parallel set operations: If set to TRUE, the strand information is
 
83
    ignored in the computation and the result has the strand information of
 
84
    \code{x}.
 
85
  }
 
86
  \item{...}{
 
87
    Further arguments to be passed to or from other methods.
 
88
  }
 
89
}
 
90
 
 
91
\details{
 
92
  The \code{pintersect} methods involving \link{GRanges}, \link{GRangesList}
 
93
  and/or \link{GappedAlignments} objects use the triplet (sequence name, range,
 
94
  strand) to determine the element by element intersection of features,
 
95
  where a strand value of \code{"*"} is treated as occurring on both the
 
96
  \code{"+"} and \code{"-"} strand.
 
97
 
 
98
  The \code{psetdiff} methods involving \link{GRanges} and/or
 
99
  \link{GRangesList} objects use the triplet (sequence name, range,
 
100
  strand) to determine the element by element set difference of features,
 
101
  where a strand value of \code{"*"} is treated as occurring on both the
 
102
  \code{"+"} and \code{"-"} strand.
 
103
}
 
104
 
 
105
\value{
 
106
  For \code{union}, \code{intersect}, \code{setdiff}, and \code{pgap}: a
 
107
  \link{GRanges}.
 
108
 
 
109
  For \code{punion} and \code{pintersect}: when \code{x} or \code{y} is
 
110
  not a \link{GRanges} object, an object of the same class as this
 
111
  non-\link{GRanges} object. Otherwise, a \link{GRanges} object.
 
112
 
 
113
  For \code{psetdiff}: either a \link{GRanges} object when both \code{x}
 
114
  and \code{y} are \link{GRanges} objects, or a \link{GRangesList} object
 
115
  when \code{y} is a \link{GRangesList} object.
 
116
}
 
117
 
 
118
\author{P. Aboyoun}
 
119
 
 
120
\seealso{
 
121
  \link[IRanges]{setops-methods},
 
122
  \link{GRanges-class},
 
123
  \link{GRangesList-class},
 
124
  \link{GappedAlignments-class},
 
125
  \link{findOverlaps-methods}
 
126
}
 
127
 
 
128
\examples{
 
129
## ---------------------------------------------------------------------
 
130
## A. SET OPERATIONS
 
131
## ---------------------------------------------------------------------
 
132
 
 
133
x <- GRanges("chr1", IRanges(c(2, 9) , c(7, 19)), strand=c("+", "-"))
 
134
y <- GRanges("chr1", IRanges(5, 10), strand="-") 
 
135
 
 
136
union(x, y)
 
137
union(x, y, ignore.strand=TRUE)
 
138
 
 
139
intersect(x, y)
 
140
intersect(x, y, ignore.strand=TRUE)
 
141
 
 
142
setdiff(x, y)
 
143
setdiff(x, y, ignore.strand=TRUE)
 
144
 
 
145
## ---------------------------------------------------------------------
 
146
## B. PARALLEL SET OPERATIONS
 
147
## ---------------------------------------------------------------------
 
148
 
 
149
\dontrun{
 
150
punion(x, shift(x, 7))  # will fail
 
151
}
 
152
punion(x, shift(x, 7), fill.gap=TRUE)
 
153
 
 
154
pintersect(x, shift(x, 6))
 
155
\dontrun{
 
156
pintersect(x, shift(x, 7))  # will fail
 
157
}
 
158
pintersect(x, shift(x, 7), resolve.empty="max.start")
 
159
 
 
160
psetdiff(x, shift(x, 7))
 
161
 
 
162
## ---------------------------------------------------------------------
 
163
## C. MORE EXAMPLES
 
164
## ---------------------------------------------------------------------
 
165
 
 
166
## GRanges object:
 
167
gr <- GRanges(seqnames=c("chr2", "chr1", "chr1"),
 
168
              ranges=IRanges(1:3, width = 12),
 
169
              strand=Rle(strand(c("-", "*", "-"))))
 
170
 
 
171
## GRangesList object
 
172
gr1 <- GRanges(seqnames="chr2",
 
173
               ranges=IRanges(3, 6))
 
174
gr2 <- GRanges(seqnames=c("chr1", "chr1"),
 
175
               ranges=IRanges(c(7,13), width = 3),
 
176
               strand=c("+", "-"))
 
177
gr3 <- GRanges(seqnames=c("chr1", "chr2"),
 
178
               ranges=IRanges(c(1, 4), c(3, 9)),
 
179
               strand=c("-", "-"))
 
180
grlist <- GRangesList(gr1=gr1, gr2=gr2, gr3=gr3)
 
181
 
 
182
## Parallel intersection of a GRanges and a GRangesList object
 
183
pintersect(gr, grlist)
 
184
pintersect(grlist, gr)
 
185
 
 
186
## Parallel intersection of a GappedAlignments and a GRanges object
 
187
library(Rsamtools)  # because file ex1.bam is in this package
 
188
galn_file <- system.file("extdata", "ex1.bam", package="Rsamtools")
 
189
galn <- readGappedAlignments(galn_file)
 
190
pintersect(galn, shift(as(galn, "GRanges"), 6L))
 
191
 
 
192
## Parallel set difference of a GRanges and a GRangesList object
 
193
psetdiff(gr, grlist)
 
194
 
 
195
## Parallel set difference of two GRangesList objects
 
196
psetdiff(grlist, shift(grlist, 3))
 
197
}
 
198
 
 
199
\keyword{methods}
 
200
\keyword{utilities}