# Chapter 1 Welcome

## 1.1 Introduction

Chromatin immunoprecipitation with sequencing (ChIP-seq) is a widely used technique for identifying the genomic binding sites of a target protein. Conventional analyses of ChIP-seq data aim to detect absolute binding (i.e., the presence or absence of a binding site) based on peaks in the read coverage. An alternative analysis strategy is to detect of changes in the binding profile between conditions (Ross-Innes et al. 2012; Pal et al. 2013). These differential binding (DB) analyses involve counting reads into genomic intervals and testing those counts for significant differences between conditions. This defines a set of putative DB regions for further examination. DB analyses are statistically easier to perform than their conventional counterparts, as the effect of genomic biases is largely mitigated when counts for different libraries are compared at the same genomic region. DB regions may also be more relevant as the change in binding can be associated with the biological difference between conditions.

This book describes the use of the csaw Bioconductor package to detect differential binding (DB) in ChIP-seq experiments with sliding windows (Lun and Smyth 2016). In these analyses, we detect and summarize DB regions between conditions in a de novo manner, i.e., without making any prior assumptions about the location or width of bound regions. We demonstrate on data from a variety of real studies focusing on changes in transcription factor binding and histone mark enrichment. Our aim is to facilitate the practical implementation of window-based DB analyses by providing detailed code and expected output. The code here can be adapted to any dataset with multiple experimental conditions and with multiple biological samples within one or more of the conditions; it is similarly straightforward to accommodate batch effects, covariates and additional experimental factors. Indeed, though the book focuses on ChIP-seq, the same software can be adapted to data from any sequencing technique where reads represent coverage of enriched genomic regions.

## 1.2 How to read this book

The descriptions in this book explore the theoretical and practical motivations behind each step of a csaw analysis. While all users are welcome to read it from start to finish, new users may prefer to examine the case studies presented in the later sections (Lun and Smyth 2015), which provides the important information in a more concise format. Experienced users (or those looking for some nighttime reading!) are more likely to benefit from the in-depth discussions in this document.

All of the workflows described here start from sorted and indexed BAM files in the chipseqDBData package. For application to user-specified data, the raw read sequences have to be aligned to the appropriate reference genome beforehand. Most aligners can be used for this purpose, but we have used Rsubread (Liao, Smyth, and Shi 2013) due to the convenience of its R interface. It is also recommended to mark duplicate reads using tools like Picard prior to starting the workflow.

The statistical methods described here are based upon those in the edgeR package (Robinson, McCarthy, and Smyth 2010). Knowledge of edgeR is useful but not a prerequesite for reading this guide.

## 1.3 How to get help

Most questions about csaw should be answered by the documentation. Every function mentioned in this guide has its own help page. For example, a detailed description of the arguments and output of the windowCounts() function can be obtained by typing ?windowCounts or help(windowCounts) at the R prompt. Further detail on the methods or the underlying theory can be found in the references at the bottom of each help page.

The authors of the package always appreciate receiving reports of bugs in the package functions or in the documentation. The same goes for well-considered suggestions for improvements. Other questions about how to use csaw are best sent to the Bioconductor support site. Please send requests for general assistance and advice to the support site, rather than to the individual authors. Users posting to the support site for the first time may find it helpful to read the posting guide.

## 1.4 How to cite this book

Most users of csaw should cite the following in any publications:

A. T. Lun and G. K. Smyth. csaw: a Bioconductor package for differential binding analysis of ChIP-seq data using sliding windows. Nucleic Acids Res., 44(5):e45, Mar 2016

To cite the workflows specifically, we can use:

A. T. L. Lun and G. K. Smyth. From reads to regions: a Bioconductor workflow to detect differential binding in ChIP-seq data. F1000Research, 4, 2015

For people interested in combined $$p$$-values, their use in DB analyses was proposed in:

A. T. Lun and G. K. Smyth. De novo detection of differentially bound regions for ChIP-seq data using peaks and windows: controlling error rates correctly. Nucleic Acids Res., 42(11):e95, Jul 2014

The DB analyses shown here use methods from the edgeR package, which has its own citation recommendations. See the appropriate section of the edgeR user’s guide for more details.

## 1.5 Quick start

A typical ChIP-seq analysis in csaw would look something like that described below. This assumes that a vector of file paths to sorted and indexed BAM files is provided in and a design matrix in supplied in . The code is split across several steps:

library(chipseqDBData)
tf.data <- head(tf.data, -1) # skip the input.
bam.files <- tf.data$Path cell.type <- sub("NF-YA ([^ ]+) .*", "\\1", tf.data$Description)
design <- model.matrix(~factor(cell.type))
colnames(design) <- c("intercept", "cell.type")

library(csaw)
data <- windowCounts(bam.files, ext=110, width=10, param=param)
2. Filtering out uninteresting regions.

binned <- windowCounts(bam.files, bin=TRUE, width=10000, param=param)
keep <- filterWindowsGlobal(data, binned)$filter > log2(5) data <- data[keep,] 3. Calculating normalization factors. data <- normFactors(binned, se.out=data) 4. Identifying DB windows. library(edgeR) y <- asDGEList(data) y <- estimateDisp(y, design) fit <- glmQLFit(y, design, robust=TRUE) results <- glmQLFTest(fit) 5. Correcting for multiple testing. merged <- mergeResults(data, results$table, tol=1000L)

## Session information

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
[3] LC_TIME=en_GB              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
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] edgeR_3.36.0                limma_3.50.0
[3] csaw_1.28.0                 SummarizedExperiment_1.24.0
[5] Biobase_2.54.0              MatrixGenerics_1.6.0
[7] matrixStats_0.61.0          GenomicRanges_1.46.0
[9] GenomeInfoDb_1.30.0         IRanges_2.28.0
[11] S4Vectors_0.32.2            BiocGenerics_0.40.0
[13] chipseqDBData_1.10.0        BiocStyle_2.22.0

loaded via a namespace (and not attached):
[1] bitops_1.0-7                  bit64_4.0.5
[3] filelock_1.0.2                httr_1.4.2
[5] tools_4.1.2                   bslib_0.3.1
[7] utf8_1.2.2                    R6_2.5.1
[9] DBI_1.1.1                     withr_2.4.2
[11] tidyselect_1.1.1              bit_4.0.4
[13] curl_4.3.2                    compiler_4.1.2
[15] rebook_1.4.0                  graph_1.72.0
[17] DelayedArray_0.20.0           bookdown_0.24
[19] sass_0.4.0                    rappdirs_0.3.3
[21] stringr_1.4.0                 digest_0.6.28
[23] Rsamtools_2.10.0              rmarkdown_2.11
[25] XVector_0.34.0                pkgconfig_2.0.3
[27] htmltools_0.5.2               dbplyr_2.1.1
[29] fastmap_1.1.0                 rlang_0.4.12
[31] RSQLite_2.2.8                 shiny_1.7.1
[33] jquerylib_0.1.4               generics_0.1.1
[35] jsonlite_1.7.2                BiocParallel_1.28.0
[37] dplyr_1.0.7                   RCurl_1.98-1.5
[39] magrittr_2.0.1                GenomeInfoDbData_1.2.7
[41] Matrix_1.3-4                  Rcpp_1.0.7
[43] fansi_0.5.0                   lifecycle_1.0.1
[45] stringi_1.7.5                 yaml_2.2.1
[47] zlibbioc_1.40.0               BiocFileCache_2.2.0
[49] AnnotationHub_3.2.0           grid_4.1.2
[51] blob_1.2.2                    parallel_4.1.2
[53] promises_1.2.0.1              ExperimentHub_2.2.0
[55] crayon_1.4.2                  lattice_0.20-45
[57] dir.expiry_1.2.0              splines_4.1.2
[59] Biostrings_2.62.0             KEGGREST_1.34.0
[61] locfit_1.5-9.4                CodeDepends_0.6.5
[63] metapod_1.2.0                 knitr_1.36
[65] pillar_1.6.4                  codetools_0.2-18
[67] XML_3.99-0.8                  glue_1.5.0
[69] BiocVersion_3.14.0            evaluate_0.14
[71] BiocManager_1.30.16           png_0.1-7
[73] vctrs_0.3.8                   httpuv_1.6.3
[75] purrr_0.3.4                   assertthat_0.2.1
[77] cachem_1.0.6                  xfun_0.28
[79] mime_0.12                     xtable_1.8-4
[81] later_1.3.0                   tibble_3.1.6
[83] AnnotationDbi_1.56.2          memoise_2.0.0
[85] statmod_1.4.36                ellipsis_0.3.2
[87] interactiveDisplayBase_1.32.0

### Bibliography

Liao, Y., G. K. Smyth, and W. Shi. 2013. “The Subread aligner: fast, accurate and scalable read mapping by seed-and-vote.” Nucleic Acids Res. 41 (10): e108.

Lun, A. T. L., and G. K. Smyth. 2015. “From Reads to Regions: A Bioconductor Workflow to Detect Differential Binding in ChIP-Seq Data.” F1000Research 4.

Lun, A. 2016. “csaw: a Bioconductor package for differential binding analysis of ChIP-seq data using sliding windows.” Nucleic Acids Res. 44 (5): e45.

Pal, B., T. Bouras, W. Shi, F. Vaillant, J. M. Sheridan, N. Fu, K. Breslin, et al. 2013. “Global changes in the mammary epigenome are induced by hormonal cues and coordinated by Ezh2.” Cell Rep. 3 (2): 411–26.

Robinson, M. D., D. J. McCarthy, and G. K. Smyth. 2010. “edgeR: a Bioconductor package for differential expression analysis of digital gene expression data.” Bioinformatics 26 (1): 139–40.

Ross-Innes, C. S., R. Stark, A. E. Teschendorff, K. A. Holmes, H. R. Ali, M. J. Dunning, G. D. Brown, et al. 2012. “Differential oestrogen receptor binding is associated with clinical outcome in breast cancer.” Nature 481 (7381): 389–93.