In this tutorial, we demonstrate how to call peaks on a single-cell ATAC-seq dataset using MACS2.

To use the peak calling functionality in Signac you will first need to install MACS2. This can be done using pip or conda, or by building the package from source.

In this demonstration we use scATAC-seq data for human PBMCs. See our vignette for the code used to generate this object, and links to the raw data. First, load the required packages and the pre-computed Seurat object:

library(Signac)
library(Seurat)

pbmc <- readRDS("../vignette_data/pbmc.rds")
DimPlot(pbmc)

Peak calling can be performed using the CallPeaks() function, and can either be done separately for different groups of cells, or performed using data from all the cells. To call peaks on each annotated cell type, we can use the group.by argument:

peaks <- CallPeaks(
  object = pbmc,
  group.by = "predicted.id"
)

The results are returned as a GRanges object, with an additional metadata column listing the cell types that each peak was identified in:

seqnames start end width strand peak_called_in
chr1 10129 10479 351 * CD4_Memory
chr1 565197 565406 210 * CD14+_Monocytes,CD8_Naive,CD4_Memory
chr1 569273 569498 226 * Double_negative_T_cell,CD4_Naive,pre-B_cell,CD8_Naive,CD4_Memory,CD14+_Monocytes,B_cell_progenitor,CD8_effector,NK_bright
chr1 713485 714537 1053 * CD14+_Monocytes,pre-B_cell,CD4_Naive,CD4_Memory,CD8_effector,Double_negative_T_cell,CD8_Naive,B_cell_progenitor,NK_dim,Dendritic_cell,CD16+_Monocytes,pDC,NK_bright
chr1 752314 752820 507 * CD14+_Monocytes,CD16+_Monocytes,Dendritic_cell
chr1 762088 763067 980 * CD14+_Monocytes,pre-B_cell,CD4_Naive,CD8_effector,CD16+_Monocytes,CD4_Memory,NK_dim,CD8_Naive,Double_negative_T_cell,Dendritic_cell,B_cell_progenitor,NK_bright

To quantify counts in each peak, you can use the FeatureMatrix() function.

We can visualize the cell-type-specific MACS2 peak calls alongside the 10x Cellranger peak calls (currently being used in the pbmc object) with the CoveragePlot() function. Here the Cellranger peaks are shown in grey and the MACS2 peaks in red:

CoveragePlot(
  object = pbmc,
  region = "CD8A",
  ranges = peaks,
  ranges.title = "MACS2"
)
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_segment()`).
Session Info
## R version 4.3.1 (2023-06-16)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Sonoma 14.4.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] C/UTF-8/C/C/C/C
## 
## time zone: Asia/Singapore
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] Seurat_5.0.3       SeuratObject_5.0.1 sp_2.1-3           Signac_1.13.0     
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3      jsonlite_1.8.8          magrittr_2.0.3         
##   [4] spatstat.utils_3.0-4    farver_2.1.1            rmarkdown_2.26         
##   [7] fs_1.6.3                zlibbioc_1.48.0         ragg_1.3.0             
##  [10] vctrs_0.6.5             ROCR_1.0-11             memoise_2.0.1          
##  [13] spatstat.explore_3.2-7  Rsamtools_2.18.0        RCurl_1.98-1.14        
##  [16] RcppRoll_0.3.0          htmltools_0.5.8         sass_0.4.9             
##  [19] sctransform_0.4.1       parallelly_1.37.1       KernSmooth_2.23-22     
##  [22] bslib_0.6.2             htmlwidgets_1.6.4       desc_1.4.3             
##  [25] ica_1.0-3               plyr_1.8.9              plotly_4.10.4          
##  [28] zoo_1.8-12              cachem_1.0.8            igraph_2.0.3           
##  [31] mime_0.12               lifecycle_1.0.4         pkgconfig_2.0.3        
##  [34] Matrix_1.6-5            R6_2.5.1                fastmap_1.1.1          
##  [37] GenomeInfoDbData_1.2.11 fitdistrplus_1.1-11     future_1.33.2          
##  [40] shiny_1.8.1             digest_0.6.35           colorspace_2.1-0       
##  [43] patchwork_1.2.0         S4Vectors_0.40.2        tensor_1.5             
##  [46] RSpectra_0.16-1         irlba_2.3.5.1           textshaping_0.3.7      
##  [49] GenomicRanges_1.54.1    labeling_0.4.3          progressr_0.14.0       
##  [52] spatstat.sparse_3.0-3   fansi_1.0.6             polyclip_1.10-6        
##  [55] abind_1.4-5             httr_1.4.7              compiler_4.3.1         
##  [58] withr_3.0.0             BiocParallel_1.36.0     fastDummies_1.7.3      
##  [61] highr_0.10              MASS_7.3-60.0.1         tools_4.3.1            
##  [64] lmtest_0.9-40           httpuv_1.6.15           future.apply_1.11.2    
##  [67] goftest_1.2-3           glue_1.7.0              nlme_3.1-164           
##  [70] promises_1.2.1          grid_4.3.1              Rtsne_0.17             
##  [73] cluster_2.1.6           reshape2_1.4.4          generics_0.1.3         
##  [76] gtable_0.3.4            spatstat.data_3.0-4     tidyr_1.3.1            
##  [79] data.table_1.15.4       utf8_1.2.4              XVector_0.42.0         
##  [82] spatstat.geom_3.2-9     BiocGenerics_0.48.1     RcppAnnoy_0.0.22       
##  [85] ggrepel_0.9.5           RANN_2.6.1              pillar_1.9.0           
##  [88] stringr_1.5.1           spam_2.10-0             RcppHNSW_0.6.0         
##  [91] later_1.3.2             splines_4.3.1           dplyr_1.1.4            
##  [94] lattice_0.22-6          deldir_2.0-4            survival_3.5-8         
##  [97] tidyselect_1.2.1        Biostrings_2.70.2       miniUI_0.1.1.1         
## [100] pbapply_1.7-2           knitr_1.45              gridExtra_2.3          
## [103] IRanges_2.36.0          scattermore_1.2         stats4_4.3.1           
## [106] xfun_0.43               matrixStats_1.2.0       stringi_1.8.3          
## [109] lazyeval_0.2.2          yaml_2.3.8              evaluate_0.23          
## [112] codetools_0.2-19        tibble_3.2.1            cli_3.6.2              
## [115] uwot_0.1.16             xtable_1.8-4            reticulate_1.35.0      
## [118] systemfonts_1.0.6       munsell_0.5.0           jquerylib_0.1.4        
## [121] Rcpp_1.0.12             GenomeInfoDb_1.38.7     spatstat.random_3.2-3  
## [124] globals_0.16.3          png_0.1-8               parallel_4.3.1         
## [127] pkgdown_2.0.7           ggplot2_3.5.0           dotCall64_1.1-1        
## [130] bitops_1.0-7            listenv_0.9.1           viridisLite_0.4.2      
## [133] scales_1.3.0            ggridges_0.5.6          leiden_0.4.3.1         
## [136] purrr_1.0.2             crayon_1.5.2            rlang_1.1.3            
## [139] cowplot_1.1.3           fastmatch_1.1-4