With the improvement of sequencing techniques, chromatin immunoprecipitation followed by high throughput sequencing (ChIP-Seq) is getting popular to study genome-wide protein-DNA interactions. To address the lack of powerful ChIP-Seq analysis method, we presented the Model-based Analysis of ChIP-Seq (MACS), for identifying transcript factor binding sites. MACS captures the influence of genome complexity to evaluate the significance of enriched ChIP regions and MACS improves the spatial resolution of binding sites through combining the information of both sequencing tag position and orientation. MACS can be easily used for ChIP-Seq data alone, or with a control sample with the increase of specificity. Moreover, as a general peak-caller, MACS can also be applied to any “DNA enrichment assays” if the question to be asked is simply: where we can find significant reads coverage than the random background.
This package is a wrapper of the MACS toolkit based on basilisk.
The package is built on basilisk. The dependent python library macs3 will be installed automatically inside its conda environment.
library(MACSr)
There are 13 functions imported from MACS3. Details of each function can be checked from its manual.
| Functions | Description |
|---|---|
callpeak |
Main MACS3 Function to call peaks from alignment results. |
bdgpeakcall |
Call peaks from bedGraph output. |
bdgbroadcall |
Call broad peaks from bedGraph output. |
bdgcmp |
Comparing two signal tracks in bedGraph format. |
bdgopt |
Operate the score column of bedGraph file. |
cmbreps |
Combine BEDGraphs of scores from replicates. |
bdgdiff |
Differential peak detection based on paired four bedGraph files. |
filterdup |
Remove duplicate reads, then save in BED/BEDPE format. |
predictd |
Predict d or fragment size from alignment results. |
pileup |
Pileup aligned reads (single-end) or fragments (paired-end) |
randsample |
Randomly choose a number/percentage of total reads. |
refinepeak |
Take raw reads alignment, refine peak summits. |
callvar |
Call variants in given peak regions from the alignment BAM files. |
hmmratac |
Dedicated peak calling based on Hidden Markov Model for ATAC-seq data. |
callpeakWe have uploaded multipe test datasets from MACS to a data package
MACSdata in the ExperimentHub. For example, Here we download a
pair of single-end bed files to run the callpeak function.
eh <- ExperimentHub::ExperimentHub()
eh <- AnnotationHub::query(eh, "MACSdata")
CHIP <- eh[["EH4558"]]
#> see ?MACSdata and browseVignettes('MACSdata') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache
CTRL <- eh[["EH4563"]]
#> see ?MACSdata and browseVignettes('MACSdata') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache
Here is an example to call narrow and broad peaks on the SE bed files.
cp1 <- callpeak(CHIP, CTRL, gsize = 5.2e7, store_bdg = TRUE,
name = "run_callpeak_narrow0", outdir = tempdir(),
cutoff_analysis = TRUE)
#> Using Python: /Users/biocbuild/.pyenv/versions/3.10.20/bin/python3.10
#> Creating virtual environment '/Users/biocbuild/Library/Caches/org.R-project.R/R/basilisk/1.25.0/MACSr/1.21.0/env_macs' ...
#> + /Users/biocbuild/.pyenv/versions/3.10.20/bin/python3.10 -m venv /Users/biocbuild/Library/Caches/org.R-project.R/R/basilisk/1.25.0/MACSr/1.21.0/env_macs
#> Done!
#> Installing packages: pip, wheel, setuptools
#> + /Users/biocbuild/Library/Caches/org.R-project.R/R/basilisk/1.25.0/MACSr/1.21.0/env_macs/bin/python -m pip install --upgrade pip wheel setuptools
#> Installing packages: 'macs3==3.0.2'
#> + /Users/biocbuild/Library/Caches/org.R-project.R/R/basilisk/1.25.0/MACSr/1.21.0/env_macs/bin/python -m pip install --upgrade --no-user 'macs3==3.0.2'
#> Virtual environment '/Users/biocbuild/Library/Caches/org.R-project.R/R/basilisk/1.25.0/MACSr/1.21.0/env_macs' successfully created.
#> INFO @ 18 May 2026 18:32:50: [689 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> # ChIP-seq file = ['/Users/biocbuild/Library/Caches/org.R-project.R/R/ExperimentHub/8a5cba7001f_4601']
#> # control file = ['/Users/biocbuild/Library/Caches/org.R-project.R/R/ExperimentHub/8a5cf8f933_4606']
#> # effective genome size = 5.20e+07
#> # band width = 300
#> # model fold = [5.0, 50.0]
#> # qvalue cutoff = 5.00e-02
#> # The maximum gap between significant sites is assigned as the read length/tag size.
#> # The minimum length of peaks is assigned as the predicted fragment length "d".
#> # Larger dataset will be scaled towards smaller dataset.
#> # Range for calculating regional lambda is: 1000 bps and 10000 bps
#> # Broad region calling is off
#> # Additional cutoff on fold-enrichment is: 0.10
#> # Paired-End mode is off
#>
#> INFO @ 18 May 2026 18:32:50: [689 MB] #1 read tag files...
#> INFO @ 18 May 2026 18:32:50: [689 MB] #1 read treatment tags...
#> INFO @ 18 May 2026 18:32:50: [691 MB] Detected format is: BED
#> INFO @ 18 May 2026 18:32:50: [691 MB] * Input file is gzipped.
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1.2 read input tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] Detected format is: BED
#> INFO @ 18 May 2026 18:32:50: [694 MB] * Input file is gzipped.
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tag size is determined as 101 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tag size = 101.0
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 total tags in treatment: 49622
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 user defined the maximum tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tags after filtering in treatment: 48047
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 Redundant rate of treatment: 0.03
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 total tags in control: 50837
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 user defined the maximum tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tags after filtering in control: 50783
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 Redundant rate of control: 0.00
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 finished!
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Build Peak Model...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 looking for paired plus/minus strand peaks...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Total number of paired peaks: 469
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Model building with cross-correlation: Done
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 finished!
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 predicted fragment length is 228 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 alternative fragment length(s) may be 228 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2.2 Generate R script for model : /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_model.r
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Call peaks...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Pre-compute pvalue-qvalue table...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Cutoff vs peaks called will be analyzed!
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Analysis of cutoff vs num of peaks or total length has been saved in b'/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_cutoff_analysis.txt'
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 In the peak calling step, the following will be performed simultaneously:
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Write bedGraph files for treatment pileup (after scaling if necessary)... run_callpeak_narrow0_treat_pileup.bdg
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Write bedGraph files for control lambda (after scaling if necessary)... run_callpeak_narrow0_control_lambda.bdg
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Pileup will be based on sequencing depth in treatment.
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Call peaks for each chromosome...
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write output xls file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.xls
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write peak in narrowPeak format file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.narrowPeak
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write summits bed file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_summits.bed
#> INFO @ 18 May 2026 18:32:51: [717 MB] Done!
cp2 <- callpeak(CHIP, CTRL, gsize = 5.2e7, store_bdg = TRUE,
name = "run_callpeak_broad", outdir = tempdir(),
broad = TRUE)
#>
Here are the outputs.
cp1
#> macsList class
#> $outputs:
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_control_lambda.bdg
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_cutoff_analysis.txt
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_model.r
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.narrowPeak
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.xls
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_summits.bed
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_treat_pileup.bdg
#> $arguments: tfile, cfile, gsize, outdir, name, store_bdg, cutoff_analysis
#> $log:
#> INFO @ 18 May 2026 18:32:50: [689 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> ...
cp2
#> macsList class
#> $outputs:
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_control_lambda.bdg
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_model.r
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_peaks.broadPeak
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_peaks.gappedPeak
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_peaks.xls
#> /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_broad_treat_pileup.bdg
#> $arguments: tfile, cfile, gsize, outdir, name, store_bdg, broad
#> $log:
#>
macsList classThe macsList is designed to contain everything of an execution,
including function, inputs, outputs and logs, for the purpose of
reproducibility.
For example, we can the function and input arguments.
cp1$arguments
#> [[1]]
#> callpeak
#>
#> $tfile
#> CHIP
#>
#> $cfile
#> CTRL
#>
#> $gsize
#> [1] 5.2e+07
#>
#> $outdir
#> tempdir()
#>
#> $name
#> [1] "run_callpeak_narrow0"
#>
#> $store_bdg
#> [1] TRUE
#>
#> $cutoff_analysis
#> [1] TRUE
The files of all the outputs are collected.
cp1$outputs
#> [1] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_control_lambda.bdg"
#> [2] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_cutoff_analysis.txt"
#> [3] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_model.r"
#> [4] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.narrowPeak"
#> [5] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.xls"
#> [6] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_summits.bed"
#> [7] "/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_treat_pileup.bdg"
The log is especially important for MACS to check. Detailed
information was given in the log when running.
cat(paste(cp1$log, collapse="\n"))
#> INFO @ 18 May 2026 18:32:50: [689 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> # ChIP-seq file = ['/Users/biocbuild/Library/Caches/org.R-project.R/R/ExperimentHub/8a5cba7001f_4601']
#> # control file = ['/Users/biocbuild/Library/Caches/org.R-project.R/R/ExperimentHub/8a5cf8f933_4606']
#> # effective genome size = 5.20e+07
#> # band width = 300
#> # model fold = [5.0, 50.0]
#> # qvalue cutoff = 5.00e-02
#> # The maximum gap between significant sites is assigned as the read length/tag size.
#> # The minimum length of peaks is assigned as the predicted fragment length "d".
#> # Larger dataset will be scaled towards smaller dataset.
#> # Range for calculating regional lambda is: 1000 bps and 10000 bps
#> # Broad region calling is off
#> # Additional cutoff on fold-enrichment is: 0.10
#> # Paired-End mode is off
#>
#> INFO @ 18 May 2026 18:32:50: [689 MB] #1 read tag files...
#> INFO @ 18 May 2026 18:32:50: [689 MB] #1 read treatment tags...
#> INFO @ 18 May 2026 18:32:50: [691 MB] Detected format is: BED
#> INFO @ 18 May 2026 18:32:50: [691 MB] * Input file is gzipped.
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1.2 read input tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] Detected format is: BED
#> INFO @ 18 May 2026 18:32:50: [694 MB] * Input file is gzipped.
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tag size is determined as 101 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tag size = 101.0
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 total tags in treatment: 49622
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 user defined the maximum tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tags after filtering in treatment: 48047
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 Redundant rate of treatment: 0.03
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 total tags in control: 50837
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 user defined the maximum tags...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 tags after filtering in control: 50783
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 Redundant rate of control: 0.00
#> INFO @ 18 May 2026 18:32:50: [694 MB] #1 finished!
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Build Peak Model...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 looking for paired plus/minus strand peaks...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Total number of paired peaks: 469
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 Model building with cross-correlation: Done
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 finished!
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 predicted fragment length is 228 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2 alternative fragment length(s) may be 228 bps
#> INFO @ 18 May 2026 18:32:50: [694 MB] #2.2 Generate R script for model : /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_model.r
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Call peaks...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Pre-compute pvalue-qvalue table...
#> INFO @ 18 May 2026 18:32:50: [694 MB] #3 Cutoff vs peaks called will be analyzed!
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Analysis of cutoff vs num of peaks or total length has been saved in b'/var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_cutoff_analysis.txt'
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 In the peak calling step, the following will be performed simultaneously:
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Write bedGraph files for treatment pileup (after scaling if necessary)... run_callpeak_narrow0_treat_pileup.bdg
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Write bedGraph files for control lambda (after scaling if necessary)... run_callpeak_narrow0_control_lambda.bdg
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Pileup will be based on sequencing depth in treatment.
#> INFO @ 18 May 2026 18:32:50: [715 MB] #3 Call peaks for each chromosome...
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write output xls file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.xls
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write peak in narrowPeak format file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_peaks.narrowPeak
#> INFO @ 18 May 2026 18:32:51: [717 MB] #4 Write summits bed file... /var/folders/r0/l4fjk6cj5xj0j3brt4bplpl40000gt/T//Rtmpic8gPx/run_callpeak_narrow0_summits.bed
#> INFO @ 18 May 2026 18:32:51: [717 MB] Done!
More details about MACS3 can be found: https://macs3-project.github.io/MACS/.
sessionInfo()
#> R version 4.6.0 Patched (2026-05-01 r89994)
#> Platform: aarch64-apple-darwin23
#> Running under: macOS Tahoe 26.3.1
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
#>
#> locale:
#> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> time zone: America/New_York
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] MACSdata_1.21.0 MACSr_1.21.0 BiocStyle_2.41.0
#>
#> loaded via a namespace (and not attached):
#> [1] rappdirs_0.3.4 sass_0.4.10 generics_0.1.4
#> [4] BiocVersion_3.24.0 RSQLite_3.52.0 lattice_0.22-9
#> [7] digest_0.6.39 magrittr_2.0.5 evaluate_1.0.5
#> [10] grid_4.6.0 bookdown_0.46 fastmap_1.2.0
#> [13] blob_1.3.0 AnnotationHub_4.3.0 jsonlite_2.0.0
#> [16] Matrix_1.7-5 AnnotationDbi_1.75.0 DBI_1.3.0
#> [19] BiocManager_1.30.27 httr_1.4.8 purrr_1.2.2
#> [22] Biostrings_2.81.1 httr2_1.2.2 jquerylib_0.1.4
#> [25] cli_3.6.6 crayon_1.5.3 rlang_1.2.0
#> [28] XVector_0.53.0 dbplyr_2.5.2 Biobase_2.73.1
#> [31] bit64_4.8.0 withr_3.0.2 cachem_1.1.0
#> [34] yaml_2.3.12 otel_0.2.0 tools_4.6.0
#> [37] dir.expiry_1.21.0 parallel_4.6.0 memoise_2.0.1
#> [40] dplyr_1.2.1 filelock_1.0.3 basilisk_1.25.0
#> [43] ExperimentHub_3.3.0 BiocGenerics_0.59.2 curl_7.1.0
#> [46] reticulate_1.46.0 vctrs_0.7.3 R6_2.6.1
#> [49] png_0.1-9 stats4_4.6.0 lifecycle_1.0.5
#> [52] BiocFileCache_3.3.0 Seqinfo_1.3.0 KEGGREST_1.53.0
#> [55] IRanges_2.47.1 S4Vectors_0.51.2 bit_4.6.0
#> [58] pkgconfig_2.0.3 bslib_0.11.0 pillar_1.11.1
#> [61] glue_1.8.1 Rcpp_1.1.1-1.1 xfun_0.57
#> [64] tibble_3.3.1 tidyselect_1.2.1 knitr_1.51
#> [67] htmltools_0.5.9 rmarkdown_2.31 compiler_4.6.0