Gene Detection Analysis for scRNA-seq

Ruoxin Li, Gerald Quon

2021-10-26

Introduction

This tutorial provides an example analysis for modelling gene detection pattern as outlined in R.Li et al, 2018. The goal of this tutorial is to provide an overview of the cell type classification and visualization tasks by learning a low dimensional embedding through a class of gene detection models: that is BFA and Binary PCA.

Summary of workflow

The following workflow summarizes a typical dimensionality reduction procedure performed by BFA or Binary PCA.

  1. Data processing
  2. Dimensionality reduction
  3. Visualization

Installation

Let’s start with the installation

next we can load dependent packages

Information of example dataset

The example dataset is generated from our scRNA-seq pre-DC/cDC dataset sourced from https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE89232 After performing all quality control procedure of genes and cells (as outlined in the paper), we then select 500 most variable genes for illustration purpose. The example dataset consists of 950 cells and 500 genes

Working with SingleCellExperiment class

The design of BFA and Binary PCA allows three kinds of input object(scData):

For illustration, here we construct a singleCellExperiment class to be the input of BFA and Binary PCA.

Gene Detection Model analysis

Binary Factor Analysis

Let \(N\) stands for number of cells, \(G\) stands for the number of genes, and \(K\) stands for the number of latent dimensions.

A bfa model object computes the following parameters after fitting the gene detection matrix.

  1. \(Z\) is \(N\) by \(K\) embedding matrix and is named as “ZZ” in the model object
  2. \(A\) is \(G\) by \(K\) loading matrix and is named as “AA” in the model object
  3. \(\beta\) if there is cell-level covariates (e.g batch effect), \(\beta\) is corresponding coefficient matrix and is named as “beta” in the model object
  4. \(\gamma\) if there is gene-level covariates (e.g QC measures), \(\gamma\) is corresponding coefficient matrix and is named as “gamma” in the model object

We choose 3 as number of latent dimensions and project the gene detection matrix on the embedding space.

We then visualize the low dimensional embedding of BFA in tSNE space. Points are colored by their corresponding cell types.

Session Info

sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [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] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] scBFA_1.8.0                 ggplot2_3.3.5              
#>  [3] zinbwave_1.16.0             SingleCellExperiment_1.16.0
#>  [5] SummarizedExperiment_1.24.0 Biobase_2.54.0             
#>  [7] GenomicRanges_1.46.0        GenomeInfoDb_1.30.0        
#>  [9] IRanges_2.28.0              S4Vectors_0.32.0           
#> [11] BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
#> [13] matrixStats_0.61.0         
#> 
#> loaded via a namespace (and not attached):
#>   [1] copula_1.0-1           plyr_1.8.6             igraph_1.2.7          
#>   [4] lazyeval_0.2.2         splines_4.1.1          pspline_1.0-18        
#>   [7] BiocParallel_1.28.0    listenv_0.8.0          scattermore_0.7       
#>  [10] digest_0.6.28          htmltools_0.5.2        fansi_0.5.0           
#>  [13] magrittr_2.0.1         memoise_2.0.0          tensor_1.5            
#>  [16] cluster_2.1.2          ROCR_1.0-11            limma_3.50.0          
#>  [19] globals_0.14.0         Biostrings_2.62.0      annotate_1.72.0       
#>  [22] stabledist_0.7-1       spatstat.sparse_2.0-0  colorspace_2.0-2      
#>  [25] blob_1.2.2             ggrepel_0.9.1          xfun_0.27             
#>  [28] dplyr_1.0.7            crayon_1.4.1           RCurl_1.98-1.5        
#>  [31] jsonlite_1.7.2         genefilter_1.76.0      spatstat.data_2.1-0   
#>  [34] survival_3.2-13        zoo_1.8-9              glue_1.4.2            
#>  [37] polyclip_1.10-0        gtable_0.3.0           zlibbioc_1.40.0       
#>  [40] XVector_0.34.0         leiden_0.3.9           DelayedArray_0.20.0   
#>  [43] future.apply_1.8.1     abind_1.4-5            scales_1.1.1          
#>  [46] mvtnorm_1.1-3          DBI_1.1.1              edgeR_3.36.0          
#>  [49] miniUI_0.1.1.1         Rcpp_1.0.7             viridisLite_0.4.0     
#>  [52] xtable_1.8-4           reticulate_1.22        spatstat.core_2.3-0   
#>  [55] bit_4.0.4              htmlwidgets_1.5.4      httr_1.4.2            
#>  [58] RColorBrewer_1.1-2     ellipsis_0.3.2         Seurat_4.0.5          
#>  [61] ica_1.0-2              farver_2.1.0           pkgconfig_2.0.3       
#>  [64] XML_3.99-0.8           uwot_0.1.10            deldir_1.0-6          
#>  [67] sass_0.4.0             locfit_1.5-9.4         utf8_1.2.2            
#>  [70] labeling_0.4.2         tidyselect_1.1.1       rlang_0.4.12          
#>  [73] softImpute_1.4-1       reshape2_1.4.4         later_1.3.0           
#>  [76] AnnotationDbi_1.56.0   munsell_0.5.0          tools_4.1.1           
#>  [79] cachem_1.0.6           generics_0.1.1         RSQLite_2.2.8         
#>  [82] ggridges_0.5.3         evaluate_0.14          stringr_1.4.0         
#>  [85] fastmap_1.1.0          goftest_1.2-3          yaml_2.2.1            
#>  [88] knitr_1.36             bit64_4.0.5            fitdistrplus_1.1-6    
#>  [91] purrr_0.3.4            RANN_2.6.1             KEGGREST_1.34.0       
#>  [94] nlme_3.1-153           pbapply_1.5-0          future_1.22.1         
#>  [97] mime_0.12              compiler_4.1.1         plotly_4.10.0         
#> [100] png_0.1-7              spatstat.utils_2.2-0   tibble_3.1.5          
#> [103] geneplotter_1.72.0     pcaPP_1.9-74           gsl_2.1-7             
#> [106] bslib_0.3.1            stringi_1.7.5          highr_0.9             
#> [109] lattice_0.20-45        Matrix_1.3-4           vctrs_0.3.8           
#> [112] pillar_1.6.4           lifecycle_1.0.1        ADGofTest_0.3         
#> [115] spatstat.geom_2.3-0    lmtest_0.9-38          jquerylib_0.1.4       
#> [118] RcppAnnoy_0.0.19       data.table_1.14.2      cowplot_1.1.1         
#> [121] bitops_1.0-7           irlba_2.3.3            httpuv_1.6.3          
#> [124] patchwork_1.1.1        R6_2.5.1               promises_1.2.0.1      
#> [127] KernSmooth_2.23-20     gridExtra_2.3          parallelly_1.28.1     
#> [130] codetools_0.2-18       MASS_7.3-54            assertthat_0.2.1      
#> [133] DESeq2_1.34.0          withr_2.4.2            SeuratObject_4.0.2    
#> [136] sctransform_0.3.2      GenomeInfoDbData_1.2.7 mgcv_1.8-38           
#> [139] parallel_4.1.1         rpart_4.1-15           grid_4.1.1            
#> [142] tidyr_1.1.4            rmarkdown_2.11         Rtsne_0.15            
#> [145] numDeriv_2016.8-1.1    shiny_1.7.1