Resolution of curse of dimensionality (RECODE) is a noise reduction method for single-cell sequencing data. This vignette briefly demonstrates how to run RECODE on single-cell RNA-seq data and store the result in Seurat object.

1 Set up

if (!require(RECODE)) devtools::install_github("yusuke-imoto-lab/RECODE/R")

1.1 Import libraries

Though we use Seurat v4 in this tutorial, we have checked Seurat v3 also works.

library(Seurat)
library(Matrix)
library(RECODE)

1.2 Import data

Sample data: For this tutorial, we use sample 10k Human PBMCs, 3’ v3.1, Chromium Controller (11,485 cells and 36,601 genes) in 10X Genomics Datasets. The test data is deposited as Feature / cell matrix HDF5 (filterd) here (registration required).

seurat <- Read10X_h5("10k_PBMC_3p_nextgem_Chromium_Controller_filtered_feature_bc_matrix.h5")
## Warning in sparseMatrix(i = indices[] + 1, p = indptr[], x = as.numeric(x = counts[]), : 'giveCsparse' has been deprecated; setting 'repr = "T"' for you
seurat <- CreateSeuratObject(seurat)

2 Run RECODE

We apply RECODE on a count matrix where each row is a gene and each column is a cell. The output is a denoised count matrix.

data <- as.matrix(seurat[["RNA"]]@counts)
data_RECODE <- RECODE(data)
## --START RECODE--
##  I.   Normalizing
##  II.  Projecting to PCA space
##  III. Modifying eigenvalues
##       ell = 166
##    Reducing noise
##  VI.  Reversing to original space
## --END RECODE--

We store the denoised count matrix in seurat[["RECODE"]]@counts.

seurat[["RECODE"]] <- CreateAssayObject(counts = Matrix(data_RECODE, sparse = TRUE))
DefaultAssay(seurat) <- "RECODE"

3 Session information

sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19044)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=Japanese_Japan.932  LC_CTYPE=Japanese_Japan.932    LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C                   LC_TIME=Japanese_Japan.932    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_3.3.5        Matrix_1.3-4         SeuratObject_4.0.2   Seurat_4.0.4         RECODE_1.0.0         rmarkdown_2.8        RevoUtils_11.0.2    
## [8] RevoUtilsMath_11.0.0
## 
## loaded via a namespace (and not attached):
##   [1] plyr_1.8.6            igraph_1.2.5          lazyeval_0.2.2        splines_4.0.2         listenv_0.8.0         scattermore_0.7       usethis_2.0.1        
##   [8] digest_0.6.25         htmltools_0.5.2       viridis_0.5.1         fansi_0.4.1           magrittr_2.0.1        memoise_2.0.0         tensor_1.5           
##  [15] cluster_2.1.0         ROCR_1.0-11           remotes_2.4.0         globals_0.14.0        matrixStats_0.61.0    spatstat.sparse_2.0-0 prettyunits_1.1.1    
##  [22] colorspace_1.4-1      ggrepel_0.8.2         xfun_0.23             dplyr_1.0.7           callr_3.7.0           crayon_1.4.1          jsonlite_1.7.0       
##  [29] spatstat.data_2.1-0   survival_3.1-12       zoo_1.8-8             glue_1.4.1            polyclip_1.10-0       gtable_0.3.0          leiden_0.3.9         
##  [36] pkgbuild_1.2.0        future.apply_1.8.1    abind_1.4-5           scales_1.1.1          DBI_1.1.1             miniUI_0.1.1.1        Rcpp_1.0.7           
##  [43] viridisLite_0.3.0     xtable_1.8-4          reticulate_1.16       spatstat.core_2.3-0   bit_4.0.4             htmlwidgets_1.5.4     httr_1.4.2           
##  [50] RColorBrewer_1.1-2    ellipsis_0.3.2        ica_1.0-2             pkgconfig_2.0.3       farver_2.0.3          sass_0.4.0            uwot_0.1.10          
##  [57] deldir_0.2-10         utf8_1.2.2            tidyselect_1.1.1      labeling_0.4.2        rlang_0.4.11          reshape2_1.4.4        later_1.3.0          
##  [64] munsell_0.5.0         tools_4.0.2           cachem_1.0.6          cli_3.0.1             generics_0.1.0        devtools_2.4.2        ggridges_0.5.3       
##  [71] evaluate_0.14         stringr_1.4.0         fastmap_1.1.0         yaml_2.2.1            goftest_1.2-2         processx_3.5.2        knitr_1.34           
##  [78] bit64_4.0.5           fs_1.5.0              fitdistrplus_1.1-5    purrr_0.3.4           RANN_2.6.1            dendextend_1.15.1     pbapply_1.5-0        
##  [85] future_1.22.1         nlme_3.1-148          mime_0.11             hdf5r_1.3.4           compiler_4.0.2        plotly_4.9.4.1        png_0.1-7            
##  [92] testthat_3.0.4        spatstat.utils_2.2-0  tibble_3.0.3          bslib_0.3.0           stringi_1.4.6         highr_0.9             ps_1.6.0             
##  [99] RSpectra_0.16-0       desc_1.3.0            lattice_0.20-41       vctrs_0.3.8           pillar_1.6.2          lifecycle_1.0.0       spatstat.geom_2.2-2  
## [106] lmtest_0.9-37         jquerylib_0.1.4       RcppAnnoy_0.0.18      data.table_1.12.8     cowplot_1.1.1         irlba_2.3.3           httpuv_1.6.3         
## [113] patchwork_1.0.1       R6_2.4.1              promises_1.2.0.1      KernSmooth_2.23-17    gridExtra_2.3         parallelly_1.28.1     sessioninfo_1.1.1    
## [120] codetools_0.2-16      MASS_7.3-51.6         assertthat_0.2.1      pkgload_1.2.2         rprojroot_2.0.2       withr_2.4.2           sctransform_0.3.2    
## [127] mgcv_1.8-31           parallel_4.0.2        grid_4.0.2            rpart_4.1-15          tidyr_1.1.0           Rtsne_0.15            shiny_1.5.0