This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ReporteR.scRNAseq/inst/content/05-dimension-reduction-A-pca.Rmd
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (51 sloc)
3.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r parameters-and-defaults, include = FALSE} | |
module <- "scRNAseq" | |
section <- "dimension_reduction" | |
``` | |
```{r parameter-merge, include = FALSE} | |
local_params <- module %>% | |
options() %>% | |
magrittr::extract2(module) %>% | |
magrittr::extract2(section) %>% | |
ReporteR.base::validate_params(parameters_and_defaults) | |
``` | |
```{r scRNAseq-dimension-reduction-A-pca-checks, include = FALSE} | |
assertive.sets::assert_is_subset(local_params$features, colnames(SummarizedExperiment::colData(object_filtered))) | |
``` | |
### Principal Component Analysis | |
Here we use **P**rincipal **C**omponent **A**nanalysis (PCA)[@ringner_2008] to visualize single cells in a *expression subspace*. | |
``Principal component analysis (PCA) is a mathematical algorithm that reduces | |
the dimensionality of the data while retaining most of the variation in the | |
data set [...]. It accomplishes this reduction by identifying directions, | |
called principal components, along which the variation in the data is maximal. | |
By using a few components, each sample can be represented by relatively few | |
numbers instead of by values for thousands of variables. Samples can then be | |
plotted, making it possible to visually assess similarities and differences | |
between samples and determine whether samples can be grouped.'' [@ringner_2008] | |
In case of the *expression subspace*, samples are embedded in a high dimensional space described by gene expression, and then reduced down to two principal components by PCA. Typically, PCA arranges samples that are globally similiar in expression in close proximity and enables xxx (Figure \@ref(fig:scRNAseq-quality-control-B-pca-figure)). | |
```{r scRNAseq-dimension-reduction-A-pca-processing, echo=FALSE, include=FALSE} | |
features <- NULL | |
if (local_params$subset_het) { | |
features <- SummarizedExperiment::rowData(object_filtered)$is_het | |
} | |
object_filtered <- scater::runPCA(object_filtered, exprs_values = local_params$assay, feature_set = features, ncomponents = local_params$dims, method = "irlba") | |
``` | |
```{r scRNAseq-dimension-reduction-A-pca-figure-params, include = FALSE, echo = FALSE} | |
fig_height <- ReporteR.base::estimate_figure_height( | |
height_in_panels = 1, | |
panel_height_in_in = params$formatting_defaults$figures$panel_height_in, | |
axis_space_in_in = params$formatting_defaults$figures$axis_space_in, | |
mpf_row_space = as.numeric(grid::convertUnit(grid::unit(5, 'mm'), 'in')), | |
max_height_in_in = params$formatting_defaults$figures$max_height_in) | |
``` | |
```{r scRNAseq-dimension-reduction-A-pca-figure, echo = FALSE, message=FALSE, warning=FALSE, fig.height = fig_height$global, fig.cap = "PCA"} | |
figure_dimred_pca <- multipanelfigure::multi_panel_figure(height = fig_height$sub, columns = min(3, length(local_params$features)), rows = 1, unit = "in") | |
for(i in 1:min(3, length(local_params$features))) { | |
tmp_plot <- object_filtered %>% | |
scater::plotReducedDim(use_dimred = "PCA", colour_by = local_params$features[i], add_ticks = FALSE) + | |
ggplot2::guides(colour = FALSE) + | |
theme_dimred_scatter | |
figure_dimred_pca <- multipanelfigure::fill_panel(figure_dimred_pca, tmp_plot) | |
} | |
figure_dimred_pca | |
``` |