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.
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. |
callpeak
We 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)
#> + /github/home/.cache/R/basilisk/1.19.0/0/bin/conda create --yes --prefix /github/home/.cache/R/basilisk/1.19.0/MACSr/1.15.0/env_macs 'python=3.10' --quiet -c conda-forge --override-channels
#> + /github/home/.cache/R/basilisk/1.19.0/0/bin/conda install --yes --prefix /github/home/.cache/R/basilisk/1.19.0/MACSr/1.15.0/env_macs 'python=3.10' -c conda-forge --override-channels
#> + /github/home/.cache/R/basilisk/1.19.0/0/bin/conda install --yes --prefix /github/home/.cache/R/basilisk/1.19.0/MACSr/1.15.0/env_macs -c conda-forge 'python=3.10' 'python=3.10' --override-channels
#> INFO @ 28 Jan 2025 07:31:54: [572 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> # ChIP-seq file = ['/github/home/.cache/R/ExperimentHub/133f63a86c0b_4601']
#> # control file = ['/github/home/.cache/R/ExperimentHub/133f314bb087_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 @ 28 Jan 2025 07:31:54: [572 MB] #1 read tag files...
#> INFO @ 28 Jan 2025 07:31:54: [572 MB] #1 read treatment tags...
#> INFO @ 28 Jan 2025 07:31:54: [576 MB] Detected format is: BED
#> INFO @ 28 Jan 2025 07:31:54: [576 MB] * Input file is gzipped.
#> INFO @ 28 Jan 2025 07:31:54: [583 MB] #1.2 read input tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] Detected format is: BED
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] * Input file is gzipped.
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tag size is determined as 101 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tag size = 101.0
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 total tags in treatment: 49622
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 user defined the maximum tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tags after filtering in treatment: 48047
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 Redundant rate of treatment: 0.03
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 total tags in control: 50837
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 user defined the maximum tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tags after filtering in control: 50783
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 Redundant rate of control: 0.00
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 finished!
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Build Peak Model...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 looking for paired plus/minus strand peaks...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Total number of paired peaks: 469
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Model building with cross-correlation: Done
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 finished!
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 predicted fragment length is 228 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 alternative fragment length(s) may be 228 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2.2 Generate R script for model : /tmp/RtmpIffkcR/run_callpeak_narrow0_model.r
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Call peaks...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Pre-compute pvalue-qvalue table...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Cutoff vs peaks called will be analyzed!
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Analysis of cutoff vs num of peaks or total length has been saved in b'/tmp/RtmpIffkcR/run_callpeak_narrow0_cutoff_analysis.txt'
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 In the peak calling step, the following will be performed simultaneously:
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Write bedGraph files for treatment pileup (after scaling if necessary)... run_callpeak_narrow0_treat_pileup.bdg
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Write bedGraph files for control lambda (after scaling if necessary)... run_callpeak_narrow0_control_lambda.bdg
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Pileup will be based on sequencing depth in treatment.
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Call peaks for each chromosome...
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write output xls file... /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.xls
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write peak in narrowPeak format file... /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.narrowPeak
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write summits bed file... /tmp/RtmpIffkcR/run_callpeak_narrow0_summits.bed
#> INFO @ 28 Jan 2025 07:31:55: [599 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:
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_control_lambda.bdg
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_cutoff_analysis.txt
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_model.r
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.narrowPeak
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.xls
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_summits.bed
#> /tmp/RtmpIffkcR/run_callpeak_narrow0_treat_pileup.bdg
#> $arguments: tfile, cfile, gsize, outdir, name, store_bdg, cutoff_analysis
#> $log:
#> INFO @ 28 Jan 2025 07:31:54: [572 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> ...
cp2
#> macsList class
#> $outputs:
#> /tmp/RtmpIffkcR/run_callpeak_broad_control_lambda.bdg
#> /tmp/RtmpIffkcR/run_callpeak_broad_model.r
#> /tmp/RtmpIffkcR/run_callpeak_broad_peaks.broadPeak
#> /tmp/RtmpIffkcR/run_callpeak_broad_peaks.gappedPeak
#> /tmp/RtmpIffkcR/run_callpeak_broad_peaks.xls
#> /tmp/RtmpIffkcR/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] "/tmp/RtmpIffkcR/run_callpeak_narrow0_control_lambda.bdg"
#> [2] "/tmp/RtmpIffkcR/run_callpeak_narrow0_cutoff_analysis.txt"
#> [3] "/tmp/RtmpIffkcR/run_callpeak_narrow0_model.r"
#> [4] "/tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.narrowPeak"
#> [5] "/tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.xls"
#> [6] "/tmp/RtmpIffkcR/run_callpeak_narrow0_summits.bed"
#> [7] "/tmp/RtmpIffkcR/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 @ 28 Jan 2025 07:31:54: [572 MB]
#> # Command line:
#> # ARGUMENTS LIST:
#> # name = run_callpeak_narrow0
#> # format = AUTO
#> # ChIP-seq file = ['/github/home/.cache/R/ExperimentHub/133f63a86c0b_4601']
#> # control file = ['/github/home/.cache/R/ExperimentHub/133f314bb087_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 @ 28 Jan 2025 07:31:54: [572 MB] #1 read tag files...
#> INFO @ 28 Jan 2025 07:31:54: [572 MB] #1 read treatment tags...
#> INFO @ 28 Jan 2025 07:31:54: [576 MB] Detected format is: BED
#> INFO @ 28 Jan 2025 07:31:54: [576 MB] * Input file is gzipped.
#> INFO @ 28 Jan 2025 07:31:54: [583 MB] #1.2 read input tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] Detected format is: BED
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] * Input file is gzipped.
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tag size is determined as 101 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tag size = 101.0
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 total tags in treatment: 49622
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 user defined the maximum tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tags after filtering in treatment: 48047
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 Redundant rate of treatment: 0.03
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 total tags in control: 50837
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 user defined the maximum tags...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 filter out redundant tags at the same location and the same strand by allowing at most 1 tag(s)
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 tags after filtering in control: 50783
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 Redundant rate of control: 0.00
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #1 finished!
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Build Peak Model...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 looking for paired plus/minus strand peaks...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Total number of paired peaks: 469
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 Model building with cross-correlation: Done
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 finished!
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 predicted fragment length is 228 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2 alternative fragment length(s) may be 228 bps
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #2.2 Generate R script for model : /tmp/RtmpIffkcR/run_callpeak_narrow0_model.r
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Call peaks...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Pre-compute pvalue-qvalue table...
#> INFO @ 28 Jan 2025 07:31:55: [583 MB] #3 Cutoff vs peaks called will be analyzed!
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Analysis of cutoff vs num of peaks or total length has been saved in b'/tmp/RtmpIffkcR/run_callpeak_narrow0_cutoff_analysis.txt'
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 In the peak calling step, the following will be performed simultaneously:
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Write bedGraph files for treatment pileup (after scaling if necessary)... run_callpeak_narrow0_treat_pileup.bdg
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Write bedGraph files for control lambda (after scaling if necessary)... run_callpeak_narrow0_control_lambda.bdg
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Pileup will be based on sequencing depth in treatment.
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #3 Call peaks for each chromosome...
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write output xls file... /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.xls
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write peak in narrowPeak format file... /tmp/RtmpIffkcR/run_callpeak_narrow0_peaks.narrowPeak
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] #4 Write summits bed file... /tmp/RtmpIffkcR/run_callpeak_narrow0_summits.bed
#> INFO @ 28 Jan 2025 07:31:55: [599 MB] Done!
More details about MACS3
can be found: https://macs3-project.github.io/MACS/.
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] MACSdata_1.14.0 MACSr_1.15.0 BiocStyle_2.35.0
#>
#> loaded via a namespace (and not attached):
#> [1] KEGGREST_1.47.0 dir.expiry_1.15.0 xfun_0.50
#> [4] bslib_0.8.0 Biobase_2.67.0 lattice_0.22-6
#> [7] vctrs_0.6.5 tools_4.4.2 generics_0.1.3
#> [10] stats4_4.4.2 curl_6.2.0 parallel_4.4.2
#> [13] tibble_3.2.1 AnnotationDbi_1.69.0 RSQLite_2.3.9
#> [16] blob_1.2.4 pkgconfig_2.0.3 Matrix_1.7-2
#> [19] dbplyr_2.5.0 S4Vectors_0.45.2 lifecycle_1.0.4
#> [22] GenomeInfoDbData_1.2.13 compiler_4.4.2 Biostrings_2.75.3
#> [25] GenomeInfoDb_1.43.4 htmltools_0.5.8.1 sys_3.4.3
#> [28] buildtools_1.0.0 sass_0.4.9 yaml_2.3.10
#> [31] pillar_1.10.1 crayon_1.5.3 jquerylib_0.1.4
#> [34] cachem_1.1.0 mime_0.12 ExperimentHub_2.15.0
#> [37] AnnotationHub_3.15.0 basilisk_1.19.0 tidyselect_1.2.1
#> [40] digest_0.6.37 dplyr_1.1.4 purrr_1.0.2
#> [43] BiocVersion_3.21.1 maketools_1.3.1 fastmap_1.2.0
#> [46] grid_4.4.2 cli_3.6.3 magrittr_2.0.3
#> [49] withr_3.0.2 filelock_1.0.3 UCSC.utils_1.3.1
#> [52] rappdirs_0.3.3 bit64_4.6.0-1 rmarkdown_2.29
#> [55] XVector_0.47.2 httr_1.4.7 bit_4.5.0.1
#> [58] reticulate_1.40.0 png_0.1-8 memoise_2.0.1
#> [61] evaluate_1.0.3 knitr_1.49 IRanges_2.41.2
#> [64] basilisk.utils_1.19.0 BiocFileCache_2.15.1 rlang_1.1.5
#> [67] Rcpp_1.0.14 glue_1.8.0 DBI_1.2.3
#> [70] BiocManager_1.30.25 BiocGenerics_0.53.5 jsonlite_1.8.9
#> [73] R6_2.5.1