Here we demonstrate the integration of multiple single-cell ATAC-seq datasets from the adult mouse brain, profiled using 10x Genomics and sci-ATAC-seq. The dataset from 10x Genomics is the same as used in our mouse brain vignette, and you can find links to download the raw data as well as the code used to produce the processed Seurat object used in this vignette on the mouse brain vignette page.

The sci-ATAC-seq dataset was generated by Cusanovich and Hill et al.. Raw data can be downloaded from the authors’ website:

We will demonstrate the use of Seurat v3 integration methods described here on scATAC-seq data, for both dataset integration and label transfer between datasets, as well as use of the harmony package for dataset integration.

First, we load the required packages, read in the data and create a Seurat object for the sci-ATAC-seq data.

Preprocessing

library(Signac)
library(Seurat)
set.seed(1234)

# this object was created following the mouse brain vignette
tenx <- readRDS(file = "../vignette_data/adult_mouse_brain.rds")
tenx$tech <- '10x'
tenx$celltype <- Idents(tenx)

sci.metadata <- read.table(
  file = "../vignette_data/sci/cell_metadata.txt",
  header = TRUE,
  row.names = 1,
  sep = "\t"
)
# subset to include only the brain data
sci.metadata <- sci.metadata[sci.metadata$tissue == 'PreFrontalCortex', ]
sci.counts <- readRDS(file = "../vignette_data/sci/atac_matrix.binary.qc_filtered.rds")
sci.counts <- sci.counts[, rownames(x = sci.metadata)]

The sci-ATAC-seq data was mapped to the mm9 mouse genome, whereas the 10x data was mapped to mm10, and so the coordinate space of the peaks in each experiment are different. We can lift over the mm9 coordinates to mm10 using the rtracklayer package, and rename the sci-ATAC-seq peaks with mm10 coordinates. Liftover chains can be downloaded from UCSC. See this post on biostars for more information about lifting over genomic coordinates.

sci_peaks_mm9 <- StringToGRanges(regions = rownames(sci.counts), sep = c("_", "_"))
mm9_mm10 <- rtracklayer::import.chain("/home/stuartt/data/liftover/mm9ToMm10.over.chain")
sci_peaks_mm10 <- rtracklayer::liftOver(x = sci_peaks_mm9, chain = mm9_mm10)
names(sci_peaks_mm10) <- rownames(sci.counts)

# discard any peaks that were mapped to >1 region in mm10
correspondence <- S4Vectors::elementNROWS(sci_peaks_mm10)
sci_peaks_mm10 <- sci_peaks_mm10[correspondence == 1]
sci_peaks_mm10 <- unlist(sci_peaks_mm10)
sci.counts <- sci.counts[names(sci_peaks_mm10), ]

# rename peaks with mm10 coordinates
rownames(sci.counts) <- GRangesToString(grange = sci_peaks_mm10)

# create Seurat object and perform some basic QC filtering
sci <- CreateSeuratObject(
  counts = sci.counts,
  meta.data = sci.metadata,
  assay = 'peaks',
  project = 'sci'
)
sci <- sci[, sci$nFeature_peaks > 2000 & !(sci$cell_label %in% c("Collisions", "Unknown"))]
sci$tech <- 'sciATAC'
sci <- RunTFIDF(sci)
sci <- FindTopFeatures(sci, min.cutoff = 50)
sci <- RunSVD(sci, n = 30, reduction.name = 'lsi', reduction.key = 'LSI_')
sci <- RunUMAP(sci, reduction = 'lsi', dims = 1:30)

We now have two scATAC-seq objects containing features in a common coordinate space. However, as the peak calling was performed independently in each experiment, it is unlikely that the peak coordinates overlap perfectly. In order to have common features across the datasets we want to integrate, we can count reads in the sci-ATAC-seq peaks in the 10x Genomics dataset and create a new assay with these counts. For efficiency, we will downsample the sci-ATAC-seq peaks used. We have found integration results to be quite robust to the number and set of peaks used.

# find peaks that intersect in both datasets
intersecting.regions <- GetIntersectingFeatures(
  object.1 = sci,
  object.2 = tenx,
  sep.1 = c("-", "-"),
  sep.2 = c(":", "-")
)

# choose a subset of intersecting peaks
peaks.use <- sample(intersecting.regions[[1]], size = 10000, replace = FALSE)

# count fragments per cell overlapping the set of peaks in the 10x data
sci_peaks_tenx <- FeatureMatrix(
  fragments = GetFragments(object = tenx, assay = 'peaks'),
  features = StringToGRanges(peaks.use),
  cells = colnames(tenx)
)

# create a new assay and add it to the 10x dataset
tenx[['sciPeaks']] <- CreateAssayObject(counts = sci_peaks_tenx, min.cells = 1)
tenx <- RunTFIDF(object = tenx, assay = 'sciPeaks')

Integration

Before performing integration it is always a good idea to check if there are dataset-specific difference present that need to be removed. If not, we could simply merge the objects without performing integration. In this case there is a strong difference between the two datasets due to the different technologies used. This effect can be removed using the integration methods in Seurat v3 described in this paper.

# Look at the data without integration first
unintegrated <- MergeWithRegions(
  object.1 = sci,
  object.2 = tenx,
  sep.1 = c("-", "-"),
  sep.2 = c(":", "-")
)

unintegrated <- RunTFIDF(unintegrated)
unintegrated <- FindTopFeatures(unintegrated, min.cutoff = 50)
unintegrated <- RunSVD(unintegrated, n = 30, reduction.name = 'lsi', reduction.key = 'LSI_')
unintegrated <- RunUMAP(unintegrated, reduction = 'lsi', dims = 1:30)
p1 <- DimPlot(unintegrated, group.by = 'tech', pt.size = 0.1) + ggplot2::ggtitle("Unintegrated")

# find integration anchors between 10x and sci-ATAC
anchors <- FindIntegrationAnchors(
  object.list = list(tenx, sci),
  anchor.features = peaks.use,
  assay = c('sciPeaks', 'peaks'),
  k.filter = NA
)

# integrate data and create a new merged object
integrated <- IntegrateData(
  anchorset = anchors,
  weight.reduction = sci[['lsi']],
  preserve.order = TRUE
)

# we now have a "corrected" TF-IDF matrix, and can run LSI again on this corrected matrix
integrated <- RunSVD(
  object = integrated,
  n = 30,
  reduction.name = 'integratedLSI'
)

integrated <- RunUMAP(
  object = integrated,
  dims = 1:30,
  reduction = 'integratedLSI'
)

p2 <- DimPlot(integrated, group.by = 'tech', pt.size = 0.1) + ggplot2::ggtitle("Integrated")
CombinePlots(list(p1, p2), ncol = 2)

Label transfer

We can also use Seurat to transfer data from one dataset to another. We previously demonstrated this between scRNA-seq datasets, and between scRNA-seq and scATAC-seq datasets (https://doi.org/10.1016/j.cell.2019.05.031). Here, we demonstrate data transfer between two single-cell ATAC-seq datasets by transferring the cell type label from the 10x Genomics scATAC-seq data to the sci-ATAC-seq data.

transfer.anchors <- FindTransferAnchors(
  reference = tenx,
  query = sci,
  reference.assay = 'sciPeaks',
  query.assay = 'peaks',
  reduction = 'cca',
  features = peaks.use,
  k.filter = NA
)

predicted.id <- TransferData(
  anchorset = transfer.anchors,
  refdata = tenx$celltype,
  weight.reduction = sci[['lsi']]
)

sci <- AddMetaData(
  object = sci,
  metadata = predicted.id
)

sci$predicted.id <- factor(sci$predicted.id, levels = levels(tenx$celltype))  # to make the colors match

p3 <- DimPlot(tenx, group.by = 'celltype', label = TRUE) + NoLegend() + ggplot2::ggtitle("Celltype labels 10x scATAC-seq")
p4 <- DimPlot(sci, group.by = 'predicted.id', label = TRUE) + NoLegend() + ggplot2::ggtitle("Predicted labels sci-ATAC-seq")
CombinePlots(list(p3, p4), ncol = 2)

Integration with Harmony

While Seurat adjusts the underlying high-dimensional data in order to correct for differences between the groups, harmony (developed by the Raychaudhuri lab) adjusts the low-dimensional cell embeddings to to reduce the dependence between cluster assignment and dataset of origin. You can read more about Harmony here.

Harmony requires a single object as input, so here we merge the sci-ATAC-seq and scATAC-seq datasets in a coordinate-aware manner using the MergeWithRegions function, and then compute LSI embeddings using the merged object. Once we have computed the LSI embeddings, we can run the RunHarmony function from the harmony package and provide the technology used as a grouping variable to remove the batch difference between the sci-ATAC-seq and 10x Genomics scATAC-seq datasets. This produces a set of “corrected” LSI embeddings that can be used for further dimension reduction with UMAP or tSNE, and for clustering.

brain <- MergeWithRegions(
  object.1 = tenx,
  object.2 = sci,
  sep.1 = c(":", "-"),
  sep.2 = c("-", "-")
)

brain <- FindTopFeatures(brain, min.cutoff = 0)
brain <- RunTFIDF(brain)
brain <- RunSVD(brain, n = 30, reduction.name = 'lsi', reduction.key = 'LSI_')
brain <- RunUMAP(brain, dims = 1:30, reduction = 'lsi')
p5 <- DimPlot(brain, group.by = 'tech', pt.size = 0.1) + ggplot2::ggtitle("Unintegrated")

library(harmony)

brain <- RunHarmony(
  object = brain,
  group.by.vars = 'tech',
  reduction = 'lsi',
  assay.use = 'peaks',
  project.dim = FALSE
)

# re-compute the UMAP using corrected LSI embeddings
brain <- RunUMAP(brain, dims = 1:30, reduction = 'harmony')
p6 <- DimPlot(brain, group.by = 'tech', pt.size = 0.1) + ggplot2::ggtitle("Harmony integration")
CombinePlots(plots = list(p5, p6), ncol = 2)

Session Info

## R version 3.6.1 (2019-07-05)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.3 LTS
##
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
##
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
##  [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] stats     graphics  grDevices utils     datasets  methods   base
##
## other attached packages:
## [1] harmony_1.0       Rcpp_1.0.3        Seurat_3.1.1.9010 Signac_0.1.6
##
## loaded via a namespace (and not attached):
##   [1] reticulate_1.13             R.utils_2.9.0
##   [3] tidyselect_0.2.5            poweRlaw_0.70.2
##   [5] RSQLite_2.1.2               AnnotationDbi_1.46.1
##   [7] htmlwidgets_1.5.1           grid_3.6.1
##   [9] BiocParallel_1.18.1         Rtsne_0.15
##  [11] munsell_0.5.0               codetools_0.2-16
##  [13] ica_1.0-2                   future_1.15.0
##  [15] colorspace_1.4-1            OrganismDbi_1.26.0
##  [17] Biobase_2.44.0              knitr_1.25
##  [19] rstudioapi_0.10             stats4_3.6.1
##  [21] ROCR_1.0-7                  gbRd_0.4-11
##  [23] listenv_0.7.0               labeling_0.3
##  [25] Rdpack_0.11-0               GenomeInfoDbData_1.2.1
##  [27] bit64_0.9-7                 rprojroot_1.3-2
##  [29] vctrs_0.2.0                 xfun_0.10
##  [31] biovizBase_1.32.0           ggseqlogo_0.1
##  [33] R6_2.4.0                    GenomeInfoDb_1.20.0
##  [35] rsvd_1.0.2                  VGAM_1.1-1
##  [37] AnnotationFilter_1.8.0      bitops_1.0-6
##  [39] reshape_0.8.8               DelayedArray_0.10.0
##  [41] assertthat_0.2.1            SDMTools_1.1-221.1
##  [43] scales_1.0.0                nnet_7.3-12
##  [45] gtable_0.3.0                npsurv_0.4-0
##  [47] globals_0.12.4              ggbio_1.32.0
##  [49] ensembldb_2.8.1             seqLogo_1.50.0
##  [51] rlang_0.4.1                 zeallot_0.1.0
##  [53] splines_3.6.1               rtracklayer_1.44.4
##  [55] lazyeval_0.2.2              acepack_1.4.1
##  [57] dichromat_2.0-0             checkmate_1.9.4
##  [59] BiocManager_1.30.9          yaml_2.2.0
##  [61] reshape2_1.4.3              GenomicFeatures_1.36.4
##  [63] backports_1.1.5             Hmisc_4.3-0
##  [65] RBGL_1.60.0                 tools_3.6.1
##  [67] ggplot2_3.2.1               ellipsis_0.3.0
##  [69] gplots_3.0.1.1              RColorBrewer_1.1-2
##  [71] BiocGenerics_0.30.0         ggridges_0.5.1
##  [73] plyr_1.8.4                  base64enc_0.1-3
##  [75] progress_1.2.2              zlibbioc_1.30.0
##  [77] purrr_0.3.3                 RCurl_1.95-4.12
##  [79] prettyunits_1.0.2           rpart_4.1-15
##  [81] pbapply_1.4-2               cowplot_1.0.0
##  [83] S4Vectors_0.22.1            zoo_1.8-6
##  [85] SummarizedExperiment_1.14.1 ggrepel_0.8.1
##  [87] cluster_2.1.0               fs_1.3.1
##  [89] motifmatchr_1.6.0           magrittr_1.5
##  [91] RSpectra_0.15-0             data.table_1.12.6
##  [93] lmtest_0.9-37               RANN_2.6.1
##  [95] ProtGenerics_1.16.0         fitdistrplus_1.0-14
##  [97] matrixStats_0.55.0          hms_0.5.2
##  [99] lsei_1.2-0                  evaluate_0.14
## [101] xtable_1.8-4                XML_3.98-1.20
## [103] IRanges_2.18.3              gridExtra_2.3
## [105] compiler_3.6.1              biomaRt_2.40.5
## [107] tibble_2.1.3                KernSmooth_2.23-16
## [109] crayon_1.3.4                R.oo_1.23.0
## [111] htmltools_0.4.0             Formula_1.2-3
## [113] TFBSTools_1.22.0            tidyr_1.0.0
## [115] RcppParallel_4.4.4          DBI_1.0.0
## [117] MASS_7.3-51.4               Matrix_1.2-17
## [119] readr_1.3.1                 R.methodsS3_1.7.1
## [121] gdata_2.18.0                parallel_3.6.1
## [123] metap_1.1                   igraph_1.2.4.1
## [125] GenomicRanges_1.36.1        pkgconfig_2.0.3
## [127] pkgdown_1.4.1               GenomicAlignments_1.20.1
## [129] TFMPvalue_0.0.8             foreign_0.8-72
## [131] plotly_4.9.1                annotate_1.62.0
## [133] DirichletMultinomial_1.26.0 XVector_0.24.0
## [135] bibtex_0.4.2                VariantAnnotation_1.30.1
## [137] stringr_1.4.0               digest_0.6.22
## [139] sctransform_0.2.0           RcppAnnoy_0.0.14
## [141] tsne_0.1-3                  graph_1.62.0
## [143] CNEr_1.20.0                 Biostrings_2.52.0
## [145] rmarkdown_1.16              leiden_0.3.1
## [147] htmlTable_1.13.2            uwot_0.1.4
## [149] curl_4.2                    Rsamtools_2.0.3
## [151] gtools_3.8.1                lifecycle_0.1.0
## [153] nlme_3.1-142                jsonlite_1.6
## [155] desc_1.2.0                  viridisLite_0.3.0
## [157] BSgenome_1.52.0             pillar_1.4.2
## [159] lattice_0.20-38             GGally_1.4.0
## [161] KEGGREST_1.24.1             httr_1.4.1
## [163] survival_3.1-7              GO.db_3.8.2
## [165] glue_1.3.1                  png_0.1-7
## [167] bit_1.1-14                  stringi_1.4.3
## [169] blob_1.2.0                  latticeExtra_0.6-28
## [171] caTools_1.17.1.2            memoise_1.1.0
## [173] dplyr_0.8.3                 irlba_2.3.3
## [175] future.apply_1.3.0          ape_5.3