Package version: ATACseqQC 1.0.5

Contents

1 Introduction

Assay for Transposase-Accessible Chromatin using sequencing (ATAC-seq) is an alternative or complementary technique to MNase-seq DNase, and FAIRE-seq for chromatin accessibility analysis. The results obtained from ATAC-seq are similar to those from DNase and FAIRE-seq. ATAC-seq is gaining popularity because it does not require cross-linking, has higher signal to noise ratio, requires a much smaller amount of biological material and is faster and easier to perform, compared to other techniques1.

To help researchers quickly assess the quality of ATAC-seq data, we have developed ATACseqQC package for easily making diagnostic plots following the published guidelines1. In addition, it has functions to preprocess ATACseq data for subsequent peak calling.

2 Quick start

Here is an example to using ATACseqQC with a subset of published ATAC-seq data1. Currently, only bam input file format is supported.

## load the library
library(ATACseqQC)
## input is bamFile
bamfile <- system.file("extdata", "GL1.bam", 
                        package="ATACseqQC", mustWork=TRUE)
bamfile.labels <- gsub(".bam", "", basename(bamfile))

2.1 Fragment size distribution

First, there should be a large proportion of reads with less than 100 bp, which represent the nucleosome-free region. Second, the fragment size distribution should have a clear periodicity, which is evident in the inset figure, indicative of nucleosome occupation (present in integer multiples).

## generate fragement size distribution
fragSize <- fragSizeDist(bamfile, bamfile.labels)

2.2 Nucleosome positioning

2.2.1 Adjust the read start sites

Tn5 transposase has been shown to bind as a dimer and insert two adaptors separated by 9 bp2.

Therefore, for downstream analysis, such as peak-calling and footprinting, all reads in input bamfile need to be shifted. The function shiftGAlignmentsList can be used to shift the reads. By default, all reads aligning to the positive strand are offset by +4bp, and all reads aligning to the negative strand are offset by -5bp1.

The adjusted reads will be written into a new bamfile for peak calling or footprinting.

## bamfile tags
tags <- c("AS", "XN", "XM", "XO", "XG", "NM", "MD", "YS", "YT")
## files will be output into outPath
outPath <- "splited"
dir.create(outPath)
## shift the bam file by the 5'ends
library(BSgenome.Hsapiens.UCSC.hg19)
seqlev <- "chr1" ## subsample data for quick run
which <- as(seqinfo(Hsapiens)[seqlev], "GRanges")
gal <- readBamFile(bamfile, tag=tags, which=which, asMates=TRUE)
gal1 <- shiftGAlignmentsList(gal)
shiftedBamfile <- file.path(outPath, "shifted.bam")
export(gal1, shiftedBamfile)

2.2.2 Split reads

The shifted reads will be split into different bins, namely nucleosome free, mononucleosome, dinucleosome, and trinucleosome. Shifted reads that do not fit into any of the above bins will be discarded. Splitting reads is a time-consuming step because we are using random forest to classify the fragments based on fragment length, GC content and conservation scores3.

By default, we assign the top 10% of short reads (reads below 100_bp) as nucleosome-free regions and the top 10% of intermediate length reads as (reads between 180 and 247 bp) mononucleosome. This serves as the training set to classify the rest of the fragments using random forest. The number of the tree will be set to 2 times of square root of the length of the training set.

library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txs <- transcripts(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(phastCons100way.UCSC.hg19)
## run program for chromosome 1 only
txs <- txs[seqnames(txs) %in% "chr1"]
genome <- Hsapiens
## split the reads into NucleosomeFree, mononucleosome, 
## dinucleosome and trinucleosome.
objs <- splitGAlignmentsByCut(gal1, txs=txs, genome=genome,
                              conservation=phastCons100way.UCSC.hg19)

Save the binned alignments into bam files.

null <- writeListOfGAlignments(objs, outPath)
## list the files generated by splitBam.
dir(outPath)
##  [1] "NucleosomeFree.bam"     "NucleosomeFree.bam.bai"
##  [3] "dinucleosome.bam"       "dinucleosome.bam.bai"  
##  [5] "inter1.bam"             "inter1.bam.bai"        
##  [7] "inter2.bam"             "inter2.bam.bai"        
##  [9] "inter3.bam"             "inter3.bam.bai"        
## [11] "mononucleosome.bam"     "mononucleosome.bam.bai"
## [13] "others.bam"             "others.bam.bai"        
## [15] "shifted.bam"            "shifted.bam.bai"       
## [17] "trinucleosome.bam"      "trinucleosome.bam.bai"

You can also do shift, split and save bams in one step by calling splitBam.

objs <- splitBam(bamfile, tags=tags, outPath=outPath,
                 txs=txs, genome=genome,
                 conservation=phastCons100way.UCSC.hg19)

2.2.3 Heatmap and coverage curve for nucleosome positions

By averaging the signal across all active TSSs, we should observe that nucleosome-free fragments are enriched at the TSS, whereas the nucleosome-bound fragments should be enriched both upstream and downstream of the active TSS and display characteristic phasing of upstream and downstream nucleosomes. Because ATAC-seq reads are concentrated at regions of open chromatin, users should see a strong nucleosome signal at the +1 nucleosome that decreases at the +2, +3 and +4 nucleosomes.

library(ChIPpeakAnno)
bamfiles <- file.path(outPath,
                     c("NucleosomeFree.bam",
                     "mononucleosome.bam",
                     "dinucleosome.bam",
                     "trinucleosome.bam"))
## Plot the cumulative percentage tag allocation in NucleosomeFree 
## and mononucleosome bams.
cumulativePercentage(bamfiles[1:2], as(seqinfo(Hsapiens)["chr1"], "GRanges"))

TSS <- promoters(txs, upstream=0, downstream=1)
TSS <- unique(TSS)
## estimate the library size for normalization
(librarySize <- estLibSize(bamfiles))
## splited/NucleosomeFree.bam splited/mononucleosome.bam 
##                      23807                       4100 
##   splited/dinucleosome.bam  splited/trinucleosome.bam 
##                       3743                        740
## calculate the signals around TSSs.
NTILE <- 101
dws <- ups <- 1010
sigs <- enrichedFragments(bamfiles, TSS=TSS,
                          librarySize=librarySize,
                          seqlev=seqlev,
                          TSS.filter=0.5,
                          n.tile = NTILE,
                          upstream = ups,
                          downstream = dws)
## log2 transformed signals
names(sigs) <- gsub(".bam", "", basename(names(sigs)))
sigs.log2 <- lapply(sigs, function(.ele) log2(.ele+1))
#plot heatmap
featureAlignedHeatmap(sigs.log2, reCenterPeaks(TSS, width=ups+dws),
                      zeroAt=.5, n.tile=NTILE)

## get signals normalized for nucleosome-free and nucleosome-bound regions.
out <- featureAlignedDistribution(sigs, 
                                  reCenterPeaks(TSS, width=ups+dws),
                                  zeroAt=.5, n.tile=NTILE, type="l")
## rescale the nucleosome-free and nucleosome signals to 0~1
range01 <- function(x){(x-min(x))/(max(x)-min(x))}
out <- apply(out, 2, range01)
matplot(out, type="l", xaxt="n", 
        xlab="Position (bp)", 
        ylab="Fraction of signal")
axis(1, at=seq(0, 100, by=10)+1, 
     labels=c("-1K", seq(-800, 800, by=200), "1K"), las=3)
abline(v=seq(0, 100, by=10)+1, lty=2, col="gray")

2.3 Footprints

ATAC-seq footprints infer factor occupancy genome-wide. The factorFootprints function uses matchPWM to predict the binding sites using the input position weight matrix (PWM). Then it calculates and plots the accumulated coverage for those binding sites to show the status of the occupancy genome-wide. Unlike CENTIPEDE4, the footprints generated here do not take into consideration the conservation (PhyloP). factorFootprints function could also accept the possible binding sites as a GRanges object.

## foot prints
library(MotifDb)
CTCF <- query(MotifDb, c("CTCF"))
CTCF <- as.list(CTCF)
print(CTCF[[1]], digits=2)
##       1    2     3     4      5     6     7     8     9     10     11
## A 0.095 0.18 0.308 0.061 0.0088 0.815 0.044 0.117 0.933 0.0055 0.3655
## C 0.319 0.16 0.054 0.876 0.9890 0.014 0.578 0.475 0.012 0.0000 0.0033
## G 0.083 0.45 0.492 0.023 0.0000 0.071 0.366 0.053 0.035 0.9912 0.6213
## T 0.503 0.20 0.147 0.039 0.0022 0.100 0.012 0.355 0.020 0.0033 0.0099
##      12     13     14     15    16    17   18    19
## A 0.059 0.0132 0.0615 0.1144 0.409 0.090 0.13 0.443
## C 0.013 0.0000 0.0088 0.8064 0.014 0.531 0.35 0.199
## G 0.553 0.9780 0.8516 0.0055 0.558 0.338 0.08 0.293
## T 0.374 0.0088 0.0780 0.0737 0.019 0.041 0.44 0.065
factorFootprints(shiftedBamfile, pfm=CTCF[[1]], 
                 genome=genome,
                 min.score="95%", seqlev=seqlev,
                 upstream=100, downstream=100)

Here is the CTCF footprints for the full dataset. CTCF footprints

3 Session Info

sessionInfo()
## R version 3.4.1 (2017-06-30)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.3 LTS
## 
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.5-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.5-bioc/R/lib/libRlapack.so
## 
## 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       
## 
## attached base packages:
##  [1] grid      stats4    parallel  stats     graphics  grDevices utils    
##  [8] datasets  methods   base     
## 
## other attached packages:
##  [1] MotifDb_1.18.0                         
##  [2] phastCons100way.UCSC.hg19_3.5.0        
##  [3] GenomicScores_1.0.1                    
##  [4] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
##  [5] GenomicFeatures_1.28.4                 
##  [6] AnnotationDbi_1.38.2                   
##  [7] Biobase_2.36.2                         
##  [8] BSgenome.Hsapiens.UCSC.hg19_1.4.0      
##  [9] BSgenome_1.44.0                        
## [10] rtracklayer_1.36.4                     
## [11] ChIPpeakAnno_3.10.1                    
## [12] VennDiagram_1.6.17                     
## [13] futile.logger_1.4.3                    
## [14] GenomicRanges_1.28.4                   
## [15] GenomeInfoDb_1.12.2                    
## [16] Biostrings_2.44.2                      
## [17] XVector_0.16.0                         
## [18] IRanges_2.10.2                         
## [19] ATACseqQC_1.0.5                        
## [20] S4Vectors_0.14.3                       
## [21] BiocGenerics_0.22.0                    
## [22] BiocStyle_2.4.1                        
## 
## loaded via a namespace (and not attached):
##  [1] ProtGenerics_1.8.0            bitops_1.0-6                 
##  [3] matrixStats_0.52.2            bit64_0.9-7                  
##  [5] httr_1.3.1                    rprojroot_1.2                
##  [7] tools_3.4.1                   backports_1.1.0              
##  [9] rGADEM_2.24.0                 R6_2.2.2                     
## [11] seqLogo_1.42.0                DBI_0.7                      
## [13] lazyeval_0.2.0                colorspace_1.3-2             
## [15] ade4_1.7-8                    motifStack_1.20.1            
## [17] bit_1.1-12                    curl_2.8.1                   
## [19] compiler_3.4.1                graph_1.54.0                 
## [21] DelayedArray_0.2.7            grImport_0.9-0               
## [23] scales_0.5.0                  randomForest_4.6-12          
## [25] RBGL_1.52.0                   stringr_1.2.0                
## [27] digest_0.6.12                 Rsamtools_1.28.0             
## [29] rmarkdown_1.6                 pkgconfig_2.0.1              
## [31] htmltools_0.3.6               ensembldb_2.0.4              
## [33] limma_3.32.5                  regioneR_1.8.1               
## [35] htmlwidgets_0.9               rlang_0.1.2                  
## [37] RSQLite_2.0                   BiocInstaller_1.26.0         
## [39] shiny_1.0.5                   BiocParallel_1.10.1          
## [41] RCurl_1.95-4.8                magrittr_1.5                 
## [43] GO.db_3.4.1                   GenomeInfoDbData_0.99.0      
## [45] Matrix_1.2-11                 Rcpp_0.12.12                 
## [47] munsell_0.4.3                 stringi_1.1.5                
## [49] yaml_2.1.14                   MASS_7.3-47                  
## [51] SummarizedExperiment_1.6.3    zlibbioc_1.22.0              
## [53] plyr_1.8.4                    AnnotationHub_2.8.2          
## [55] blob_1.1.0                    lattice_0.20-35              
## [57] splines_3.4.1                 multtest_2.32.0              
## [59] knitr_1.17                    MotIV_1.32.0                 
## [61] seqinr_3.4-5                  biomaRt_2.32.1               
## [63] futile.options_1.0.0          XML_3.98-1.9                 
## [65] evaluate_0.10.1               lambda.r_1.1.9               
## [67] idr_1.2                       httpuv_1.3.5                 
## [69] mime_0.5                      xtable_1.8-2                 
## [71] AnnotationFilter_1.0.0        survival_2.41-3              
## [73] tibble_1.3.4                  GenomicAlignments_1.12.2     
## [75] memoise_1.1.0                 interactiveDisplayBase_1.14.0

References

1. Buenrostro, J. D., Giresi, P. G., Zaba, L. C., Chang, H. Y. & Greenleaf, W. J. Transposition of native chromatin for fast and sensitive epigenomic profiling of open chromatin, dna-binding proteins and nucleosome position. Nature methods 10, 1213–1218 (2013).

2. Adey, A. et al. Rapid, low-input, low-bias construction of shotgun fragment libraries by high-density in vitro transposition. Genome biology 11, R119 (2010).

3. Chen, K. et al. DANPOS: Dynamic analysis of nucleosome position and occupancy by sequencing. Genome research 23, 341–351 (2013).

4. Pique-Regi, R. et al. Accurate inference of transcription factor binding from dna sequence and chromatin accessibility data. Genome research 21, 447–455 (2011).