Skip to content

Commit

Permalink
- Add 'algorithm' arg to usage section.
Browse files Browse the repository at this point in the history
- Fix GIntervalTree broken example.
- Other minor tweaks.


git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/GenomicRanges@97360 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information
[email protected] committed Dec 4, 2014
1 parent dd99a67 commit aa9c0e8
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 71 deletions.
4 changes: 4 additions & 0 deletions R/findOverlaps-GIntervalTree-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ setMethod("findOverlaps", c("GenomicRanges", "GIntervalTree"),
Hits(q_hits, s_hits, q_len, s_len)
})

setMethod("countOverlaps", c("GenomicRanges", "GIntervalTree"),
countOverlaps.definition
)

3 changes: 2 additions & 1 deletion R/nearest-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
queryLength=as.integer(max(c(0, queryHits))),
subjectLength=as.integer(max(c(0, subjectHits))))
{
Hits(queryHits, subjectHits, queryLength, subjectLength)
o <- S4Vectors:::orderIntegerPairs(queryHits, subjectHits)
Hits(queryHits[o], subjectHits[o], queryLength, subjectLength)
}

.findPrecedeFollow_pmin <-
Expand Down
2 changes: 1 addition & 1 deletion man/GIntervalTree-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
\title{GIntervalTree objects}

\description{
The GRanges class is a container for the genomic locations and
The GIntervalTree class is a container for the genomic locations and
their associated annotations.
}

Expand Down
10 changes: 0 additions & 10 deletions man/GRanges-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
\alias{[,List,GenomicRanges-method}
\alias{[,list,GenomicRanges-method}
\alias{c,GenomicRanges-method}
\alias{tile,GenomicRanges-method}
\alias{window,GenomicRanges-method}

% $ and $<- methods:
Expand Down Expand Up @@ -331,15 +330,6 @@
elements are removed from the returned object if \code{drop} is
\code{TRUE}.
}
\item{}{
\code{tile(x, n, width)}: Splits \code{x} into a
\code{GRangesList}, each element of which corresponds to a tile,
or partition, of \code{x}. Specify the tile geometry with either
\code{n} or \code{width} (not both). Passing \code{n} creates
\code{n} tiles of approximately equal width, truncated by sequence
end, while passing \code{width} tiles the region with ranges of
the given width, again truncated by sequence end.
}
}
}

Expand Down
103 changes: 51 additions & 52 deletions man/findOverlaps-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
\alias{countOverlaps,GenomicRanges,Vector-method}
\alias{countOverlaps,Vector,GenomicRanges-method}
\alias{countOverlaps,GenomicRanges,GenomicRanges-method}
\alias{countOverlaps,GenomicRanges,GIntervalTree-method}
\alias{countOverlaps,GRangesList,Vector-method}
\alias{countOverlaps,Vector,GRangesList-method}
\alias{countOverlaps,GRangesList,GRangesList-method}
Expand Down Expand Up @@ -72,25 +73,29 @@

\usage{
\S4method{findOverlaps}{GenomicRanges,GenomicRanges}(query, subject,
maxgap = 0L, minoverlap = 1L,
type = c("any", "start", "end", "within", "equal"),
select = c("all", "first", "last", "arbitrary"),
ignore.strand = FALSE)
maxgap=0L, minoverlap=1L,
type=c("any", "start", "end", "within", "equal"),
select=c("all", "first", "last", "arbitrary"),
algorithm=c("nclist", "intervaltree"),
ignore.strand=FALSE)

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

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

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

\arguments{
Expand Down Expand Up @@ -141,7 +146,7 @@

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

For \code{countOverlaps} an integer vector containing the tabulated
query overlap hits.
Expand Down Expand Up @@ -174,49 +179,43 @@

\examples{
## GRanges object:
gr <-
GRanges(seqnames =
Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
ranges =
IRanges(1:10, width = 10:1, names = head(letters,10)),
strand =
Rle(strand(c("-", "+", "*", "+", "-")),
c(1, 2, 2, 3, 2)),
score = 1:10,
GC = seq(1, 0, length=10))
gr <- GRanges(
seqnames=Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)),
ranges=IRanges(1:10, width=10:1, names=head(letters,10)),
strand=Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)),
score=1:10,
GC=seq(1, 0, length=10)
)
gr

## GRangesList object:
gr1 <-
GRanges(seqnames = "chr2", ranges = IRanges(4:3, 6),
strand = "+", score = 5:4, GC = 0.45)
gr2 <-
GRanges(seqnames = c("chr1", "chr1"),
ranges = IRanges(c(7,13), width = 3),
strand = c("+", "-"), score = 3:4, GC = c(0.3, 0.5))
gr3 <-
GRanges(seqnames = c("chr1", "chr2"),
ranges = IRanges(c(1, 4), c(3, 9)),
strand = c("-", "-"), score = c(6L, 2L), GC = c(0.4, 0.1))
grl <- GRangesList("gr1" = gr1, "gr2" = gr2, "gr3" = gr3)
gr1 <- GRanges(seqnames="chr2", ranges=IRanges(4:3, 6),
strand="+", score=5:4, GC=0.45)
gr2 <- GRanges(seqnames=c("chr1", "chr1"),
ranges=IRanges(c(7,13), width=3),
strand=c("+", "-"), score=3:4, GC=c(0.3, 0.5))
gr3 <- GRanges(seqnames=c("chr1", "chr2"),
ranges=IRanges(c(1, 4), c(3, 9)),
strand=c("-", "-"), score=c(6L, 2L), GC=c(0.4, 0.1))
grl <- GRangesList("gr1"=gr1, "gr2"=gr2, "gr3"=gr3)

## Overlapping two GRanges objects:
table(!is.na(findOverlaps(gr, gr1, select="arbitrary")))
countOverlaps(gr, gr1)
findOverlaps(gr, gr1)
subsetByOverlaps(gr, gr1)

countOverlaps(gr, gr1, type = "start")
findOverlaps(gr, gr1, type = "start")
subsetByOverlaps(gr, gr1, type = "start")
countOverlaps(gr, gr1, type="start")
findOverlaps(gr, gr1, type="start")
subsetByOverlaps(gr, gr1, type="start")

findOverlaps(gr, gr1, select = "first")
findOverlaps(gr, gr1, select = "last")
findOverlaps(gr, gr1, select="first")
findOverlaps(gr, gr1, select="last")

findOverlaps(gr1, gr)
findOverlaps(gr1, gr, type = "start")
findOverlaps(gr1, gr, type = "within")
findOverlaps(gr1, gr, type = "equal")
findOverlaps(gr1, gr, type="start")
findOverlaps(gr1, gr, type="within")
findOverlaps(gr1, gr, type="equal")

## using a GIntervalTree
gtree <- GIntervalTree(gr1)
Expand All @@ -230,20 +229,20 @@ table(!is.na(findOverlaps(grl, gr, select="first")))
countOverlaps(grl, gr)
findOverlaps(grl, gr)
subsetByOverlaps(grl, gr)
countOverlaps(grl, gr, type = "start")
findOverlaps(grl, gr, type = "start")
subsetByOverlaps(grl, gr, type = "start")
findOverlaps(grl, gr, select = "first")
countOverlaps(grl, gr, type="start")
findOverlaps(grl, gr, type="start")
subsetByOverlaps(grl, gr, type="start")
findOverlaps(grl, gr, select="first")

## using a GIntervalTree
table(!is.na(findOverlaps(grl, gtree, select="first")))
countOverlaps(grl, gtree)
findOverlaps(grl, gtree)
subsetByOverlaps(grl, gtree)
countOverlaps(grl, gtree, type = "start")
findOverlaps(grl, gtree, type = "start")
subsetByOverlaps(grl, gtree, type = "start")
findOverlaps(grl, gtree, select = "first")
countOverlaps(grl, gtree, type="start")
findOverlaps(grl, gtree, type="start")
subsetByOverlaps(grl, gtree, type="start")
findOverlaps(grl, gtree, select="first")

## Overlapping two GRangesList objects:
countOverlaps(grl, rev(grl))
Expand Down
12 changes: 6 additions & 6 deletions man/nearest-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
}

\usage{
\S4method{precede}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{precede}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{precede}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)
\S4method{precede}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)

\S4method{follow}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{follow}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{follow}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)
\S4method{follow}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)

\S4method{nearest}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{nearest}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE, ...)
\S4method{nearest}{GenomicRanges,GenomicRanges}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)
\S4method{nearest}{GenomicRanges,missing}(x, subject, select=c("arbitrary", "all"), ignore.strand=FALSE)

\S4method{distanceToNearest}{GenomicRanges,GenomicRanges}(x, subject, ignore.strand=FALSE, ...)
\S4method{distanceToNearest}{GenomicRanges,missing}(x, subject, ignore.strand=FALSE, ...)
Expand Down
11 changes: 10 additions & 1 deletion man/tile-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

\description{
\code{\link[IRanges]{tile}} method for
\link{GenomicRanges}. Partitions the each range into a set of
\link{GenomicRanges}. Partitions each range into a set of
tiles. Tiles are defined in terms of their number or width.
}

Expand All @@ -31,6 +31,15 @@
}
}

\details{
Splits \code{x} into a \code{GRangesList}, each element of which corresponds
to a tile, or partition, of \code{x}. Specify the tile geometry with either
\code{n} or \code{width} (not both). Passing \code{n} creates \code{n} tiles
of approximately equal width, truncated by sequence end, while passing
\code{width} tiles the region with ranges of the given width, again truncated
by sequence end.
}

\value{
A \code{GRangesList} object, each element of which corresponds to a tile.
}
Expand Down

0 comments on commit aa9c0e8

Please sign in to comment.