nrows <- 20; ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
rowRanges <- GRanges(rep(c("chr1", "chr2"), c(5, 15)),
IRanges(sample(1000L, 20), width=100),
strand=Rle(c("+", "-"), c(12, 8)))
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
row.names=LETTERS[1:6])
se0 <- SummarizedExperiment(assays=SimpleList(counts=counts),
rowRanges=rowRanges, colData=colData)
se1 <- shift(se0, 100)
res <- nearest(se0, se1)
res
stopifnot(identical(res, nearest(rowRanges(se0), rowRanges(se1))))
stopifnot(identical(res, nearest(se0, rowRanges(se1))))
stopifnot(identical(res, nearest(rowRanges(se0), se1)))
res <- nearest(se0) # missing subject
res
stopifnot(identical(res, nearest(rowRanges(se0))))
hits <- nearest(se0, se1, select="all")
hits
stopifnot(identical(
hits,
nearest(rowRanges(se0), rowRanges(se1), select="all")
))
stopifnot(identical(
hits,
nearest(se0, rowRanges(se1), select="all")
))
stopifnot(identical(
hits,
nearest(rowRanges(se0), se1, select="all")
))
Run the code above in your browser using DataLab