################################################### ### chunk number 1: options ################################################### #line 40 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" options(width=72) ################################################### ### chunk number 2: biocLite eval=FALSE ################################################### ## #line 66 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" ## source("http://bioconductor.org/biocLite.R") ## biocLite("GenomicRanges") ################################################### ### chunk number 3: initialize ################################################### #line 70 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" library(GenomicRanges) ################################################### ### chunk number 4: example-GRanges ################################################### #line 83 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" gr <- GRanges(seqnames = Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)), ranges = IRanges(1:10, end = 7:16, names = head(letters, 10)), strand = Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)), score = 1:10, GC = seq(1, 0, length=10)) gr ################################################### ### chunk number 5: GRanges-location-accessors ################################################### #line 112 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" seqnames(gr) ranges(gr) strand(gr) ################################################### ### chunk number 6: metadataAccess ################################################### #line 122 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" elementMetadata(gr)[,"score"] values(gr) ################################################### ### chunk number 7: setSeqLengths ################################################### #line 131 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" seqlengths(gr) <- c(249250621,243199373,198022430) ################################################### ### chunk number 8: setSeqLengths2 ################################################### #line 136 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" seqlengths(gr) ################################################### ### chunk number 9: names ################################################### #line 143 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" names(gr) length(gr) ################################################### ### chunk number 10: splitAppendGRanges ################################################### #line 155 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" sp <- split(gr, rep(1:2, each=5)) sp ################################################### ### chunk number 11: combine ################################################### #line 163 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" c(sp[[1]], sp[[2]]) ################################################### ### chunk number 12: subset1 ################################################### #line 172 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" gr[2:3] ################################################### ### chunk number 13: subset2 ################################################### #line 180 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" gr[2:3, "GC"] ################################################### ### chunk number 14: assign1 ################################################### #line 188 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" singles <- split(gr) grMod <- gr grMod[2] <- singles[[1]] head(grMod, n=3) ################################################### ### chunk number 15: assign2 ################################################### #line 198 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" grMod[2,1] <- singles[[3]][,1] head(grMod, n=3) ################################################### ### chunk number 16: other ################################################### #line 206 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" rep(singles[[2]], times = 3) rev(gr) head(gr,n=2) tail(gr,n=2) window(gr, start=2,end=4) seqselect(gr, start=c(2,7), end=c(3,9)) ################################################### ### chunk number 17: IRangesStuff ################################################### #line 222 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" g <- gr[1:3] g <- append(g, singles[[10]]) start(g) end(g) width(g) range(g) ################################################### ### chunk number 18: flank ################################################### #line 237 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" flank(g, 10) ################################################### ### chunk number 19: flank2 ################################################### #line 243 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" flank(g, 10, start=FALSE) ################################################### ### chunk number 20: shiftAndResize ################################################### #line 253 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" shift(g, 5) resize(g, 30) ################################################### ### chunk number 21: reduce ################################################### #line 261 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" reduce(g) ################################################### ### chunk number 22: gaps ################################################### #line 270 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" gaps(g) ################################################### ### chunk number 23: disjoin ################################################### #line 278 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" disjoin(g) ################################################### ### chunk number 24: coverage ################################################### #line 287 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" coverage(g) ################################################### ### chunk number 25: intervals1 ################################################### #line 299 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" g2 <- head(gr, n=2) union(g, g2) intersect(g, g2) setdiff(g, g2) ################################################### ### chunk number 26: intervals2 ################################################### #line 314 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" g3 <- g[1:2] ranges(g3[1]) <- IRanges(start=5, end=12) punion(g2, g3) pintersect(g2, g3) psetdiff(g2, g3) ################################################### ### chunk number 27: manPage eval=FALSE ################################################### ## #line 325 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" ## ?GRanges ################################################### ### chunk number 28: example-GRangesList ################################################### #line 341 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" gr1 <- GRanges(seqnames = "chr2", ranges = IRanges(3, 6), strand = "+", score = 5L, 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)) grl <- GRangesList("txA" = gr1, "txB" = gr2) grl ################################################### ### chunk number 29: basicGRLAccessors ################################################### #line 374 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" seqnames(grl) ranges(grl) strand(grl) ################################################### ### chunk number 30: exceptions ################################################### #line 384 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" length(grl) names(grl) seqlengths(grl) ################################################### ### chunk number 31: elementLengths ################################################### #line 396 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" elementLengths(grl) ################################################### ### chunk number 32: isEmpty ################################################### #line 403 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" isEmpty(grl) ################################################### ### chunk number 33: elementMetadataGRL ################################################### #line 413 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" elementMetadata(grl) <- c("Transcript A","Transcript B") elementMetadata(grl) values(grl) ################################################### ### chunk number 34: unlistGRL ################################################### #line 426 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" ul <- unlist(grl) ################################################### ### chunk number 35: intOpsGRL ################################################### #line 447 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" start(grl) end(grl) width(grl) ################################################### ### chunk number 36: coverageGRL ################################################### #line 458 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" shift(grl, 20) coverage(grl) ################################################### ### chunk number 37: subsetGRL eval=FALSE ################################################### ## #line 471 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" ## grl[1] ## grl[[1]] ## grl["txA"] ## grl$txB ################################################### ### chunk number 38: subsetGRL2 ################################################### #line 482 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" grl[1, "score"] grl["txB", "GC"] ################################################### ### chunk number 39: otherSubsetGRL ################################################### #line 493 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" rep(grl[[1]], times = 3) rev(grl) head(grl, n=1) tail(grl, n=1) window(grl, start=1, end=1) seqselect(grl, start=2, end=2) ################################################### ### chunk number 40: lapply ################################################### #line 516 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" lapply(grl, length) sapply(grl, length) ################################################### ### chunk number 41: mapply ################################################### #line 527 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" grl2 <- shift(grl, 10) names(grl2) <- c("shiftTxA", "shiftTxB") mapply(c, grl, grl2) Map(c, grl, grl2) ################################################### ### chunk number 42: endoapply ################################################### #line 542 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" endoapply(grl,rev) ################################################### ### chunk number 43: mendoapply ################################################### #line 549 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" mendoapply(c,grl,grl2) ################################################### ### chunk number 44: ReduceGRL ################################################### #line 559 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" Reduce(c,grl) ################################################### ### chunk number 45: manPage2 eval=FALSE ################################################### ## #line 566 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" ## ?GRangesList ################################################### ### chunk number 46: findOverlaps ################################################### #line 581 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" mtch <- findOverlaps(gr, grl) matchMatrix(mtch) ################################################### ### chunk number 47: countOL ################################################### #line 596 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" countOverlaps(gr, grl) ################################################### ### chunk number 48: subsetByOverlaps ################################################### #line 604 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" subsetByOverlaps(gr,grl) ################################################### ### chunk number 49: match ################################################### #line 611 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" match(gr,grl) match(grl,gr) gr %in% grl grl %in% gr ################################################### ### chunk number 50: readGappedAlignments ################################################### #line 657 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" library(Rsamtools) aln1_file <- system.file("extdata", "ex1.bam", package="Rsamtools") aln1 <- readGappedAlignments(aln1_file) aln1 length(aln1) ################################################### ### chunk number 51: accessors ################################################### #line 682 "vignettes/GenomicRanges/inst/doc/GenomicRangesIntroduction.Rnw" head(rname(aln1)) seqlevels(aln1) head(strand(aln1)) head(cigar(aln1)) head(qwidth(aln1)) head(start(aln1)) head(end(aln1)) head(width(aln1)) head(ngap(aln1))