In order to correct for systematic differences in sequencing coverage between libraries we will normalise the dataset. This involves dividing all counts for each cell by a cell-specific scaling factor, often called a “size factor” (Anders and Huber 2010). The assumption here is that any cell-specific bias (e.g., in capture or amplification efficiency) affects all genes equally via scaling of the expected mean count for that cell. The size factor for each cell represents the estimate of the relative bias in that cell, so division of its counts by its size factor should remove that bias.
Specifically we will used the deconvolution method available in the scran package. This method allows to take in consideration the composition bias between samples (Lun et al., 2016)
On top of normalisation the data is also log-transformed. The log-transformation is useful as differences in the log-values represent log-fold changes in expression. Or in other words, which is more interesting - a gene that is expressed at an average count of 50 in cell type A and 10 in cell type B, or a gene that is expressed at an average count of 1100 in A and 1000 in B? Log-transformation focuses on the former by promoting contributions from genes with strong relative differences.
Variable-level metrics are computed by the getVarianceExplained() function (before and after normalization). This calculates the percentage of variance of each gene’s expression that is explained by each variable in the colData of the SingleCellExperiment object. We can then use this to determine which experimental factors are contributing most to the variance in expression. This is useful for diagnosing batch effects or to quickly verify that a treatment has an effect.
The percentage of variance explained by a factor is on the x axis, and in the y axis there is the density of the R-squared values across all genes.
The “total” label is the total number of molecules, that correlates with the detected number of genes, “detected”.
Before normalisation it is expected that most variance will be explained by the sequencing depth, i.e. the total number of umis and the total number of genes
## Warning: Removed 240 rows containing non-finite values (stat_density).
We can see how there is less variance explained now by factors such as the detected genes or the number of counts
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous x-axis
## Warning: Removed 241 rows containing non-finite values (stat_density).
Another way to assess the variance is with a PCA plot. Here again we can see how the sequencing depth(sum) explains most of the variance before the normalisation
Another type of dimensional reduction is the UMAP reduction.
–> –> –> –> –>
–>
Click to expand
## R version 4.0.4 (2021-02-15)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19041)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
## [4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
##
## attached base packages:
## [1] parallel stats4 stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] batchelor_1.6.3 Matrix_1.3-4 scran_1.18.7 org.Mm.eg.db_3.12.0
## [5] AnnotationDbi_1.52.0 scater_1.18.6 ggplot2_3.3.4 SingleCellExperiment_1.12.0
## [9] SummarizedExperiment_1.20.0 Biobase_2.50.0 GenomicRanges_1.42.0 GenomeInfoDb_1.26.7
## [13] IRanges_2.24.1 S4Vectors_0.28.1 BiocGenerics_0.36.1 MatrixGenerics_1.2.1
## [17] matrixStats_0.59.0 here_1.0.1
##
## loaded via a namespace (and not attached):
## [1] bitops_1.0-7 bit64_4.0.5 RcppAnnoy_0.0.18 rprojroot_2.0.2
## [5] tools_4.0.4 bslib_0.2.5.1 ResidualMatrix_1.0.0 utf8_1.2.1
## [9] R6_2.5.0 irlba_2.3.3 vipor_0.4.5 uwot_0.1.10
## [13] DBI_1.1.1 colorspace_2.0-2 withr_2.4.2 tidyselect_1.1.1
## [17] gridExtra_2.3 bit_4.0.4 compiler_4.0.4 BiocNeighbors_1.8.2
## [21] DelayedArray_0.16.3 labeling_0.4.2 sass_0.4.0 scales_1.1.1
## [25] stringr_1.4.0 digest_0.6.27 rmarkdown_2.9 XVector_0.30.0
## [29] pkgconfig_2.0.3 htmltools_0.5.1.1 sparseMatrixStats_1.2.1 limma_3.46.0
## [33] fastmap_1.1.0 highr_0.9 rlang_0.4.10 RSQLite_2.2.7
## [37] DelayedMatrixStats_1.12.3 jquerylib_0.1.4 generics_0.1.0 farver_2.1.0
## [41] jsonlite_1.7.2 BiocParallel_1.24.1 dplyr_1.0.7 RCurl_1.98-1.3
## [45] magrittr_2.0.1 BiocSingular_1.6.0 GenomeInfoDbData_1.2.4 scuttle_1.0.4
## [49] Rcpp_1.0.6 ggbeeswarm_0.6.0 munsell_0.5.0 fansi_0.5.0
## [53] viridis_0.6.1 lifecycle_1.0.0 edgeR_3.32.1 stringi_1.6.2
## [57] yaml_2.2.1 zlibbioc_1.36.0 grid_4.0.4 blob_1.2.1
## [61] dqrng_0.3.0 crayon_1.4.1 lattice_0.20-44 cowplot_1.1.1
## [65] beachmat_2.6.4 locfit_1.5-9.4 knitr_1.33 pillar_1.6.1
## [69] igraph_1.2.6 codetools_0.2-18 glue_1.4.2 evaluate_0.14
## [73] vctrs_0.3.8 gtable_0.3.0 purrr_0.3.4 assertthat_0.2.1
## [77] cachem_1.0.5 xfun_0.21 rsvd_1.0.5 RSpectra_0.16-0
## [81] rsconnect_0.8.18 viridisLite_0.4.0 tibble_3.1.2 beeswarm_0.4.0
## [85] memoise_2.0.0 statmod_1.4.36 bluster_1.0.0 ellipsis_0.3.2