# Example report using bumphunter results

# 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: generics

    ##
    ## Attaching package: 'generics'

    ## The following objects are masked from 'package:base':
    ##
    ##     as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
    ##     setequal, union

    ##
    ## Attaching package: 'BiocGenerics'

    ## The following objects are masked from 'package:stats':
    ##
    ##     IQR, mad, sd, var, xtabs

    ## The following objects are masked from 'package:base':
    ##
    ##     anyDuplicated, aperm, append, as.data.frame, basename, cbind,
    ##     colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
    ##     get, grep, grepl, is.unsorted, lapply, Map, mapply, match, mget,
    ##     order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    ##     rbind, Reduce, rownames, sapply, saveRDS, table, tapply, unique,
    ##     unsplit, which.max, which.min

    ##
    ## Attaching package: 'S4Vectors'

    ## The following object is masked from 'package:utils':
    ##
    ##     findMatches

    ## The following objects are masked from 'package:base':
    ##
    ##     expand.grid, I, unname

    ## Loading required package: IRanges

    ## Loading required package: Seqinfo

    ## Loading required package: GenomicRanges

    ## Loading required package: foreach

    ## Loading required package: iterators

    ## Loading required package: parallel

    ## Loading required package: locfit

    ## locfit 1.5-9.12   2025-03-05

    ## 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.5.2).

    ## [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
    library(GenomeInfoDb)  # for getChromInfoFromUCSC()
    seqlengths(regions) <- seqlengths(
        getChromInfoFromUCSC("hg19", as.Seqinfo = TRUE)
    )[
        names(seqlengths(regions))
    ]

    ## Explore the regions
    regions

    ## GRanges object with 15 ranges and 5 metadata columns:
    ##        seqnames    ranges strand |     value      area   cluster         L
    ##           <Rle> <IRanges>  <Rle> | <numeric> <numeric> <numeric> <numeric>
    ##    [1]     chr1 2316-2631      * | -1.581475  15.81475         2        10
    ##    [2]     chr2   451-551      * |  1.589129   4.76739         3         3
    ##    [3]     chr1   456-526      * |  1.067883   3.20365         1         3
    ##    [4]     chr1 2176-2211      * |  0.784179   1.56836         2         2
    ##    [5]     chr1      2841      * |  1.201018   1.20102         2         1
    ##    ...      ...       ...    ... .       ...       ...       ...       ...
    ##   [11]     chr1       631      * |  0.618603  0.618603         1         1
    ##   [12]     chr1         1      * |  0.609609  0.609609         1         1
    ##   [13]     chr1      2911      * | -0.576423  0.576423         2         1
    ##   [14]     chr2       251      * | -0.556160  0.556160         3         1
    ##   [15]     chr1      2806      * | -0.521606  0.521606         2         1
    ##         clusterL
    ##        <integer>
    ##    [1]        29
    ##    [2]        20
    ##    [3]        29
    ##    [4]        29
    ##    [5]        29
    ##    ...       ...
    ##   [11]        29
    ##   [12]        29
    ##   [13]        29
    ##   [14]        20
    ##   [15]        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")

    ## Now create the report
    report <- renderReport(regions, "Example bumphunter",
        pvalueVars = NULL,
        densityVars = c(
            "Area" = "area", "Value" = "value",
            "Cluster Length" = "clusterL"
        ), significantVar = NULL,
        output = "bumphunter-example", outdir = "bumphunter-example",
        device = "png"
    )

You can view the final report at `bumphunter-example/bumphunter-example.html` or here.

In case the link does not work, a pre-compiled version of this document and its corresponding report are available at leekgroup.github.io/regionReportSupp/.

# Reproducibility

    ## Date generated:
    Sys.time()

    ## [1] "2026-05-01 09:42:24 UTC"

    ## Time spent making this page:
    proc.time()

    ##    user  system elapsed
    ##  11.573   0.913  12.269

    ## R and packages info:
    options(width = 120)
    sessioninfo::session_info()

    ## ─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
    ##  setting  value
    ##  version  R version 4.6.0 (2026-04-24)
    ##  os       Ubuntu 24.04.4 LTS
    ##  system   x86_64, linux-gnu
    ##  ui       X11
    ##  language (EN)
    ##  collate  en_US.UTF-8
    ##  ctype    en_US.UTF-8
    ##  tz       Etc/UTC
    ##  date     2026-05-01
    ##  pandoc   3.8.3 @ /usr/local/bin/ (via rmarkdown)
    ##  quarto   1.9.37 @ /usr/local/bin/quarto
    ##
    ## ─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
    ##  package              * version   date (UTC) lib source
    ##  abind                  1.4-8     2024-09-12 [2] RSPM (R 4.6.0)
    ##  AnnotationDbi          1.74.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  backports              1.5.1     2026-04-03 [2] RSPM (R 4.6.0)
    ##  base64enc              0.1-6     2026-02-02 [2] RSPM (R 4.6.0)
    ##  bibtex                 0.5.2     2026-02-03 [2] RSPM (R 4.6.0)
    ##  Biobase                2.72.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  BiocGenerics         * 0.58.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  BiocIO                 1.22.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  BiocManager            1.30.27   2025-11-14 [2] RSPM (R 4.6.0)
    ##  BiocParallel           1.46.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  BiocStyle            * 2.40.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  Biostrings             2.80.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  bit                    4.6.0     2025-03-06 [2] RSPM (R 4.6.0)
    ##  bit64                  4.8.0     2026-04-21 [2] RSPM (R 4.6.0)
    ##  bitops                 1.0-9     2024-10-03 [2] RSPM (R 4.6.0)
    ##  blob                   1.3.0     2026-01-14 [2] RSPM (R 4.6.0)
    ##  BSgenome               1.80.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  bslib                  0.10.0    2026-01-26 [2] RSPM (R 4.6.0)
    ##  buildtools             1.0.0     2026-04-27 [3] local (/pkg)
    ##  bumphunter           * 1.54.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  cachem                 1.1.0     2024-05-16 [2] RSPM (R 4.6.0)
    ##  checkmate              2.3.4     2026-02-03 [2] RSPM (R 4.6.0)
    ##  cigarillo              1.2.0     2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  cli                    3.6.6     2026-04-09 [2] RSPM (R 4.6.0)
    ##  cluster                2.1.8.2   2026-02-05 [2] RSPM (R 4.6.0)
    ##  codetools              0.2-20    2024-03-31 [2] RSPM (R 4.6.0)
    ##  colorspace             2.1-2     2025-09-22 [2] RSPM (R 4.6.0)
    ##  crayon                 1.5.3     2024-06-20 [2] RSPM (R 4.6.0)
    ##  curl                   7.1.0     2026-04-22 [2] RSPM (R 4.6.0)
    ##  data.table             1.18.2.1  2026-01-27 [2] RSPM (R 4.6.0)
    ##  DBI                    1.3.0     2026-02-25 [2] RSPM (R 4.6.0)
    ##  DEFormats              1.40.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  DelayedArray           0.38.1    2026-04-29 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  derfinder              1.46.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  derfinderHelper        1.46.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  DESeq2                 1.52.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  dichromat              2.0-0.1   2022-05-02 [2] RSPM (R 4.6.0)
    ##  digest                 0.6.39    2025-11-19 [2] RSPM (R 4.6.0)
    ##  doRNG                  1.8.6.3   2026-02-05 [2] RSPM (R 4.6.0)
    ##  dplyr                  1.2.1     2026-04-03 [2] RSPM (R 4.6.0)
    ##  edgeR                  4.10.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  evaluate               1.0.5     2025-08-27 [2] RSPM (R 4.6.0)
    ##  farver                 2.1.2     2024-05-13 [2] RSPM (R 4.6.0)
    ##  fastmap                1.2.0     2024-05-15 [2] RSPM (R 4.6.0)
    ##  foreach              * 1.5.2     2022-02-02 [2] RSPM (R 4.6.0)
    ##  foreign                0.8-91    2026-01-29 [2] RSPM (R 4.6.0)
    ##  Formula                1.2-5     2023-02-24 [2] RSPM (R 4.6.0)
    ##  generics             * 0.1.4     2025-05-09 [2] RSPM (R 4.6.0)
    ##  GenomeInfoDb         * 1.48.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  GenomicAlignments      1.48.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  GenomicFeatures        1.64.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  GenomicFiles           1.48.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  GenomicRanges        * 1.64.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  ggplot2                4.0.3     2026-04-22 [2] RSPM (R 4.6.0)
    ##  glue                   1.8.1     2026-04-17 [2] RSPM (R 4.6.0)
    ##  gridExtra              2.3       2017-09-09 [2] RSPM (R 4.6.0)
    ##  gtable                 0.3.6     2024-10-25 [2] RSPM (R 4.6.0)
    ##  Hmisc                  5.2-5     2026-01-09 [2] RSPM (R 4.6.0)
    ##  htmlTable              2.5.0     2026-04-22 [2] RSPM (R 4.6.0)
    ##  htmltools              0.5.9     2025-12-04 [2] RSPM (R 4.6.0)
    ##  htmlwidgets            1.6.4     2023-12-06 [2] RSPM (R 4.6.0)
    ##  httr                   1.4.8     2026-02-13 [2] RSPM (R 4.6.0)
    ##  IRanges              * 2.46.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  iterators            * 1.0.14    2022-02-05 [2] RSPM (R 4.6.0)
    ##  jquerylib              0.1.4     2021-04-26 [2] RSPM (R 4.6.0)
    ##  jsonlite               2.0.0     2025-03-27 [2] RSPM (R 4.6.0)
    ##  KEGGREST               1.52.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  knitr                  1.51      2025-12-20 [2] RSPM (R 4.6.0)
    ##  knitrBootstrap         1.0.4     2025-12-08 [2] RSPM (R 4.6.0)
    ##  lattice                0.22-9    2026-02-09 [2] RSPM (R 4.6.0)
    ##  lifecycle              1.0.5     2026-01-08 [2] RSPM (R 4.6.0)
    ##  limma                  3.68.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  locfit               * 1.5-9.12  2025-03-05 [2] RSPM (R 4.6.0)
    ##  lubridate              1.9.5     2026-02-04 [2] RSPM (R 4.6.0)
    ##  magrittr               2.0.5     2026-04-04 [2] RSPM (R 4.6.0)
    ##  maketools              1.3.2     2025-01-25 [3] RSPM (R 4.6.0)
    ##  markdown               2.0       2025-03-23 [2] RSPM (R 4.6.0)
    ##  Matrix                 1.7-5     2026-03-21 [2] RSPM (R 4.6.0)
    ##  MatrixGenerics         1.24.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  matrixStats            1.5.0     2025-01-07 [2] RSPM (R 4.6.0)
    ##  memoise                2.0.1     2021-11-26 [2] RSPM (R 4.6.0)
    ##  nnet                   7.3-20    2025-01-01 [2] RSPM (R 4.6.0)
    ##  otel                   0.2.0     2025-08-29 [2] RSPM (R 4.6.0)
    ##  pillar                 1.11.1    2025-09-17 [2] RSPM (R 4.6.0)
    ##  pkgconfig              2.0.3     2019-09-22 [2] RSPM (R 4.6.0)
    ##  plyr                   1.8.9     2023-10-02 [2] RSPM (R 4.6.0)
    ##  png                    0.1-9     2026-03-15 [2] RSPM (R 4.6.0)
    ##  qvalue                 2.44.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  R6                     2.6.1     2025-02-15 [2] RSPM (R 4.6.0)
    ##  RColorBrewer           1.1-3     2022-04-03 [2] RSPM (R 4.6.0)
    ##  Rcpp                   1.1.1-1.1 2026-04-24 [2] RSPM (R 4.6.0)
    ##  RCurl                  1.98-1.18 2026-03-21 [2] RSPM (R 4.6.0)
    ##  RefManageR             1.4.0     2022-09-30 [2] RSPM (R 4.6.0)
    ##  regionReport         * 1.46.0    2026-04-28 [1] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  reshape2               1.4.5     2025-11-12 [2] RSPM (R 4.6.0)
    ##  restfulr               0.0.16    2025-06-27 [2] RSPM (R 4.6.0)
    ##  rjson                  0.2.23    2024-09-16 [2] RSPM (R 4.6.0)
    ##  rlang                  1.2.0     2026-04-06 [2] RSPM (R 4.6.0)
    ##  rmarkdown              2.31      2026-03-26 [2] RSPM (R 4.6.0)
    ##  rngtools               1.5.2     2021-09-20 [2] RSPM (R 4.6.0)
    ##  rpart                  4.1.27    2026-03-27 [2] RSPM (R 4.6.0)
    ##  Rsamtools              2.28.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  RSQLite                2.4.6     2026-02-06 [2] RSPM (R 4.6.0)
    ##  rstudioapi             0.18.0    2026-01-16 [2] RSPM (R 4.6.0)
    ##  rtracklayer            1.72.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  S4Arrays               1.12.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  S4Vectors            * 0.50.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  S7                     0.2.2     2026-04-22 [2] RSPM (R 4.6.0)
    ##  sass                   0.4.10    2025-04-11 [2] RSPM (R 4.6.0)
    ##  scales                 1.4.0     2025-04-24 [2] RSPM (R 4.6.0)
    ##  Seqinfo              * 1.2.0     2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  sessioninfo            1.2.3     2025-02-05 [2] RSPM (R 4.6.0)
    ##  SparseArray            1.12.1    2026-05-01 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  statmod                1.5.1     2025-10-09 [2] RSPM (R 4.6.0)
    ##  stringi                1.8.7     2025-03-27 [2] RSPM (R 4.6.0)
    ##  stringr                1.6.0     2025-11-04 [2] RSPM (R 4.6.0)
    ##  SummarizedExperiment   1.42.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  sys                    3.4.3     2024-10-04 [2] RSPM (R 4.6.0)
    ##  tibble                 3.3.1     2026-01-11 [2] RSPM (R 4.6.0)
    ##  tidyselect             1.2.1     2024-03-11 [2] RSPM (R 4.6.0)
    ##  timechange             0.4.0     2026-01-29 [2] RSPM (R 4.6.0)
    ##  UCSC.utils             1.8.0     2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  VariantAnnotation      1.58.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  vctrs                  0.7.3     2026-04-11 [2] RSPM (R 4.6.0)
    ##  xfun                   0.57      2026-03-20 [2] RSPM (R 4.6.0)
    ##  XML                    3.99-0.23 2026-03-20 [2] RSPM (R 4.6.0)
    ##  xml2                   1.5.2     2026-01-17 [2] RSPM (R 4.6.0)
    ##  XVector                0.52.0    2026-04-28 [2] https://bioc-release.r-universe.dev (R 4.6.0)
    ##  yaml                   2.3.12    2025-12-10 [2] RSPM (R 4.6.0)
    ##
    ##  [1] /tmp/RtmpuRgm72/Rinst1e849decd37
    ##  [2] /github/workspace/pkglib
    ##  [3] /usr/local/lib/R/site-library
    ##  [4] /usr/lib/R/site-library
    ##  [5] /usr/lib/R/library
    ##  * ── Packages attached to the search path.
    ##
    ## ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────