Package version: regionReport 1.4.1

Contents

1 bumphunter example

The bumphunter package can be used for methylation analyses where you are interested in identifying differentially methylated regions. The vignette explains in greater detail the data set we are using in this example.

## Load bumphunter
library('bumphunter')
## Loading required package: S4Vectors
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## 
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## 
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, xtabs
## 
## The following objects are masked from 'package:base':
## 
##     Filter, Find, Map, Position, Reduce, anyDuplicated, append,
##     as.data.frame, as.vector, cbind, colnames, do.call,
##     duplicated, eval, evalq, get, grep, grepl, intersect,
##     is.unsorted, lapply, lengths, mapply, match, mget, order,
##     paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames,
##     sapply, setdiff, sort, table, tapply, union, unique, unlist,
##     unsplit
## 
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: GenomicRanges
## Loading required package: foreach
## Loading required package: iterators
## Loading required package: locfit
## locfit 1.5-9.1    2013-03-22
## Create data from the vignette
pos <- list(pos1=seq(1, 1000, 35),
            pos2=seq(2001, 3000, 35),
            pos3=seq(1, 1000, 50))
chr <- rep(paste0('chr', c(1, 1, 2)), times = sapply(pos, length))
pos <- unlist(pos, use.names = FALSE)

## Find clusters
cl <- clusterMaker(chr, pos, maxGap = 300)

## Build simulated bumps
Indexes <- split(seq_along(cl), cl)
beta1 <- rep(0, length(pos))
for(i in seq(along=Indexes)){
    ind <- Indexes[[i]]
    x <- pos[ind]
    z <- scale(x, median(x), max(x)/12)
    beta1[ind] <- i*(-1)^(i+1)*pmax(1-abs(z)^3,0)^3 ##multiply by i to vary size
}

## Build data
beta0 <- 3 * sin(2 * pi * pos / 720)
X <- cbind(rep(1, 20), rep(c(0, 1), each = 10))
set.seed(23852577)
error <- matrix(rnorm(20 * length(beta1), 0, 1), ncol = 20)
y <- t(X[, 1]) %x% beta0 + t(X[, 2]) %x% beta1 + error

## Perform bumphunting
tab <- bumphunter(y, X, chr, pos, cl, cutoff=.5)
## [bumphunterEngine] Using a single core (backend: doSEQ, version: 1.4.3).
## [bumphunterEngine] Computing coefficients.
## [bumphunterEngine] Finding regions.
## [bumphunterEngine] Found 15 bumps.
## Explore data
lapply(tab, head)
## $table
##     chr start  end      value       area cluster indexStart indexEnd  L
## 10 chr1  2316 2631 -1.5814747 15.8147473       2         39       48 10
## 7  chr2   451  551  1.5891293  4.7673878       3         68       70  3
## 2  chr1   456  526  1.0678828  3.2036485       1         14       16  3
## 5  chr1  2176 2211  0.7841794  1.5683589       2         35       36  2
## 6  chr1  2841 2841  1.2010184  1.2010184       2         54       54  1
## 4  chr1   771  771  0.7780902  0.7780902       1         23       23  1
##    clusterL
## 10       29
## 7        20
## 2        29
## 5        29
## 6        29
## 4        29
## 
## $coef
##             [,1]
## [1,]  0.60960932
## [2,] -0.09052769
## [3,] -0.21482638
## [4,]  0.13053755
## [5,] -0.21723642
## [6,]  0.39934961
## 
## $fitted
##             [,1]
## [1,]  0.60960932
## [2,] -0.09052769
## [3,] -0.21482638
## [4,]  0.13053755
## [5,] -0.21723642
## [6,]  0.39934961
## 
## $pvaluesMarginal
## [1] NA

Once we have the regions we can proceed to build the required GRanges object.

library('GenomicRanges')

## Build GRanges with sequence lengths
regions <- GRanges(seqnames = tab$table$chr, 
    IRanges(start = tab$table$start, end = tab$table$end),
    strand = '*', value = tab$table$value, area = tab$table$area, 
    cluster = tab$table$cluster, L = tab$table$L, clusterL = tab$table$clusterL)

## Assign chr lengths
data(hg19Ideogram, package = 'biovizBase')
seqlengths(regions) <- seqlengths(hg19Ideogram)[names(seqlengths(regions))]

## Explore the regions
regions
## GRanges object with 15 ranges and 5 metadata columns:
##        seqnames       ranges strand   |              value
##           <Rle>    <IRanges>  <Rle>   |          <numeric>
##    [1]     chr1 [2316, 2631]      *   |  -1.58147472668612
##    [2]     chr2 [ 451,  551]      *   |   1.58912926544627
##    [3]     chr1 [ 456,  526]      *   |   1.06788283103948
##    [4]     chr1 [2176, 2211]      *   |  0.784179442360784
##    [5]     chr1 [2841, 2841]      *   |   1.20101842543356
##    ...      ...          ...    ... ...                ...
##   [11]     chr1 [ 631,  631]      *   |  0.618602646982714
##   [12]     chr1 [   1,    1]      *   |  0.609609318450113
##   [13]     chr1 [2911, 2911]      *   | -0.576423040796044
##   [14]     chr2 [ 251,  251]      *   | -0.556159535339166
##   [15]     chr1 [2806, 2806]      *   | -0.521605772372843
##                     area   cluster         L  clusterL
##                <numeric> <numeric> <numeric> <integer>
##    [1]  15.8147472668612         2        10        29
##    [2]  4.76738779633882         3         3        20
##    [3]  3.20364849311844         1         3        29
##    [4]  1.56835888472157         2         2        29
##    [5]  1.20101842543356         2         1        29
##    ...               ...       ...       ...       ...
##   [11] 0.618602646982714         1         1        29
##   [12] 0.609609318450113         1         1        29
##   [13] 0.576423040796044         2         1        29
##   [14] 0.556159535339166         3         1        20
##   [15] 0.521605772372843         2         1        29
##   -------
##   seqinfo: 2 sequences from an unspecified genome

Now that we have identified a set of differentially methylated regions we can proceed to creating the HTML report. Note that this report has less information than the DiffBind example because we don’t have a p-value variable.

## Load regionReport
library('regionReport')
## Note: the specification for S3 class "AsIs" in package 'RJSONIO' seems equivalent to one from package 'BiocGenerics': not turning on duplicate class definitions for this class.
report <- renderReport(regions, 'Example bumphunter', pvalueVars = NULL,
    densityVars = c('Area' = 'area', 'Value' = 'value',
    'Cluster Length' = 'clusterL'), significantVar = NULL,
    output = 'bumphunterExampleOutput', outdir = '.', device = 'png')
## '/home/biocbuild/bbs-3.2-bioc/R/bin/R' --no-site-file --no-environ  \
##   --no-save --no-restore --quiet --file='bumphunterReport-isolated.R'  \
##   --slave

You can view the final report here.

2 Reproducibility

## Date generated:
Sys.time()
## [1] "2015-11-02 20:42:48 PST"
## Time spent making this page:
proc.time()
##    user  system elapsed 
## 143.673   0.945 144.788
## R and packages info:
options(width = 120)
devtools::session_info()
## Session info -----------------------------------------------------------------------------------------------------------
##  setting  value                       
##  version  R version 3.2.2 (2015-08-14)
##  system   x86_64, linux-gnu           
##  ui       X11                         
##  language en_US:                      
##  collate  C                           
##  tz       <NA>                        
##  date     2015-11-02
## Packages ---------------------------------------------------------------------------------------------------------------
##  package              * version  date       source        
##  AnnotationDbi          1.32.0   2015-11-03 Bioconductor  
##  BSgenome               1.38.0   2015-11-03 Bioconductor  
##  Biobase                2.30.0   2015-11-03 Bioconductor  
##  BiocGenerics         * 0.16.0   2015-11-03 Bioconductor  
##  BiocInstaller          1.20.0   2015-11-03 Bioconductor  
##  BiocParallel           1.4.0    2015-11-03 Bioconductor  
##  BiocStyle            * 1.8.0    2015-11-03 Bioconductor  
##  Biostrings             2.38.0   2015-11-03 Bioconductor  
##  DBI                    0.3.1    2014-09-24 CRAN (R 3.2.2)
##  Formula                1.2-1    2015-04-07 CRAN (R 3.2.2)
##  GGally                 0.5.0    2014-12-02 CRAN (R 3.2.2)
##  GenomeInfoDb         * 1.6.1    2015-11-03 Bioconductor  
##  GenomicAlignments      1.6.1    2015-11-03 Bioconductor  
##  GenomicFeatures        1.22.2   2015-11-03 Bioconductor  
##  GenomicFiles           1.6.0    2015-11-03 Bioconductor  
##  GenomicRanges        * 1.22.0   2015-11-03 Bioconductor  
##  Hmisc                  3.17-0   2015-09-21 CRAN (R 3.2.2)
##  IRanges              * 2.4.1    2015-11-03 Bioconductor  
##  MASS                   7.3-44   2015-08-30 CRAN (R 3.2.2)
##  Matrix                 1.2-2    2015-07-08 CRAN (R 3.2.2)
##  OrganismDbi            1.12.0   2015-11-03 Bioconductor  
##  R6                     2.1.1    2015-08-19 CRAN (R 3.2.2)
##  RBGL                   1.46.0   2015-11-03 Bioconductor  
##  RColorBrewer           1.1-2    2014-12-07 CRAN (R 3.2.2)
##  RCurl                  1.95-4.7 2015-06-30 CRAN (R 3.2.2)
##  RJSONIO                1.3-0    2014-07-28 CRAN (R 3.2.2)
##  RSQLite                1.0.0    2014-10-25 CRAN (R 3.2.2)
##  Rcpp                   0.12.1   2015-09-10 CRAN (R 3.2.2)
##  RefManageR             0.8.63   2015-06-09 CRAN (R 3.2.2)
##  Rsamtools              1.22.0   2015-11-03 Bioconductor  
##  S4Vectors            * 0.8.0    2015-11-03 Bioconductor  
##  SummarizedExperiment   1.0.0    2015-11-03 Bioconductor  
##  VariantAnnotation      1.16.3   2015-11-03 Bioconductor  
##  XML                    3.98-1.3 2015-06-30 CRAN (R 3.2.2)
##  XVector                0.10.0   2015-11-03 Bioconductor  
##  acepack                1.3-3.3  2014-11-24 CRAN (R 3.2.2)
##  bibtex                 0.4.0    2014-12-31 CRAN (R 3.2.2)
##  biomaRt                2.26.0   2015-11-03 Bioconductor  
##  biovizBase             1.18.0   2015-11-03 Bioconductor  
##  bitops                 1.0-6    2013-08-17 CRAN (R 3.2.2)
##  bumphunter           * 1.10.0   2015-11-03 Bioconductor  
##  cluster                2.0.3    2015-07-21 CRAN (R 3.2.2)
##  codetools              0.2-14   2015-07-15 CRAN (R 3.2.2)
##  colorspace             1.2-6    2015-03-11 CRAN (R 3.2.2)
##  derfinder              1.4.1    2015-11-03 Bioconductor  
##  derfinderHelper        1.4.1    2015-11-03 Bioconductor  
##  derfinderPlot          1.4.1    2015-11-03 Bioconductor  
##  devtools             * 1.9.1    2015-09-11 CRAN (R 3.2.2)
##  dichromat              2.0-0    2013-01-24 CRAN (R 3.2.2)
##  digest                 0.6.8    2014-12-31 CRAN (R 3.2.2)
##  doRNG                  1.6      2014-03-07 CRAN (R 3.2.2)
##  evaluate               0.8      2015-09-18 CRAN (R 3.2.2)
##  foreach              * 1.4.3    2015-10-13 CRAN (R 3.2.2)
##  foreign                0.8-66   2015-08-19 CRAN (R 3.2.2)
##  formatR                1.2.1    2015-09-18 CRAN (R 3.2.2)
##  futile.logger          1.4.1    2015-04-20 CRAN (R 3.2.2)
##  futile.options         1.0.0    2010-04-06 CRAN (R 3.2.2)
##  ggbio                  1.18.0   2015-11-03 Bioconductor  
##  ggplot2                1.0.1    2015-03-17 CRAN (R 3.2.2)
##  graph                  1.48.0   2015-11-03 Bioconductor  
##  gridExtra              2.0.0    2015-07-14 CRAN (R 3.2.2)
##  gtable                 0.1.2    2012-12-05 CRAN (R 3.2.2)
##  htmltools              0.2.6    2014-09-08 CRAN (R 3.2.2)
##  httr                   1.0.0    2015-06-25 CRAN (R 3.2.2)
##  iterators            * 1.0.8    2015-10-13 CRAN (R 3.2.2)
##  knitcitations          1.0.7    2015-10-28 CRAN (R 3.2.2)
##  knitr                  1.11     2015-08-14 CRAN (R 3.2.2)
##  knitrBootstrap         0.9.0    2013-10-17 CRAN (R 3.2.2)
##  lambda.r               1.1.7    2015-03-20 CRAN (R 3.2.2)
##  lattice                0.20-33  2015-07-14 CRAN (R 3.2.2)
##  latticeExtra           0.6-26   2013-08-15 CRAN (R 3.2.2)
##  limma                  3.26.1   2015-11-03 Bioconductor  
##  locfit               * 1.5-9.1  2013-04-20 CRAN (R 3.2.2)
##  lubridate              1.3.3    2013-12-31 CRAN (R 3.2.2)
##  magrittr               1.5      2014-11-22 CRAN (R 3.2.2)
##  markdown               0.7.7    2015-04-22 CRAN (R 3.2.2)
##  matrixStats            0.15.0   2015-10-27 CRAN (R 3.2.2)
##  memoise                0.2.1    2014-04-22 CRAN (R 3.2.2)
##  mgcv                   1.8-9    2015-10-30 CRAN (R 3.2.2)
##  munsell                0.4.2    2013-07-11 CRAN (R 3.2.2)
##  nlme                   3.1-122  2015-08-19 CRAN (R 3.2.2)
##  nnet                   7.3-11   2015-08-30 CRAN (R 3.2.2)
##  pkgmaker               0.22     2014-05-14 CRAN (R 3.2.2)
##  plyr                   1.8.3    2015-06-12 CRAN (R 3.2.2)
##  proto                  0.3-10   2012-12-22 CRAN (R 3.2.2)
##  qvalue                 2.2.0    2015-11-03 Bioconductor  
##  regionReport         * 1.4.1    2015-11-03 Bioconductor  
##  registry               0.3      2015-07-08 CRAN (R 3.2.2)
##  reshape                0.8.5    2014-04-23 CRAN (R 3.2.2)
##  reshape2               1.4.1    2014-12-06 CRAN (R 3.2.2)
##  rmarkdown              0.8.1    2015-10-10 CRAN (R 3.2.2)
##  rngtools               1.2.4    2014-03-06 CRAN (R 3.2.2)
##  rpart                  4.1-10   2015-06-29 CRAN (R 3.2.2)
##  rtracklayer            1.30.1   2015-11-03 Bioconductor  
##  scales                 0.3.0    2015-08-25 CRAN (R 3.2.2)
##  stringi                1.0-1    2015-10-22 CRAN (R 3.2.2)
##  stringr                1.0.0    2015-04-30 CRAN (R 3.2.2)
##  survival               2.38-3   2015-07-02 CRAN (R 3.2.2)
##  whisker                0.3-2    2013-04-28 CRAN (R 3.2.2)
##  xtable                 1.7-4    2014-09-12 CRAN (R 3.2.2)
##  yaml                   2.1.13   2014-06-12 CRAN (R 3.2.2)
##  zlibbioc               1.16.0   2015-11-03 Bioconductor