The user wants a tutorial on processing single-cell ATAC-seq (scATAC-seq) data.
The request covers specific steps:
- Alignment/Fragment deduplication.
- Peak calling.
- Dimensionality reduction.
- Integration with scRNA-seq.
- Regulatory motif enrichment.
Target Audience: Likely a bioinformatician or a biologist moving into computational genomics. The tone should be educational, structured, and practical.
Structure of the Response:
I should organize this as a workflow guide, perhaps following a standard pipeline like the 10x Genomics Cell Ranger ARC -> ArchR/Signac/Seurat pipeline, as these are the industry standards.
Step-by-Step Breakdown:
-
Introduction: Briefly explain what scATAC-seq measures (chromatin accessibility). Mention key tools (Cell Ranger, ArchR, Signac, Seurat).
-
Step 1: Raw Data Processing (Alignment & Deduplication):
- Input: FASTQ files.
- Tools:
Cell Ranger ATAC (10x specific) or chromap (generic/fast).
- Process: Mapping to reference genome -> Identifying valid barcodes -> Deduplication (Crucial for ATAC to remove PCR duplicates based on coordinate + barcode + UMI).
- Output: Fragment file (TSV). This is the fundamental unit of scATAC data.
-
Step 2: Quality Control (QC) & Peak Calling:
- QC Metrics: TSS enrichment (signal-to-noise), Nucleosome banding (fragment length distribution), Total fragments per cell.
- Peak Calling: Unlike bulk ATAC, we need to aggregate signal from similar cells to call peaks accurately.
- Method: "Pseudo-bulk" approach. Group cells (e.g., via latent semantic indexing initially or just per sample), aggregate reads, run MACS2, merge peaks into a unified peak set.
- Tools: ArchR, Signac, or
MACS2.
-
Step 3: Feature Counting & Dimensionality Reduction:
- Matrix: We need a cell-by-peak matrix (binary or counts). This matrix is sparse and high-dimensional.
- Latent Semantic Indexing (LSI): Standard for ATAC (TF-IDF -> SVD).
- Clustering: Graph-based clustering on LSI components.
- Visualization: UMAP/t-SNE.
-
Step 4: Integration with scRNA-seq:
- Why? ATAC tells you where the chromatin is open, but not necessarily what genes are expressed. Integration matches open chromatin to gene expression.
- Methods:
- Label Transfer: Train a classifier on RNA, apply to ATAC.
- Co-embedding: CCA (Canonical Correlation Analysis) or using a bridge reference (WNN - Weighted Nearest Neighbor).
- Tools: Seurat (CCA/FindTransferAnchors), Signac, or cross-modality tools like
GLUE.
-
Step 5: Regulatory Motif Enrichment:
- Goal: Identify Transcription Factors (TFs) driving the differences between clusters.
- Method: Scan peaks for known motifs (JASPAR database) -> Calculate deviation scores (chromVAR) or motif enrichment in differentially accessible peaks (DARs).
- Tools:
chromVAR (standard deviation approach), HOMER, or built-in functions in Signac/ArchR.
Code Examples:
Since the user asked to "Teach", providing code snippets is essential. Signac (R/Seurat wrapper) and ArchR (R) are the best candidates. I will focus on Signac + Seurat because it's widely used and integrates easily with the scRNA-seq step requested, but I will mention ArchR as a powerful alternative.
Refining the Content:
- Alignment: Explain that the "Fragment File" is the key output.
- Deduplication: Emphasize that scATAC deduplication is different from bulk because of the barcode.
- Peak Calling: Emphasize the "Pseudo-bulk" concept. You can't call peaks on single cells individually.
- Dim Reduction: Explain TF-IDF (normalization for sparsity).
- Integration: Focus on "Transfer Anchors" in Seurat as the most accessible method.
- Motifs: Explain
chromVAR logic (k-mers vs position weight matrices).
Drafting the response:
- Header: Clear title.
- Prerequisites: R/Python, reference genome.
- Section 1 (Alignment): Mention Cell Ranger.
- Section 2 (Processing in R): Use Signac syntax for the rest.
- Create object.
- QC filtering.
- LSI.
- Section 3 (Integration): Show the
FindTransferAnchors workflow.
- Section 4 (Motifs): Show
RunChromVAR.
Self-Correction/Review:
- Did I miss anything? Doublet detection is important in scATAC. I should mention it briefly in QC.
- Is the code copy-pasteable? I should use generic paths/variables.
- Is the distinction between "Peak Matrix" and "Tile Matrix" clear? I'll stick to Peak Matrix for simplicity but mention tiles as an alternative for LSI in ArchR.
Final Polish: Ensure the distinction between bulk and single-cell logic is clear (e.g., why we do pseudo-bulk peak calling).
Let's write it out. I will structure it as a comprehensive guide using the Signac (R) ecosystem, as it is highly accessible for those already familiar with Seurat, and handles the integration step gracefully.
- Part 1: Pre-processing (The Bash/Command Line phase) -> Cell Ranger.
- Part 2: Post-processing (The R/Python phase) -> QC, Peak Calling, LSI.
- Part 3: Integration -> Linking to scRNA.
- Part 4: Biological Insight -> Motifs.
This looks solid. I will include a code block for the main workflow using Signac/Seurat.
One specific detail: The user asked for "Peak Calling". In pipelines like Cell Ranger, peak calling is often done automatically. However, for custom analysis or non-10x data, you aggregate fragments per cluster and run MACS2. I must clarify that iterative peak calling is the gold standard (Cluster cells -> Call peaks -> Remap cells). I will explain this concept.
Motif Enrichment: Mention chromVAR specifically. It is the standard.
Okay, ready to generate.
This guide provides a comprehensive workflow for processing single-cell ATAC-seq (scATAC-seq) data. We will cover the journey from raw sequencing reads to biological interpretation, focusing on the Signac (R) ecosystem, which is the industry standard for this type of analysis.
Workflow Overview
- Pre-processing: Alignment & Fragment Deduplication (Command Line).
- Data Structure: Peak-Cell Matrix generation.
- Peak Calling: Identifying regulatory regions.
- Dimensionality Reduction: Latent Semantic Indexing (LSI).
- Integration: scATAC + scRNA-seq alignment.
- Motif Enrichment: Finding Transcription Factor drivers.
Part 1: Alignment & Fragment Deduplication
(Command Line / Terminal)
Before entering R/Python, raw FASTQ files must be processed. Unlike scRNA-seq, which uses UMI-tools for deduplication, scATAC-seq relies on coordinate sorting and removal of PCR duplicates based on mapping positions.
Tools: Cell Ranger ATAC (10x Genomics) or Chromap (FAST).
The Process
- Alignment: Map reads to a reference genome (e.g., GRCh38).
- Barcode Processing: Correct cell barcodes (allowing 1 mismatch) and attach them to aligned fragments.
- Deduplication: This is critical. You must remove fragments where:
- The start position is identical.
- The end position is identical.
- The cell barcode is identical.
- Note: 10x Cell Ranger does this automatically to produce the
fragments.tsv.gz file.
Key Output: fragments.tsv.gz
This is the raw material for scATAC analysis. It is a tab-separated file containing: Chromosome, Start, End, Barcode, Duplicate_Score.
Part 2: Quantification & Peak Calling
(R / Signac)
In scATAC, we do not count "genes." We count "accessibility in genomic regions."
1. Load Data & Create Object
We need the fragments file and a gene annotation (GTF).
library(Signac)
library(Seurat)
library(EnsDb.Hsapiens.v86) # Example for Human
# 1. Load metadata (usually from Cell Ranger output)
metadata <- read.csv("atac_v1_pbmc_10k_singlecell.csv", header = TRUE, row.names = 1)
# 2. Load Fragment file
fragment_file <- "fragments.tsv.gz"
# 3. Create Chromatin Assay
chrom_assay <- CreateChromatinAssay(
fragments = fragment_file,
sep = c("\t", "\t"), # Delimiters in fragments file
min.cells = 10,
genome = "hg38"
)
pbmc <- CreateSeuratObject(counts = chrom_assay, meta.data = metadata)
2. Peak Calling (Pseudo-bulk)
You cannot call peaks on a single cell (too sparse). We use a "pseudo-bulk" approach:
- Group cells by cluster (or treat the whole sample as one).
- Aggregate the fragment coverage.
- Run MACS2 (Model-based Analysis of ChIP-Seq) to find peaks.
# If you have pre-called peaks (e.g., from Cell Ranger), load them directly:
peaks <- read.table("peaks.bed", header = FALSE)
colnames(peaks) <- c("chr", "start", "end")
# If calling peaks de-novo (requires MACS2 installed):
pbmc <- CallPeaks(
object = pbmc,
macs2.path = "/path/to/macs2",
effective.genome.size = 2.7e9 # Human
)
3. Peak-Cell Matrix
Now we create a binary matrix:
- Rows: Peaks (Regions).
- Cols: Cells.
- Values: 1 (Accessible) or 0 (Not).
This matrix is extremely sparse (mostly zeros).
Part 3: Dimensionality Reduction (LSI)
scATAC data has a different noise structure than scRNA-seq. PCA is often insufficient. The standard method is LSI (Latent Semantic Indexing), adapted from natural language processing.
1. Term Frequency - Inverse Document Frequency (TF-IDF)
This normalizes the data.
- Term Frequency (TF): Normalizes counts by total fragments per cell.
- Inverse Document Frequency (IDF): Down-weights peaks that appear in every cell (ubiquitous accessibility is noise) and up-weights rare peaks.
pbmc <- RunTFIDF(pbmc)
2. Singular Value Decomposition (SVD)
This reduces dimensionality. We take the top 50 singular values.
pbmc <- FindTopFeatures(pbmc, min.cutoff = 'q0') # Use all features
pbmc <- RunSVD(pbmc)
3. Correction: Removing the "Depth Component"
In scATAC, the first component of LSI (LSI_1) often correlates perfectly with sequencing depth (technical noise), not biology. You must plot LSI_1 vs Depth and remove it if correlated.
DepthCor(pbmc) # Visual check
# Usually, we use LSI_2 through LSI_50 for clustering.
pbmc <- RunUMAP(pbmc, reduction = 'lsi', dims = 2:30)
pbmc <- FindNeighbors(pbmc, reduction = 'lsi', dims = 2:30)
pbmc <- FindClusters(pbmc, resolution = 0.5)
Part 4: Integration with scRNA-seq
scATAC tells you where chromatin is open, but not which genes are expressed. scRNA tells you expression levels. By integrating them, we can label scATAC clusters with known cell types from scRNA data.
Method: "Reference-based mapping" (Canonical Correlation Analysis - CCA).
1. Load RNA Reference
# Load a pre-processed scRNA object (Reference)
pbmc_rna <- readRDS("pbmc_rna.rds")
2. Find Anchors
We find pairs of cells (one ATAC, one RNA) that are mutual neighbors in a shared low-dimensional space. Signac converts the ATAC peaks into a "gene activity score" (counting fragments in the gene body + promoter) to make it comparable to RNA expression.
transfer.anchors <- FindTransferAnchors(
reference = pbmc_rna,
query = pbmc,
reduction = 'cca', # or 'pcaproject'
features = VariableFeatures(pbmc_rna),
dims = 1:30
)
3. Transfer Labels
predicted.labels <- TransferData(
anchorset = transfer.anchors,
weight.reduction = pbmc[['lsi']], # Use LSI from ATAC
dims = 2:30
)
pbmc <- AddMetaData(pbmc, metadata = predicted.labels)
Part 5: Regulatory Motif Enrichment
We want to know why a specific cluster is distinct. Which Transcription Factors (TFs) are binding to the accessible regions?
We use the chromVAR algorithm.
- Scan the genome for motif sequences (using a database like JASPAR).
- Calculate a "deviation score" for every cell: Is the cell more or less accessible in regions containing that motif than the average cell?
1. Add Motif Information
library(JASPAR2020)
library(TFBSTools)
library(motifmatchr)
library(chromVAR)
# Get motif matrix from JASPAR database
pfm <- getMatrixSet(x = JASPAR2020, opts = list(species = "Homo sapiens"))
# Add motif annotations to the Seurat object
pbmc <- AddMotifs(
object = pbmc,
genome = BSgenome.Hsapiens.UCSC.hg38, # Needs a BSgenome object
pfm = pfm
)
2. Run chromVAR
pbmc <- RunChromVAR(
object = pbmc,
genome = BSgenome.Hsapiens.UCSC.hg38
)
3. Visualize
Now you can plot the "Motif Deviation Score" just like a gene expression UMAP.
- If Cluster 1 is T-cells, you expect high deviation scores for the TCF7 motif.
FeaturePlot(pbmc, features = "MA0031-TCF7", reduction = "umap")
Summary of Key Concepts
| Step | scRNA-seq Logic | scATAC-seq Logic |
|---|
| Input | FASTQ -> cDNA Counts | FASTQ -> Fragment File |
| Quantification | Gene Expression Matrix | Peak-Cell Matrix (Binary) |
| Normalization | LogNormalize (CPM/Log1p) | TF-IDF |
| Dim. Reduction | PCA | LSI (SVD on TF-IDF) |
| Integration | CCA / RPCA | Reference Mapping (Gene Activity) |
| Bio Insight | Differential Expression | Motif Enrichment (chromVAR) |