For this tutorial, we will be analyzing a single-cell ATAC-seq dataset of adult mouse brain cells provided by 10x Genomics. The following files are used in this vignette, all available through the 10x Genomics website.

View data download code

To download the required data, run the following lines in a shell:

wget http://cf.10xgenomics.com/samples/cell-atac/1.1.0/atac_v1_adult_brain_fresh_5k/atac_v1_adult_brain_fresh_5k_filtered_peak_bc_matrix.h5
wget http://cf.10xgenomics.com/samples/cell-atac/1.1.0/atac_v1_adult_brain_fresh_5k/atac_v1_adult_brain_fresh_5k_singlecell.csv
wget http://cf.10xgenomics.com/samples/cell-atac/1.1.0/atac_v1_adult_brain_fresh_5k/atac_v1_adult_brain_fresh_5k_fragments.tsv.gz
wget http://cf.10xgenomics.com/samples/cell-atac/1.1.0/atac_v1_adult_brain_fresh_5k/atac_v1_adult_brain_fresh_5k_fragments.tsv.gz.tbi

This vignette echoes the commands run in the introductory Signac vignette on human PBMC. We provide the same analysis in a different system to demonstrate performance and applicability to other tissue types, and to provide an example from another species.

First load in Signac, Seurat, and some other packages we will be using for analyzing mouse data.

library(Signac)
library(Seurat)
library(EnsDb.Mmusculus.v79)
## Warning: package 'S4Vectors' was built under R version 4.3.2
## Warning: package 'GenomeInfoDb' was built under R version 4.3.3
## Warning: package 'GenomicFeatures' was built under R version 4.3.2

Pre-processing workflow

counts <- Read10X_h5("../vignette_data/atac_v1_adult_brain_fresh_5k_filtered_peak_bc_matrix.h5")
metadata <- read.csv(
  file = "../vignette_data/atac_v1_adult_brain_fresh_5k_singlecell.csv",
  header = TRUE,
  row.names = 1
)

brain_assay <- CreateChromatinAssay(
  counts = counts,
  sep = c(":", "-"),
  genome = "mm10",
  fragments = '../vignette_data/atac_v1_adult_brain_fresh_5k_fragments.tsv.gz',
  min.cells = 1
)
## Computing hash
brain <- CreateSeuratObject(
  counts = brain_assay,
  assay = 'peaks',
  project = 'ATAC',
  meta.data = metadata
)

We can also add gene annotations to the brain object for the mouse genome. This will allow downstream functions to pull the gene annotation information directly from the object.

# extract gene annotations from EnsDb
annotations <- GetGRangesFromEnsDb(ensdb = EnsDb.Mmusculus.v79)

# change to UCSC style since the data was mapped to hg19
seqlevels(annotations) <- paste0('chr', seqlevels(annotations))
genome(annotations) <- "mm10"

# add the gene information to the object
Annotation(brain) <- annotations

Computing QC Metrics

Next we compute some useful per-cell QC metrics.

brain <- NucleosomeSignal(object = brain)

We can look at the fragment length periodicity for all the cells, and group by cells with high or low nucleosomal signal strength. You can see that cells which are outliers for the mononucleosomal/ nucleosome-free ratio have different banding patterns. The remaining cells exhibit a pattern that is typical for a successful ATAC-seq experiment.

brain$nucleosome_group <- ifelse(brain$nucleosome_signal > 4, 'NS > 4', 'NS < 4')
FragmentHistogram(object = brain, group.by = 'nucleosome_group', region = 'chr1-1-10000000')

The enrichment of Tn5 integration events at transcriptional start sites (TSSs) can also be an important quality control metric to assess the targeting of Tn5 in ATAC-seq experiments. The ENCODE consortium defined a TSS enrichment score as the number of Tn5 integration site around the TSS normalized to the number of Tn5 integration sites in flanking regions. See the ENCODE documentation for more information about the TSS enrichment score (https://www.encodeproject.org/data-standards/terms/). We can calculate the TSS enrichment score for each cell using the TSSEnrichment() function in Signac.

brain <- TSSEnrichment(brain, fast = FALSE)
brain$high.tss <- ifelse(brain$TSS.enrichment > 2, 'High', 'Low')
TSSPlot(brain, group.by = 'high.tss') + NoLegend()

brain$pct_reads_in_peaks <- brain$peak_region_fragments / brain$passed_filters * 100
brain$blacklist_ratio <- brain$blacklist_region_fragments / brain$peak_region_fragments

VlnPlot(
  object = brain,
  features = c('pct_reads_in_peaks', 'peak_region_fragments',
               'TSS.enrichment', 'blacklist_ratio', 'nucleosome_signal'),
  pt.size = 0.1,
  ncol = 5
)

We remove cells that are outliers for these QC metrics.

brain <- subset(
  x = brain,
  subset = peak_region_fragments > 3000 &
    peak_region_fragments < 100000 &
    pct_reads_in_peaks > 40 &
    blacklist_ratio < 0.025 &
    nucleosome_signal < 4 &
    TSS.enrichment > 2
)
brain
## An object of class Seurat 
## 157203 features across 3512 samples within 1 assay 
## Active assay: peaks (157203 features, 0 variable features)
##  2 layers present: counts, data

Normalization and linear dimensional reduction

brain <- RunTFIDF(brain)
brain <- FindTopFeatures(brain, min.cutoff = 'q0')
brain <- RunSVD(object = brain)

The first LSI component often captures sequencing depth (technical variation) rather than biological variation. If this is the case, the component should be removed from downstream analysis. We can assess the correlation between each LSI component and sequencing depth using the DepthCor() function:

DepthCor(brain)

Here we see there is a very strong correlation between the first LSI component and the total number of counts for the cell, so we will perform downstream steps without this component.

Non-linear dimension reduction and clustering

Now that the cells are embedded in a low-dimensional space, we can use methods commonly applied for the analysis of scRNA-seq data to perform graph-based clustering, and non-linear dimension reduction for visualization. The functions RunUMAP(), FindNeighbors(), and FindClusters() all come from the Seurat package.

brain <- RunUMAP(
  object = brain,
  reduction = 'lsi',
  dims = 2:30
)
brain <- FindNeighbors(
  object = brain,
  reduction = 'lsi',
  dims = 2:30
)
brain <- FindClusters(
  object = brain,
  algorithm = 3,
  resolution = 1.2,
  verbose = FALSE
)

DimPlot(object = brain, label = TRUE) + NoLegend()

Create a gene activity matrix

# compute gene activities
gene.activities <- GeneActivity(brain)

# add the gene activity matrix to the Seurat object as a new assay
brain[['RNA']] <- CreateAssayObject(counts = gene.activities)
brain <- NormalizeData(
  object = brain,
  assay = 'RNA',
  normalization.method = 'LogNormalize',
  scale.factor = median(brain$nCount_RNA)
)
DefaultAssay(brain) <- 'RNA'
FeaturePlot(
  object = brain,
  features = c('Sst','Pvalb',"Gad2","Neurod6","Rorb","Syt6"),
  pt.size = 0.1,
  max.cutoff = 'q95',
  ncol = 3
)

Integrating with scRNA-seq data

To help interpret the scATAC-seq data, we can classify cells based on an scRNA-seq experiment from the same biological system (the adult mouse brain). We utilize methods for cross-modality integration and label transfer, described here, with a more in-depth tutorial here.

You can download the raw data for this experiment from the Allen Institute website, and view the code used to construct this object on GitHub. Alternatively, you can download the pre-processed Seurat object here.

# Load the pre-processed scRNA-seq data
allen_rna <- readRDS("../vignette_data/allen_brain.rds")
allen_rna <- UpdateSeuratObject(allen_rna)
allen_rna <- FindVariableFeatures(
  object = allen_rna,
  nfeatures = 5000
)

transfer.anchors <- FindTransferAnchors(
  reference = allen_rna,
  query = brain,
  reduction = 'cca',
  dims = 1:30
)

predicted.labels <- TransferData(
  anchorset = transfer.anchors,
  refdata = allen_rna$subclass,
  weight.reduction = brain[['lsi']],
  dims = 2:30
)

brain <- AddMetaData(object = brain, metadata = predicted.labels)
plot1 <- DimPlot(allen_rna, group.by = 'subclass', label = TRUE, repel = TRUE) + NoLegend() + ggtitle('scRNA-seq')
plot2 <- DimPlot(brain, group.by = 'predicted.id', label = TRUE, repel = TRUE) + NoLegend() + ggtitle('scATAC-seq')
plot1 + plot2

You can see that the RNA-based classifications are consistent with the UMAP visualization, computed only on the ATAC-seq data.

Find differentially accessible peaks between clusters

Here, we find differentially accessible regions between excitatory neurons in different layers of the cortex.

#switch back to working with peaks instead of gene activities
DefaultAssay(brain) <- 'peaks'
Idents(brain) <- "predicted.id"

da_peaks <- FindMarkers(
  object = brain,
  ident.1 = c("L2/3 IT"), 
  ident.2 = c("L4", "L5 IT", "L6 IT"),
  test.use = 'LR',
  latent.vars = 'nCount_peaks'
)

head(da_peaks)
##                                  p_val avg_log2FC pct.1 pct.2    p_val_adj
## chr4-86523678-86525285    3.266647e-69   3.691294 0.426 0.037 5.135267e-64
## chr2-118700082-118704897  8.553383e-61   2.092487 0.648 0.182 1.344617e-55
## chr15-87605281-87607659   3.864918e-55   2.450827 0.499 0.097 6.075767e-50
## chr10-107751762-107753240 1.534485e-52   1.801355 0.632 0.192 2.412257e-47
## chr4-101303935-101305131  5.949521e-51   3.427059 0.356 0.031 9.352825e-46
## chr13-69329933-69331707   1.604991e-49  -2.254722 0.140 0.435 2.523094e-44
plot1 <- VlnPlot(
  object = brain,
  features = rownames(da_peaks)[1],
  pt.size = 0.1,
  idents = c("L4","L5 IT","L2/3 IT")
)
plot2 <- FeaturePlot(
  object = brain,
  features = rownames(da_peaks)[1],
  pt.size = 0.1,
  max.cutoff = 'q95'
)
plot1 | plot2

open_l23 <- rownames(da_peaks[da_peaks$avg_log2FC > 3, ])
open_l456 <- rownames(da_peaks[da_peaks$avg_log2FC < 3, ])
closest_l23 <- ClosestFeature(brain, open_l23)
closest_l456 <- ClosestFeature(brain, open_l456)
head(closest_l23)
##                                 tx_id gene_name            gene_id
## ENSMUST00000151481 ENSMUST00000151481   Fam154a ENSMUSG00000028492
## ENSMUST00000131864 ENSMUST00000131864   Gm12796 ENSMUSG00000085721
## ENSMUST00000139527 ENSMUST00000139527     Yipf1 ENSMUSG00000057375
## ENSMUSE00001329193 ENSMUST00000185379   Gm29414 ENSMUSG00000099392
## ENSMUSE00000514286 ENSMUST00000077353      Hmbs ENSMUSG00000032126
## ENSMUST00000161356 ENSMUST00000161356      Reln ENSMUSG00000042453
##                      gene_biotype type           closest_region
## ENSMUST00000151481 protein_coding  gap   chr4-86487920-86538964
## ENSMUST00000131864        lincRNA  gap chr4-101292521-101318425
## ENSMUST00000139527 protein_coding  cds chr4-107345009-107345191
## ENSMUSE00001329193        lincRNA exon   chr1-25026581-25026779
## ENSMUSE00000514286 protein_coding exon   chr9-44344010-44344228
## ENSMUST00000161356 protein_coding  gap   chr5-21891568-21895988
##                                query_region distance
## ENSMUST00000151481   chr4-86523678-86525285        0
## ENSMUST00000131864 chr4-101303935-101305131        0
## ENSMUST00000139527 chr4-107344435-107345145        0
## ENSMUSE00001329193   chr1-25008426-25009334    17246
## ENSMUSE00000514286   chr9-44345250-44346015     1021
## ENSMUST00000161356   chr5-21894051-21894682        0
head(closest_l456)
##                                 tx_id gene_name            gene_id
## ENSMUST00000104937 ENSMUST00000104937   Ankrd63 ENSMUSG00000078137
## ENSMUSE00000647021 ENSMUST00000068088   Fam19a5 ENSMUSG00000054863
## ENSMUST00000165341 ENSMUST00000165341     Otogl ENSMUSG00000091455
## ENSMUST00000044081 ENSMUST00000044081     Papd7 ENSMUSG00000034575
## ENSMUST00000070198 ENSMUST00000070198    Ppp3ca ENSMUSG00000028161
## ENSMUST00000084628 ENSMUST00000084628    Hs3st2 ENSMUSG00000046321
##                      gene_biotype type            closest_region
## ENSMUST00000104937 protein_coding  cds  chr2-118702266-118703438
## ENSMUSE00000647021 protein_coding exon   chr15-87625230-87625486
## ENSMUST00000165341 protein_coding  utr chr10-107762223-107762309
## ENSMUST00000044081 protein_coding  utr   chr13-69497959-69499915
## ENSMUST00000070198 protein_coding  utr  chr3-136935226-136937727
## ENSMUST00000084628 protein_coding  cds  chr7-121392730-121393214
##                                 query_region distance
## ENSMUST00000104937  chr2-118700082-118704897        0
## ENSMUSE00000647021   chr15-87605281-87607659    17570
## ENSMUST00000165341 chr10-107751762-107753240     8982
## ENSMUST00000044081   chr13-69329933-69331707   166251
## ENSMUST00000070198  chr3-137056475-137058371   118747
## ENSMUST00000084628  chr7-121391215-121395519        0

Plotting genomic regions

We can also create coverage plots grouped by cluster, cell type, or any other metadata stored in the object for any genomic region using the CoveragePlot() function. These represent pseudo-bulk accessibility tracks, where signal from all cells within a group have been averaged together to visualize the DNA accessibility in a region.

# show cell types with at least 50 cells
idents.plot <- names(which(table(Idents(brain)) > 50))

CoveragePlot(
  object = brain,
  region = c("Neurod6", "Gad2"),
  idents = idents.plot,
  extend.upstream = 1000,
  extend.downstream = 1000,
  ncol = 1
)

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] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] patchwork_1.2.0            ggplot2_3.5.0             
##  [3] EnsDb.Mmusculus.v79_2.99.0 ensembldb_2.26.0          
##  [5] AnnotationFilter_1.26.0    GenomicFeatures_1.54.3    
##  [7] AnnotationDbi_1.64.1       Biobase_2.62.0            
##  [9] GenomicRanges_1.54.1       GenomeInfoDb_1.38.7       
## [11] IRanges_2.36.0             S4Vectors_0.40.2          
## [13] BiocGenerics_0.48.1        Seurat_5.0.3              
## [15] SeuratObject_5.0.1         sp_2.1-3                  
## [17] Signac_1.13.0             
## 
## loaded via a namespace (and not attached):
##   [1] fs_1.6.3                    ProtGenerics_1.34.0        
##   [3] matrixStats_1.2.0           spatstat.sparse_3.0-3      
##   [5] bitops_1.0-7                httr_1.4.7                 
##   [7] RColorBrewer_1.1-3          tools_4.3.1                
##   [9] sctransform_0.4.1           backports_1.4.1            
##  [11] utf8_1.2.4                  R6_2.5.1                   
##  [13] lazyeval_0.2.2              uwot_0.1.16                
##  [15] withr_3.0.0                 prettyunits_1.2.0          
##  [17] gridExtra_2.3               progressr_0.14.0           
##  [19] cli_3.6.2                   textshaping_0.3.7          
##  [21] spatstat.explore_3.2-7      fastDummies_1.7.3          
##  [23] labeling_0.4.3              sass_0.4.9                 
##  [25] spatstat.data_3.0-4         ggridges_0.5.6             
##  [27] pbapply_1.7-2               pkgdown_2.0.7              
##  [29] Rsamtools_2.18.0            systemfonts_1.0.6          
##  [31] foreign_0.8-86              dichromat_2.0-0.1          
##  [33] parallelly_1.37.1           BSgenome_1.70.2            
##  [35] rstudioapi_0.16.0           RSQLite_2.3.5              
##  [37] generics_0.1.3              BiocIO_1.12.0              
##  [39] ica_1.0-3                   spatstat.random_3.2-3      
##  [41] dplyr_1.1.4                 Matrix_1.6-5               
##  [43] ggbeeswarm_0.7.2            fansi_1.0.6                
##  [45] abind_1.4-5                 lifecycle_1.0.4            
##  [47] yaml_2.3.8                  SummarizedExperiment_1.32.0
##  [49] SparseArray_1.2.4           BiocFileCache_2.10.1       
##  [51] Rtsne_0.17                  grid_4.3.1                 
##  [53] blob_1.2.4                  promises_1.2.1             
##  [55] crayon_1.5.2                miniUI_0.1.1.1             
##  [57] lattice_0.22-6              cowplot_1.1.3              
##  [59] KEGGREST_1.42.0             pillar_1.9.0               
##  [61] knitr_1.45                  rjson_0.2.21               
##  [63] future.apply_1.11.2         codetools_0.2-19           
##  [65] fastmatch_1.1-4             leiden_0.4.3.1             
##  [67] glue_1.7.0                  data.table_1.15.4          
##  [69] vctrs_0.6.5                 png_0.1-8                  
##  [71] spam_2.10-0                 gtable_0.3.4               
##  [73] cachem_1.0.8                xfun_0.43                  
##  [75] S4Arrays_1.2.1              mime_0.12                  
##  [77] survival_3.5-8              RcppRoll_0.3.0             
##  [79] fitdistrplus_1.1-11         ROCR_1.0-11                
##  [81] nlme_3.1-164                bit64_4.0.5                
##  [83] progress_1.2.3              filelock_1.0.3             
##  [85] RcppAnnoy_0.0.22            bslib_0.6.2                
##  [87] irlba_2.3.5.1               vipor_0.4.7                
##  [89] KernSmooth_2.23-22          rpart_4.1.23               
##  [91] colorspace_2.1-0            DBI_1.2.2                  
##  [93] Hmisc_5.1-2                 nnet_7.3-19                
##  [95] ggrastr_1.0.2               tidyselect_1.2.1           
##  [97] bit_4.0.5                   compiler_4.3.1             
##  [99] curl_5.2.1                  htmlTable_2.4.2            
## [101] hdf5r_1.3.10                xml2_1.3.6                 
## [103] desc_1.4.3                  DelayedArray_0.28.0        
## [105] plotly_4.10.4               rtracklayer_1.62.0         
## [107] checkmate_2.3.1             scales_1.3.0               
## [109] lmtest_0.9-40               rappdirs_0.3.3             
## [111] stringr_1.5.1               digest_0.6.35              
## [113] goftest_1.2-3               spatstat.utils_3.0-4       
## [115] rmarkdown_2.26              XVector_0.42.0             
## [117] htmltools_0.5.8             pkgconfig_2.0.3            
## [119] base64enc_0.1-3             MatrixGenerics_1.14.0      
## [121] highr_0.10                  dbplyr_2.5.0               
## [123] fastmap_1.1.1               rlang_1.1.3                
## [125] htmlwidgets_1.6.4           shiny_1.8.1                
## [127] farver_2.1.1                jquerylib_0.1.4            
## [129] zoo_1.8-12                  jsonlite_1.8.8             
## [131] BiocParallel_1.36.0         VariantAnnotation_1.48.1   
## [133] RCurl_1.98-1.14             magrittr_2.0.3             
## [135] Formula_1.2-5               GenomeInfoDbData_1.2.11    
## [137] dotCall64_1.1-1             munsell_0.5.0              
## [139] Rcpp_1.0.12                 reticulate_1.35.0          
## [141] stringi_1.8.3               zlibbioc_1.48.0            
## [143] MASS_7.3-60.0.1             plyr_1.8.9                 
## [145] parallel_4.3.1              listenv_0.9.1              
## [147] ggrepel_0.9.5               deldir_2.0-4               
## [149] Biostrings_2.70.2           splines_4.3.1              
## [151] tensor_1.5                  hms_1.1.3                  
## [153] igraph_2.0.3                spatstat.geom_3.2-9        
## [155] RcppHNSW_0.6.0              reshape2_1.4.4             
## [157] biomaRt_2.58.2              XML_3.99-0.16.1            
## [159] evaluate_0.23               biovizBase_1.50.0          
## [161] httpuv_1.6.15               RANN_2.6.1                 
## [163] tidyr_1.3.1                 purrr_1.0.2                
## [165] polyclip_1.10-6             future_1.33.2              
## [167] scattermore_1.2             xtable_1.8-4               
## [169] restfulr_0.0.15             RSpectra_0.16-1            
## [171] later_1.3.2                 viridisLite_0.4.2          
## [173] ragg_1.3.0                  tibble_3.2.1               
## [175] beeswarm_0.4.0              memoise_2.0.1              
## [177] GenomicAlignments_1.38.2    cluster_2.1.6              
## [179] globals_0.16.3