For very large datasets, the standard integration workflow can sometimes be prohibitively computationally expensive. In this workflow, we employ two options that can improve efficiency and runtimes:

  1. Reciprocal PCA (RPCA)
  2. Reference-based integration

The main efficiency improvements are gained in FindIntegrationAnchors(). First, we use reciprocal PCA (RPCA) instead of CCA, to identify an effective space in which to find anchors. When determining anchors between any two datasets using reciprocal PCA, we project each dataset into the others PCA space and constrain the anchors by the same mutual neighborhood requirement. All downstream integration steps remain the same and we are able to ‘correct’ (or harmonize) the datasets.

Additionally, we use reference-based integration. In the standard workflow, we identify anchors between all pairs of datasets. While this gives datasets equal weight in downstream integration, it can also become computationally intensive. For example when integrating 10 different datasets, we perform 45 different pairwise comparisons. As an alternative, we introduce here the possibility of specifying one or more of the datasets as the ‘reference’ for integrated analysis, with the remainder designated as ‘query’ datasets. In this workflow, we do not identify anchors between pairs of query datasets, reducing the number of comparisons. For example, when integrating 10 datasets with one specified as a reference, we perform only 9 comparisons. Reference-based integration can be applied to either log-normalized or SCTransform-normalized datasets.

This alternative workflow consists of the following steps:

  • Create a list of Seurat objects to integrate
  • Perform normalization, feature selection, and scaling separately for each dataset
  • Run PCA on each object in the list
  • Integrate datasets, and proceed with joint analysis

In general, we observe strikingly similar results between the standard workflow and the one demonstrated here, with substantial reduction in compute time and memory. However, if the datasets are highly divergent (for example, cross-modality mapping or cross-species mapping), where only a small subset of features can be used to facilitate integration, and you may observe superior results using CCA.

For this example, we will be using the “Immune Cell Atlas” data from the Human Cell Atlas which can be found here.

After acquiring the data, we first perform standard normalization and variable feature selection.

bm280k.data <- Read10X_h5("../data/ica_bone_marrow_h5.h5")
bm280k <- CreateSeuratObject(counts = bm280k.data, min.cells = 100, min.features = 500)
bm280k.list <- SplitObject(bm280k, split.by = "orig.ident")
bm280k.list <- lapply(X = bm280k.list, FUN = function(x) {
    x <- NormalizeData(x, verbose = FALSE)
    x <- FindVariableFeatures(x, verbose = FALSE)
})

Next, select features for downstream integration, and run PCA on each object in the list, which is required for running the alternative reciprocal PCA workflow.

features <- SelectIntegrationFeatures(object.list = bm280k.list)
bm280k.list <- lapply(X = bm280k.list, FUN = function(x) {
    x <- ScaleData(x, features = features, verbose = FALSE)
    x <- RunPCA(x, features = features, verbose = FALSE)
})

Since this dataset contains both men and women, we will chose one male and one female (BM1 and BM2) to use in a reference-based workflow. We determined donor sex by examining the expression of the XIST gene.

anchors <- FindIntegrationAnchors(object.list = bm280k.list, reference = c(1, 2), reduction = "rpca",
    dims = 1:50)
bm280k.integrated <- IntegrateData(anchorset = anchors, dims = 1:50)
bm280k.integrated <- ScaleData(bm280k.integrated, verbose = FALSE)
bm280k.integrated <- RunPCA(bm280k.integrated, verbose = FALSE)
bm280k.integrated <- RunUMAP(bm280k.integrated, dims = 1:50)
DimPlot(bm280k.integrated, group.by = "orig.ident")

Session Info

## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
## 
## Matrix products: default
## BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
## 
## 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=C             
##  [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] ggplot2_3.3.5      SeuratObject_4.0.2 Seurat_4.0.4      
## 
## loaded via a namespace (and not attached):
##   [1] Rtsne_0.15            colorspace_2.0-2      deldir_0.2-10        
##   [4] ellipsis_0.3.2        ggridges_0.5.3        rprojroot_2.0.2      
##   [7] fs_1.5.0              spatstat.data_2.1-0   farver_2.1.0         
##  [10] leiden_0.3.8          listenv_0.8.0         bit64_4.0.5          
##  [13] ggrepel_0.9.1         RSpectra_0.16-0       fansi_0.5.0          
##  [16] codetools_0.2-18      splines_4.1.0         cachem_1.0.5         
##  [19] knitr_1.33            polyclip_1.10-0       jsonlite_1.7.2       
##  [22] ica_1.0-2             cluster_2.1.2         png_0.1-7            
##  [25] uwot_0.1.10           shiny_1.6.0           sctransform_0.3.2    
##  [28] spatstat.sparse_2.0-0 compiler_4.1.0        httr_1.4.2           
##  [31] assertthat_0.2.1      Matrix_1.3-3          fastmap_1.1.0        
##  [34] lazyeval_0.2.2        later_1.2.0           formatR_1.11         
##  [37] htmltools_0.5.1.1     tools_4.1.0           igraph_1.2.6         
##  [40] gtable_0.3.0          glue_1.4.2            RANN_2.6.1           
##  [43] reshape2_1.4.4        dplyr_1.0.7           Rcpp_1.0.7           
##  [46] scattermore_0.7       jquerylib_0.1.4       pkgdown_1.6.1        
##  [49] vctrs_0.3.8           nlme_3.1-152          lmtest_0.9-38        
##  [52] xfun_0.25             stringr_1.4.0         globals_0.14.0       
##  [55] mime_0.11             miniUI_0.1.1.1        lifecycle_1.0.0      
##  [58] irlba_2.3.3           goftest_1.2-2         future_1.21.0        
##  [61] MASS_7.3-54           zoo_1.8-9             scales_1.1.1         
##  [64] spatstat.core_2.1-2   ragg_1.1.3            promises_1.2.0.1     
##  [67] spatstat.utils_2.1-0  parallel_4.1.0        RColorBrewer_1.1-2   
##  [70] yaml_2.2.1            memoise_2.0.0         reticulate_1.20      
##  [73] pbapply_1.4-3         gridExtra_2.3         sass_0.4.0           
##  [76] rpart_4.1-15          stringi_1.7.3         highr_0.9            
##  [79] desc_1.3.0            rlang_0.4.11          pkgconfig_2.0.3      
##  [82] systemfonts_1.0.2     matrixStats_0.60.0    evaluate_0.14        
##  [85] lattice_0.20-44       tensor_1.5            ROCR_1.0-11          
##  [88] purrr_0.3.4           labeling_0.4.2        patchwork_1.1.1      
##  [91] htmlwidgets_1.5.3     bit_4.0.4             cowplot_1.1.1        
##  [94] tidyselect_1.1.1      parallelly_1.26.0     RcppAnnoy_0.0.18     
##  [97] plyr_1.8.6            magrittr_2.0.1        R6_2.5.0             
## [100] generics_0.1.0        DBI_1.1.1             withr_2.4.2          
## [103] mgcv_1.8-35           pillar_1.6.2          fitdistrplus_1.1-5   
## [106] abind_1.4-5           survival_3.2-11       tibble_3.1.3         
## [109] future.apply_1.7.0    hdf5r_1.3.3           crayon_1.4.1         
## [112] KernSmooth_2.23-20    utf8_1.2.2            spatstat.geom_2.1-0  
## [115] plotly_4.9.4          rmarkdown_2.10        grid_4.1.0           
## [118] data.table_1.14.0     digest_0.6.27         xtable_1.8-4         
## [121] tidyr_1.1.3           httpuv_1.6.1          textshaping_0.3.5    
## [124] munsell_0.5.0         viridisLite_0.4.0     bslib_0.2.5.1